-
Notifications
You must be signed in to change notification settings - Fork 2
178 lines (150 loc) · 4.53 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
name: CI
on:
push:
branches:
- main
tags-ignore:
- hello-tracing-backend/v*
- hello-tracing-common/v*
- hello-tracing-gateway/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
run: |
toolchain=$(grep channel rust-toolchain.toml | sed -r 's/channel = "(.*)"/\1/')
echo "using toolchain $toolchain"
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
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
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- 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
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- 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
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: Swatinem/rust-cache@v2
- name: just test
run: |
rustup override set ${{needs.toolchain.outputs.toolchain}}
just test
dependabot:
runs-on: ubuntu-latest
needs: [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}}