mirror of
https://github.com/jdx/mise-action.git
synced 2026-05-14 22:00:34 +00:00
GITHUB_ENV persists across all steps in a job. Each test now explicitly sets MISE_ENV before running to ensure isolation between tests.
275 lines
8.1 KiB
YAML
275 lines
8.1 KiB
YAML
name: "build-test"
|
|
on: # rebuild any PRs and main branch changes
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref_name }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build: # make sure build/ci work properly
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
- run: |
|
|
npm install
|
|
- run: |
|
|
npm run all
|
|
test: # make sure the action works on a clean machine without building
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- name: ubuntu
|
|
runs-on: ubuntu-latest
|
|
- name: macos
|
|
runs-on: macos-latest
|
|
- name: windows
|
|
runs-on: windows-latest
|
|
- name: alpine
|
|
runs-on: ubuntu-latest
|
|
container: alpine:latest
|
|
requirements: apk add --no-cache curl bash
|
|
name: ${{ matrix.name }}
|
|
runs-on: ${{ matrix.runs-on }}
|
|
container: ${{ matrix.container }}
|
|
steps:
|
|
- name: Install requirements
|
|
if: ${{ matrix.requirements }}
|
|
run: ${{ matrix.requirements }}
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
- name: Setup mise
|
|
uses: ./
|
|
with:
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
|
|
[env]
|
|
MY_ENV_VAR = "abc"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- run: mise --version
|
|
- run: mise x jq -- jq --version
|
|
- run: which jq
|
|
- run: jq --version
|
|
- run: . scripts/test.sh
|
|
shell: bash
|
|
|
|
specific_version:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
- name: Setup mise
|
|
uses: ./
|
|
with:
|
|
cache_save: ${{ github.ref_name == 'main' }}
|
|
cache_key_prefix: mise-v1
|
|
version: 2025.7.3
|
|
sha256: d38d4993c5379a680b50661f86287731dc1d1264777880a79b786403af337948
|
|
install_args: bun
|
|
mise_toml: |
|
|
[tools]
|
|
bun = "1"
|
|
- run: which bun
|
|
- run: bun -v
|
|
- name: Update mise
|
|
uses: ./
|
|
with:
|
|
cache_save: ${{ github.ref_name == 'main' }}
|
|
cache_key_prefix: mise-v1
|
|
version: v2025.7.3 # should trim the `v`
|
|
sha256: d38d4993c5379a680b50661f86287731dc1d1264777880a79b786403af337948
|
|
|
|
checksum_failure:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
- name: Setup mise
|
|
id: bad
|
|
uses: ./
|
|
with:
|
|
version: 2024.9.6
|
|
sha256: 1f0b8c3d2e4f5a6b7c8d9e0f1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t
|
|
continue-on-error: true
|
|
- name: Dump steps context
|
|
if: ${{ always() }}
|
|
env:
|
|
STEPS_CONTEXT: ${{ toJson(steps) }}
|
|
run: echo "$STEPS_CONTEXT"
|
|
- name: expect failure
|
|
run: echo "Failed as expected"
|
|
if: ${{ steps.bad.outcome == 'failure' }}
|
|
- name: not failed as expected
|
|
run: |
|
|
echo "Expected failure but the job was ${{ steps.bad.outcome }}"
|
|
exit 1
|
|
if: ${{ steps.bad.outcome != 'failure' }}
|
|
|
|
custom_cache_key:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
- name: Setup mise with custom cache key
|
|
uses: ./
|
|
with:
|
|
cache_key: "custom-{{platform}}-{{install_args_hash}}-${{ github.run_id }}"
|
|
install_args: "jq@1.7.1"
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
- run: mise --version
|
|
- run: mise x jq -- jq --version
|
|
- run: which jq
|
|
- run: jq --version
|
|
|
|
fetch_from_github:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
- name: Setup mise from mise.jdx.dev
|
|
uses: ./
|
|
with:
|
|
fetch_from_github: true
|
|
cache: false
|
|
cache_save: false
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
- run: mise --version
|
|
- run: mise x jq -- jq --version
|
|
- run: which jq
|
|
- run: jq --version
|
|
|
|
mise_environment_test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
|
|
# Test 1: Basic environment input
|
|
- name: Setup mise with environment input
|
|
uses: ./
|
|
with:
|
|
environment: preview
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
|
|
[env]
|
|
TEST_VAR = "test-value"
|
|
|
|
- name: Verify MISE_ENV is set in subsequent steps
|
|
run: |
|
|
if [ "$MISE_ENV" != "preview" ]; then
|
|
echo "MISE_ENV not set correctly: got '$MISE_ENV', expected 'preview'"
|
|
exit 1
|
|
fi
|
|
echo "✓ MISE_ENV correctly set to: $MISE_ENV"
|
|
|
|
- name: Verify mise environment variables are loaded
|
|
run: |
|
|
if [ "$TEST_VAR" != "test-value" ]; then
|
|
echo "Environment variable not loaded: got '$TEST_VAR'"
|
|
exit 1
|
|
fi
|
|
echo "✓ Environment variables loaded correctly"
|
|
|
|
# Test 2: MISE_ENV environment variable takes precedence
|
|
# Clear MISE_ENV first since it persists from previous test
|
|
- name: Clear MISE_ENV from previous test
|
|
run: |
|
|
echo "MISE_ENV=production" >> $GITHUB_ENV
|
|
|
|
- name: Setup mise with both env var and input
|
|
uses: ./
|
|
with:
|
|
environment: staging
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
|
|
[env]
|
|
PROD_VAR = "production-value"
|
|
|
|
- name: Verify existing MISE_ENV takes precedence
|
|
run: |
|
|
if [ "$MISE_ENV" != "production" ]; then
|
|
echo "MISE_ENV should be 'production' (from env var), got '$MISE_ENV'"
|
|
exit 1
|
|
fi
|
|
echo "✓ Existing MISE_ENV correctly took precedence"
|
|
|
|
- name: Verify environment variables are loaded
|
|
run: |
|
|
if [ "$PROD_VAR" != "production-value" ]; then
|
|
echo "Environment variable not loaded: got '$PROD_VAR'"
|
|
exit 1
|
|
fi
|
|
echo "✓ Environment variables loaded correctly"
|
|
|
|
# Test 3: Cache key includes environment
|
|
- name: Clear MISE_ENV for cache test
|
|
run: echo "MISE_ENV=test-env" >> $GITHUB_ENV
|
|
|
|
- name: Setup mise with environment (cache test)
|
|
uses: ./
|
|
with:
|
|
environment: test-env
|
|
cache_key: "test-{{mise_env}}-{{platform}}-${{ github.run_id }}"
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
|
|
- name: Verify environment persists
|
|
run: |
|
|
if [ "$MISE_ENV" != "test-env" ]; then
|
|
echo "MISE_ENV not persisted correctly: got '$MISE_ENV'"
|
|
exit 1
|
|
fi
|
|
echo "✓ MISE_ENV persisted correctly for cache test"
|
|
|
|
# Test 4: Respect env=false input
|
|
- name: Clear MISE_ENV for next test
|
|
run: echo "MISE_ENV=no-export" >> $GITHUB_ENV
|
|
|
|
- name: Setup mise with env=false
|
|
uses: ./
|
|
with:
|
|
environment: no-export
|
|
env: false
|
|
install: false
|
|
mise_toml: |
|
|
[tools]
|
|
jq = "1.7.1"
|
|
|
|
- name: Verify MISE_ENV is set even with env=false
|
|
run: |
|
|
# MISE_ENV should be set by the action
|
|
if [ "$MISE_ENV" != "no-export" ]; then
|
|
echo "MISE_ENV should be set to 'no-export', got '$MISE_ENV'"
|
|
exit 1
|
|
fi
|
|
echo "✓ MISE_ENV set even with env=false"
|
|
|
|
final:
|
|
needs:
|
|
- build
|
|
- test
|
|
- specific_version
|
|
- checksum_failure
|
|
- custom_cache_key
|
|
- fetch_from_github
|
|
- mise_environment_test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 1
|
|
if: always()
|
|
steps:
|
|
- name: Check CI job results
|
|
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')
|
|
run: exit 1
|