-
Notifications
You must be signed in to change notification settings - Fork 5
206 lines (178 loc) · 6.52 KB
/
Copy pathtest.yml
File metadata and controls
206 lines (178 loc) · 6.52 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: 'Test'
on:
pull_request:
branches: [ "master" ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
code-quality:
name: "Code Quality"
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v7
with:
# Check out pull request HEAD instead of merge commit.
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
- name: Install yq
run: .github/scripts/install-yq.sh
- name: 'Read nightly channel from rust-toolchain.toml'
id: toolchain-meta
run: |
set -euo pipefail
CHANNEL=$(yq -r '.toolchain.channel' rust-toolchain.toml)
if [ -z "$CHANNEL" ] || [ "$CHANNEL" = "null" ]; then
echo "::error::Could not read toolchain.channel from rust-toolchain.toml"
exit 1
fi
echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
- name: "Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain-meta.outputs.channel }}
- name: 'Build stable-mir-json' # rustfmt documentation claims it is unstable on code that doesn't build
run: |
cargo build -vv
- name: "Check `cargo clippy`"
run: |
rustup component add clippy
cargo clippy -- -Dwarnings
- name: "Check `cargo fmt`"
run: |
rustup component add rustfmt
cargo fmt --check
- name: 'Install Nix'
uses: cachix/install-nix-action@v31.11.0
with:
install_url: https://releases.nixos.org/nix/nix-2.30.1/install
extra_nix_config: |
substituters = https://cache.nixos.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- name: "Check `nixfmt`"
run: |
NIX_FILES=$(bash -O globstar -c 'ls **/*.nix')
nix shell nixpkgs#nixfmt-rfc-style --command nixfmt --check ${NIX_FILES}
integration-tests:
needs: code-quality
name: "Integration Tests"
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v7
with:
# Check out pull request HEAD instead of merge commit.
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
- name: Install yq
run: .github/scripts/install-yq.sh
- name: 'Read nightly channel from rust-toolchain.toml'
id: toolchain-meta
run: |
set -euo pipefail
CHANNEL=$(yq -r '.toolchain.channel' rust-toolchain.toml)
if [ -z "$CHANNEL" ] || [ "$CHANNEL" = "null" ]; then
echo "::error::Could not read toolchain.channel from rust-toolchain.toml"
exit 1
fi
echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
- name: "Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain-meta.outputs.channel }}
- name: 'Build stable-mir-json'
run: | # Warning check should be redundant since code-quality runs first
RUSTFLAGS='--deny warnings' cargo build -vv
- name: 'Install a good-enough jq version'
uses: dcarbone/install-jq-action@v4
with:
version: 1.7.1
force: true
- name: 'Run smir integration tests'
run: |
which jq
jq --version
make integration-test
ui-tests:
needs: code-quality
name: "UI Tests"
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v7
with:
# Check out pull request HEAD instead of merge commit.
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
- name: Install yq
run: .github/scripts/install-yq.sh
- name: 'Read nightly channel from rust-toolchain.toml'
id: toolchain-meta
run: |
set -euo pipefail
CHANNEL=$(yq -r '.toolchain.channel' rust-toolchain.toml)
if [ -z "$CHANNEL" ] || [ "$CHANNEL" = "null" ]; then
echo "::error::Could not read toolchain.channel from rust-toolchain.toml"
exit 1
fi
echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
- name: "Set up nightly Rust" # https://github.com/rust-lang/rustup/issues/3409
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain-meta.outputs.channel }}
- name: 'Derive rustc commit and check out Rust repo'
id: rustc-meta
run: |
set -euo pipefail
COMMIT=$(rustc -vV | grep 'commit-hash' | cut -d' ' -f2)
if [ -z "$COMMIT" ]; then
echo "::error::Could not determine rustc commit-hash from 'rustc -vV'"
exit 1
fi
echo "rustc-commit=$COMMIT" >> "$GITHUB_OUTPUT"
- name: 'Check out Rust repo'
uses: actions/checkout@v7
with:
repository: rust-lang/rust
ref: ${{ steps.rustc-meta.outputs.rustc-commit }}
path: rust
fetch-depth: 1
- name: 'Build stable-mir-json'
run: | # Warning check should be redundant since code-quality runs first
RUSTFLAGS='--deny warnings' cargo build -vv
- name: 'Run smir UI tests'
run: |
RUST_DIR_ROOT='rust' VERBOSE=1 make test-ui
nix:
needs: code-quality
name: 'Nix Tests'
strategy:
fail-fast: false
matrix:
runner: [normal, MacM1] # MacM1 / normal are self-hosted,
runs-on: ${{ matrix.runner }}
timeout-minutes: 20
steps:
- name: 'Check out code'
uses: actions/checkout@v7
with:
# Check out pull request HEAD instead of merge commit.
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
- name: 'Install Nix'
if: ${{ matrix.runner != 'MacM1' }}
uses: cachix/install-nix-action@v31.11.0
with:
install_url: https://releases.nixos.org/nix/nix-2.30.1/install
extra_nix_config: |
substituters = https://cache.nixos.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- name: 'Build and test'
run: |
set -euxo pipefail
nix --version
nix flake check # build and run integration & unit tests