-
Notifications
You must be signed in to change notification settings - Fork 1
194 lines (164 loc) · 5.03 KB
/
ci.yaml
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
name: ci
on:
push:
branches:
- main
tags-ignore:
- v*
pull_request:
branches:
- main
schedule:
- cron: 0 4/12 * * *
workflow_dispatch:
inputs:
nightly:
description: use latest nightly
required: true
type: boolean
concurrency:
group: ${{github.workflow}}-${{github.head_ref || github.run_id}}
cancel-in-progress: true
jobs:
toolchain:
runs-on: ubuntu-latest
env:
nightly: ${{(github.event.inputs.nightly == 'true' || github.event_name == 'schedule') && 'true' || ''}}
outputs:
toolchain: ${{steps.set_toolchain.outputs.toolchain}}
nightly_toolchain: ${{steps.set_toolchain.outputs.nightly_toolchain}}
steps:
- uses: actions/checkout@v4
- name: Set toolchain
id: set_toolchain
env:
toolchain_toml: "rust-toolchain.toml"
run: |
if [[ -z $nightly ]] && [[ -f $toolchain_toml ]]; then
toolchain=$(grep channel $toolchain_toml | sed -r 's/channel = "(.*)"/\1/')
echo "using toolchain $toolchain from rust-toolchain.toml"
echo "toolchain=$toolchain" >> "$GITHUB_OUTPUT"
if [[ $toolchain =~ ^nightly.* ]]; then
echo "using nightly_toolchain $toolchain"
echo "nightly_toolchain=$toolchain" >> "$GITHUB_OUTPUT"
else
echo "using nightly_toolchain nightly"
echo "nightly_toolchain=nightly" >> "$GITHUB_OUTPUT"
fi
else
toolchain='nightly'
echo "using toolchain nightly"
echo "toolchain=nightly" >> "$GITHUB_OUTPUT"
echo "using nightly_toolchain nightly"
echo "nightly_toolchain=nightly" >> "$GITHUB_OUTPUT"
fi
check:
runs-on: ubuntu-latest
needs: toolchain
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{needs.toolchain.outputs.toolchain}}
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- uses: Swatinem/rust-cache@v2
- name: just check
run: |
rustup override set ${{needs.toolchain.outputs.toolchain}}
just check
fmt-check:
runs-on: ubuntu-latest
needs: toolchain
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{needs.toolchain.outputs.nightly_toolchain}}
components: rustfmt
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- uses: Swatinem/rust-cache@v2
- name: just fmt-check
run: |
rustup override set ${{needs.toolchain.outputs.nightly_toolchain}}
just fmt-check ''
lint:
runs-on: ubuntu-latest
needs: [toolchain, check, fmt-check]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: ${{needs.toolchain.outputs.toolchain}}
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- uses: Swatinem/rust-cache@v2
- name: just lint
run: |
rustup override set ${{needs.toolchain.outputs.toolchain}}
just lint
test:
runs-on: ubuntu-latest
needs: [toolchain, check, fmt-check]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{needs.toolchain.outputs.toolchain}}
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- uses: Swatinem/rust-cache@v2
- name: just test
run: |
rustup override set ${{needs.toolchain.outputs.toolchain}}
just test
doc:
runs-on: ubuntu-latest
needs: [toolchain, check, fmt-check]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{needs.toolchain.outputs.nightly_toolchain}}
- name: Install just
uses: taiki-e/install-action@v2
with:
tool: just
- uses: Swatinem/rust-cache@v2
- name: just doc
run: |
rustup override set ${{needs.toolchain.outputs.nightly_toolchain}}
just doc ''
dependabot:
runs-on: ubuntu-latest
needs: [doc, lint, test]
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
permissions:
contents: write
pull-requests: write
steps:
- name: approve
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: merge
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}