-
Notifications
You must be signed in to change notification settings - Fork 21
225 lines (201 loc) · 7.31 KB
/
main.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Main-CI-Flow
on:
push:
branches:
- main
- main-v[0-9].**
tags:
- v[0-9].**
pull_request:
types:
- opened
- reopened
- synchronize
- auto_merge_enabled
- edited
# On PR events, cancel existing CI runs on this same PR for this workflow.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
commitlint:
runs-on: starkware-ubuntu-latest-small
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install commitlint
run: npm install --global @commitlint/cli @commitlint/config-conventional
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main'))
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose
- name: Validate PR title with commitlint
if: github.event_name != 'merge_group' && github.event_name != 'push' && !(contains(github.event.pull_request.title, 'merge-main') || contains(github.event.pull_request.title, 'merge main'))
env:
TITLE: ${{ github.event.pull_request.title }}
run: echo "$TITLE" | commitlint --verbose
code_style:
runs-on: starkware-ubuntu-20-04-medium
steps:
# Enviorment setup.
- uses: actions/checkout@v4
- uses: Noelware/[email protected]
- uses: baptiste0928/cargo-install@v3
with:
crate: taplo-cli
version: '0.9.0'
locked: true
# Setup pypy and link to the location expected by .cargo/config.toml.
- uses: actions/setup-python@v5
id: setup-pypy
with:
python-version: "pypy3.9"
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
- env:
LD_LIBRARY_PATH: ${{ steps.setup-pypy.outputs.pythonLocation }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
# Install rust components.
- uses: ./.github/actions/bootstrap
# Run tests.
- name: "Run rustfmt and clippy"
run: scripts/rust_fmt.sh --check
- name: "Run clippy"
run: scripts/clippy.sh
- name: "Run cargo doc"
run: cargo doc --workspace -r --document-private-items --no-deps
- name: "Run taplo"
run: scripts/taplo.sh
- name: "Run cargo check"
env:
RUSTDOCFLAGS: "-D warnings"
run: cargo check --workspace -r --all-features
- name: Run Machete (detect unused dependencies)
uses: bnjbvr/cargo-machete@main
run-workspace-tests:
runs-on: starkware-ubuntu-latest-medium
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/bootstrap
- run: cargo test -p workspace_tests
run-tests:
runs-on: starkware-ubuntu-20-04-medium
steps:
- uses: actions/checkout@v4
with:
# Fetch the entire history.
fetch-depth: 0
- uses: ./.github/actions/bootstrap
- uses: Noelware/[email protected]
# Setup pypy and link to the location expected by .cargo/config.toml.
- uses: actions/setup-python@v5
id: setup-pypy
with:
python-version: "pypy3.9"
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
- env:
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: "Run tests pull request"
if: github.event_name == 'pull_request'
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_tests.py --changes_only --commit_id ${{ github.event.pull_request.base.sha }}
env:
SEED: 0
- name: "Run tests on push"
if: github.event_name == 'push'
# TODO: Better support for running tests on push.
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_tests.py
env:
SEED: 0
merge-gatekeeper:
runs-on: starkware-ubuntu-latest-small
# Restrict permissions of the GITHUB_TOKEN.
# Docs: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions:
checks: read
statuses: read
steps:
- name: Run Merge Gatekeeper on pull request
if: github.event_name == 'pull_request'
uses: upsidr/merge-gatekeeper@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
timeout: 1200
interval: 30
ignored: "code-review/reviewable"
- name: Run Merge Gatekeeper on Merge Queue || push
if: github.event_name == 'merge_group' || github.event_name == 'push'
uses: upsidr/merge-gatekeeper@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{github.ref}}
timeout: 1200
interval: 30
ignored: "code-review/reviewable"
codecov:
runs-on: starkware-ubuntu-latest-medium
steps:
- uses: actions/checkout@v4
with:
# Fetch the entire history.
fetch-depth: 0
- uses: ./.github/actions/bootstrap
- name: Set-Up
run: |
sudo apt-get update
sudo apt-get install -y clang llvm libudev-dev
- uses: Noelware/[email protected]
with:
version: ${{env.PROTOC_VERSION}}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- run: npm install -g [email protected]
# Setup pypy and link to the location expected by .cargo/config.toml.
- uses: actions/setup-python@v5
id: setup-pypy
with:
python-version: "pypy3.9"
- run: ln -s '${{ steps.setup-pypy.outputs.python-path }}' /usr/local/bin/pypy3.9
- env:
LD_LIBRARY_PATH: ${{ env.Python3_ROOT_DIR }}/bin
run: echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: "Run codecov on pull request"
id: run_codecov_pr
if: github.event_name == 'pull_request'
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_codecov.py --changes_only --commit_id ${{ github.event.pull_request.base.sha }}
if [ -f codecov.json ]; then
echo "codecov_output=true" >> $GITHUB_OUTPUT
else
echo "codecov_output=false" >> $GITHUB_OUTPUT
fi
env:
SEED: 0
- name: "Run codecov on push"
if: github.event_name == 'push'
# TODO: Better support for running tests on push.
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_codecov.py
echo "codecov_output=true" >> $GITHUB_OUTPUT
env:
SEED: 0
- name: Codecov
if: steps.run_codecov_pr.outputs.codecov_output == 'true'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
fail_ci_if_error: true
version: "v0.1.15"