Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
whether they work is to be seen
  • Loading branch information
wackbyte committed Jan 19, 2024
1 parent 24aef8a commit ab8e3a2
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 12 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
43 changes: 43 additions & 0 deletions tests/default/action.yml
Original file line number Diff line number Diff line change
@@ -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

17 changes: 9 additions & 8 deletions tests/action.yml → tests/install/action.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
32 changes: 32 additions & 0 deletions tests/override/action.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ab8e3a2

Please sign in to comment.