diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10e0bf2..22b850b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,8 @@ permissions: contents: read jobs: - test: - name: Rust ${{matrix.rust}} on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || 'unknown'}} + test-install: + name: Install test for Rust ${{matrix.rust}} on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || 'unknown'}} runs-on: ${{matrix.os}}-latest strategy: fail-fast: false @@ -37,7 +37,25 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Run tests - uses: ./tests + - name: Run test + uses: ./tests/install with: toolchain: ${{matrix.rust}} + + test-default: + name: Default test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Run test + uses: ./tests/default + + test-override: + name: Override test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Run test + uses: ./tests/override diff --git a/tests/default/action.yml b/tests/default/action.yml new file mode 100644 index 0000000..7ef9941 --- /dev/null +++ b/tests/default/action.yml @@ -0,0 +1,43 @@ +name: Default test +description: Check that the default setting works and that the action may be run multiple times + +runs: + using: composite + steps: + - name: Install Rust 1.74.1 (without default) + id: toolchain-1-74-1 + uses: ./ + with: + toolchain: 1.74.1 + + - name: Install Rust 1.75.0 (with default) + id: toolchain-1-75-0 + uses: ./ + with: + toolchain: 1.75.0 + default: true + + - name: 1.74.1 cache key + run: echo '${{steps.toolchain-1-74-1.outputs.cachekey}}' + shell: bash + + - name: 1.75.0 cache key + run: echo '${{steps.toolchain-1-75-0.outputs.cachekey}}' + shell: bash + + - name: Default rustc version + run: rustc --version + shell: bash + + - name: Check 1.74.1 cache key + run: cmp -s <(echo ${{steps.toolchain-1-74-1.outputs.cachekey}}) <(echo PLACEHOLDER) + shell: bash + + - name: Check 1.75.0 cache key + run: cmp -s <(echo ${{steps.toolchain-1-75-0.outputs.cachekey}}) <(echo PLACEHOLDER) + shell: bash + + - name: Check default rustc version + run: cmp -s <(rustc --version) <(echo PLACEHOLDER) + shell: bash + diff --git a/tests/action.yml b/tests/install/action.yml similarity index 73% rename from tests/action.yml rename to tests/install/action.yml index 0def33e..78c97a8 100644 --- a/tests/action.yml +++ b/tests/install/action.yml @@ -1,33 +1,34 @@ -name: Test -description: Run the test suite +name: Install test +description: Check that the action works inputs: toolchain: - description: + description: Rust toolchain name required: true runs: using: composite steps: - - name: Run action for ${{inputs.toolchain}} + - name: Install Rust ${{inputs.toolchain}} id: toolchain uses: ./ with: toolchain: ${{inputs.toolchain}} - - name: echo ${{'${{steps.toolchain.outputs.cachekey}}'}} + - name: Cache key run: echo '${{steps.toolchain.outputs.cachekey}}' shell: bash - - name: check ${{'${{steps.toolchain.outputs.cachekey}}'}} + - name: Check cache key if: inputs.toolchain == '1.62.0' run: cmp -s <(echo ${{steps.toolchain.outputs.cachekey}}) <(echo 20220627a831) shell: bash - - run: rustc --version + - name: rustc version + run: rustc --version shell: bash - - run: cargo init . --bin --name ci + - run: cargo init . --bin --name test if: inputs.toolchain == 'nightly' || inputs.toolchain == 'beta' || inputs.toolchain == 'stable' shell: bash diff --git a/tests/override/action.yml b/tests/override/action.yml new file mode 100644 index 0000000..20e5416 --- /dev/null +++ b/tests/override/action.yml @@ -0,0 +1,32 @@ +name: Override test +description: Check that the override setting works + +runs: + using: composite + steps: + - name: Install Rust stable + id: toolchain + uses: ./ + with: + toolchain: stable + override: true + + - name: Stable cache key + run: echo '${{steps.toolchain.outputs.cachekey}}' + shell: bash + + - name: Stable rustc version + id: rustc + run: | + echo "version=$(rustc --version)" >> $GITHUB_OUTPUT + shell: bash + + - run: cargo init . --bin --name test + shell: bash + + - run: echo '1.70.0' > rust-toolchain + shell: bash + + - name: Check rustc version is overridden + run: cmp -s <(rustc --version) <(echo ${{steps.rustc.outputs.version}}) + shell: bash