Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output .tool-versions contents as an object #311

Open
jthegedus opened this issue May 16, 2021 · 2 comments
Open

output .tool-versions contents as an object #311

jthegedus opened this issue May 16, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@jthegedus
Copy link
Contributor

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 CI pipeline:

      - 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
// asdf action output (asdf_tools)
{
  "nodejs": "14.16.1"
}
# 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.

@jthegedus jthegedus added the enhancement New feature or request label May 16, 2021
@steebchen
Copy link

This would be extremely useful to have

@klippx
Copy link

klippx commented Nov 8, 2023

Very useful, take my money! ✋ 💵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants