setup-rust-toolchain/.github/workflows/ci.yml

107 lines
2.9 KiB
YAML
Raw Normal View History

2022-04-18 03:15:23 +08:00
name: CI
on:
push: { branches: [main] }
2022-04-18 03:15:23 +08:00
pull_request:
schedule: [cron: "40 1 * * *"]
jobs:
install:
2024-01-14 00:03:46 +08:00
name: Rust ${{matrix.rust || '(default)'}} (toolchain-file=${{matrix.write-toolchain-file}}) (${{matrix.os}})
2023-02-14 06:21:02 +08:00
runs-on: ${{matrix.os}}
2022-04-18 03:15:23 +08:00
strategy:
fail-fast: false
2024-01-14 01:44:20 +08:00
max-parallel: 5
2022-04-18 03:15:23 +08:00
matrix:
2024-01-13 23:54:38 +08:00
os:
- ubuntu-latest
- windows-latest
- macos-latest
write-toolchain-file:
- false
- true
rust:
2024-01-13 23:54:38 +08:00
# use stable toolchain as default
- null
# Test that the sparse registry check works.
# 1.66 and 1.67 don't support stable sparse registry.
- "1.66"
- "nightly"
- "beta"
- "stable"
2022-04-18 03:15:23 +08:00
steps:
- uses: actions/checkout@v4
2022-07-22 05:26:47 +08:00
# Test toolchain file support
- name: Write rust-toolchain.toml
2024-01-13 23:54:38 +08:00
if: matrix.write-toolchain-file
shell: bash
2022-07-22 05:26:47 +08:00
run: |
cat <<EOF >>rust-toolchain.toml
[toolchain]
2024-01-13 23:54:38 +08:00
channel = "nightly-2024-01-10"
2022-07-22 05:26:47 +08:00
components = [ "rustfmt", "rustc-dev" ]
targets = [ "wasm32-unknown-unknown", "thumbv7m-none-eabi" ]
2022-07-22 05:26:47 +08:00
profile = "minimal"
EOF
- id: toolchain
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust || 'on toolchain file'}}
uses: ./
2022-04-18 03:15:23 +08:00
with:
toolchain: ${{matrix.rust}}
components: clippy
2022-04-18 03:15:23 +08:00
- name: Check ${{'${{steps.toolchain.outputs.rustc-version}}'}}
run: echo '${{steps.toolchain.outputs.rustc-version}}'
2022-04-18 03:15:23 +08:00
- name: Check ${{'${{steps.toolchain.outputs.cargo-version}}'}}
run: echo '${{steps.toolchain.outputs.cargo-version}}'
2022-04-18 03:15:23 +08:00
- name: Check ${{'${{steps.toolchain.outputs.rustup-version}}'}}
run: echo '${{steps.toolchain.outputs.rustup-version}}'
2024-01-13 23:54:38 +08:00
- name: Check lack of toolchain input or file results in stable
2024-01-13 23:57:48 +08:00
if: matrix.write-toolchain-file == false && matrix.rust == null
2024-01-13 23:54:38 +08:00
shell: bash
run: |-
rustcv="$(rustc --version)"
[[ "$rustcv" != *"nightly"* && "$rustcv" != *"beta"* ]]
- name: Check toolchain file is being overridden
if: matrix.write-toolchain-file
shell: bash
run: |-
rustcv="$(rustc --version)"
[[ ! ( "$rustcv" == *"nightly"* && "$rustcv" == *"2024-01-10"* ) ]]
- shell: bash
run: rustc --version && cargo --version
# Test with creating a small project
- run: cargo init . --bin --name ci
# Add tiny empty crate.
# This checks that registry access works.
- run: cargo add serde_as
- run: cargo clippy
2024-01-14 01:25:41 +08:00
cache:
name: Cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
2024-01-14 01:44:20 +08:00
- name: Install Rust
2024-01-14 01:25:41 +08:00
uses: ./
with:
components: clippy
cache: true
cache-workspaces: |-
./test-workspace
2024-01-14 01:36:31 +08:00
- run: cargo clippy --manifest-path=./test-workspace/Cargo.toml