asdf-vm / asdf-vm/actions

output `.tool-versions` contents as an object

Open
#311 2 comments 10 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
163
Forks
50
PR merge metrics
No merged PRs in 30d

Description

**problem**

`asdf` only has *nix support but sometimes we use `asdf` to build tools for all platforms. When it comes to writting tests for unsupported platforms, namely Windows, we have to resort to doubling up our workflow tool installation.

An example from [`svelte-adapter-firebase`](https://github.com/jthegedus/svelte-adapter-firebase/blob/main/.github/workflows/test.yml) CI pipeline:

```yaml
- uses: actions/checkout@v2
- name: install asdf
if: matrix.os != 'windows-latest'
uses: asdf-vm/actions/install@v1
with:
before_install: bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'

# START: Windows
- name: install Node.js on Windows
if: matrix.os == 'windows-latest'
uses: actions/setup-node@v2
with:
node-version: 14.16.1
- name: install pnpm on Windows
if: matrix.os == 'windows-latest'
run: curl -f https://get.pnpm.io/v6.js | node - add --global pnpm@6
# END: Windows

- name: Install svelte-adapter-firebase deps
run: pnpm install
```

Note the hardcoded `node-version` in the Windows section.

**solution**

If `asdf` were to output the contents of the `.tool-versions` file as an object, this could be referenced in later steps in the CI pipeline, removing the need for hard-coded values when supporting other OSs.

EG:

```
# .tool-versions
nodejs 14.16.1
```

```js
// asdf action output (asdf_tools)
{
"nodejs": "14.16.1"
}
```

```diff
# github action
- uses: actions/checkout@v2
- name: install asdf
+ id: install_asdf
if: matrix.os != 'windows-latest'
uses: asdf-vm/actions/install@v1
with:
before_install: bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'

# START: Windows
- name: install Node.js on Windows
if: matrix.os == 'windows-latest'
uses: actions/setup-node@v2
with:
- node-version: 14.16.1
+ node-version: steps.install_asdf.outputs.asdf_tools.nodejs
```

This seems relatively simple to implement and give a more flexible solution to this problem than currently available.

**alternatives**

I have yet to explore running WSL in the Action Windows runner, which might prove a more useful solution.

Contributor guide

Open the contributing guide

Research direction

Start with the action installation flow described in the issue and compare it with the example workflow in .github/workflows/test.yml from svelte-adapter-firebase. Use the .tool-versions example as the input contract, and consider the work done when the action exposes its tool versions as an object that later GitHub Actions steps can reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, javascript
Domain
ci-cd, devops
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.