.github/workflows/nupm-tests.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reusable workflow to be able to provide defaults to the CI | |
on: | |
workflow_dispatch: | |
inputs: | |
nu_version: | |
description: "A valid NPM-style semver specification, such as '0.86.0', etc. and 'nightly', supports '0.60.0' -> latest and latest 'nightly'" | |
default: "*" | |
type: string | |
nupm_revision: | |
description: "A commit hash, branch name or tag to checkout before installing Nupm." | |
required: true | |
default: "*" | |
type: string | |
timeout: | |
description: "The timeout of the ci job. Default is 20min" | |
default: 20 | |
type: number | |
workflow_call: | |
inputs: | |
nu_version: | |
description: "A valid NPM-style semver specification, such as '0.86.0', etc. and 'nightly', supports '0.60.0' -> latest and latest 'nightly'" | |
default: "*" | |
type: string | |
nupm_revision: | |
description: "A commit hash, branch name or tag to checkout before installing Nupm." | |
required: true | |
default: "*" | |
type: string | |
timeout: | |
description: "The timeout of the ci job. Default is 20min" | |
default: 20 | |
type: number | |
env: | |
NU_LOG_LEVEL: DEBUG | |
GITHUB_TOKEN: ${{ github.token }} | |
defaults: | |
run: | |
shell: nu {0} | |
jobs: | |
nupm-tests: | |
timeout-minutes: ${{ inputs.timeout }} | |
strategy: | |
fail-fast: true | |
matrix: | |
platform: [windows-latest, macos-latest, ubuntu-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Nushell and Nupm versions | |
shell: bash | |
run: | | |
echo "target: ${{github.base_ref}}" | |
echo "ref: ${{github.ref}}" | |
if [[ '${{ github.base_ref }}' == 'nightly' ]]; then | |
echo "NU_VERSION='nightly'" >> $GITHUB_ENV | |
echo "NUPM_REVISION='main'" >> $GITHUB_ENV | |
elif [[ '${{ github.ref }}' == 'refs/heads/nightly' ]]; then | |
echo "NU_VERSION='nightly'" >> $GITHUB_ENV | |
echo "NUPM_REVISION='main'" >> $GITHUB_ENV | |
else | |
echo "NU_VERSION=${{ inputs.nu_version }}" >> $GITHUB_ENV | |
echo "NUPM_REVISION=${{ inputs.nupm_revision }}" >> $GITHUB_ENV | |
fi | |
- name: Setup nushell and nupm | |
uses: amtoine/setup-nupm-action@0.1.1 | |
id: "nu-setup" | |
with: | |
nu_version: ${{ env.NU_VERSION }} | |
nupm_revision: ${{ env.NUPM_REVISION }} | |
- name: Set up Git | |
shell: bash | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global init.defaultBranch main | |
- name: Run the tests | |
run: | | |
# NOTE: required for `use nupm` to work inside `toolkit test` | |
"$env.NU_LIB_DIRS = [ (${{ steps.nu-setup.outputs.nupm_path }} | path dirname) ]" | |
| save --force /tmp/env.nu | |
# NOTE: required for `use toolkit.nu` to work | |
nu --env-config /tmp/env.nu --commands " | |
use toolkit.nu | |
toolkit test --verbose | |
" |