-
Notifications
You must be signed in to change notification settings - Fork 32
106 lines (88 loc) · 2.94 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: CI
on:
push: { branches: [main] }
pull_request:
schedule: [cron: "40 1 * * *"]
jobs:
install:
name: Rust ${{matrix.rust || '(default)'}} (toolchain-file=${{matrix.write-toolchain-file}}) (${{matrix.os}})
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
max-parallel: 5
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
write-toolchain-file:
- false
- true
rust:
# 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"
steps:
- uses: actions/checkout@v4
# Test toolchain file support
- name: Write rust-toolchain.toml
if: matrix.write-toolchain-file
shell: bash
run: |
cat <<EOF >>rust-toolchain.toml
[toolchain]
channel = "nightly-2024-01-10"
components = [ "rustfmt", "rustc-dev" ]
targets = [ "wasm32-unknown-unknown", "thumbv7m-none-eabi" ]
profile = "minimal"
EOF
- id: toolchain
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust || 'on toolchain file'}}
uses: ./
with:
toolchain: ${{matrix.rust}}
components: clippy
- name: Check ${{'${{steps.toolchain.outputs.rustc-version}}'}}
run: echo '${{steps.toolchain.outputs.rustc-version}}'
- name: Check ${{'${{steps.toolchain.outputs.cargo-version}}'}}
run: echo '${{steps.toolchain.outputs.cargo-version}}'
- name: Check ${{'${{steps.toolchain.outputs.rustup-version}}'}}
run: echo '${{steps.toolchain.outputs.rustup-version}}'
- name: Check lack of toolchain input or file results in stable
if: matrix.write-toolchain-file == false && matrix.rust == null
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
cache:
name: Cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: ./
with:
components: clippy
cache: true
cache-workspaces: |-
./test-workspace
- run: cargo clippy --manifest-path=./test-workspace/Cargo.toml