-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (147 loc) · 6.4 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
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
name: Tests
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
runs-on: warp-ubuntu-latest-x64-16x
steps:
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://git@github.com
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: argumentcomputer/ci-workflows
- uses: ./.github/actions/ci-env
- uses: ./.github/actions/install-deps
with:
packages: opam
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Linux Tests
run: |
cargo nextest run --profile ci --cargo-profile dev-ci --workspace --run-ignored all --features loam
clippy:
runs-on: ubuntu-latest
steps:
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://git@github.com
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: argumentcomputer/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check Rustfmt Code Style
run: cargo fmt --all --check
- name: check *everything* compiles
run: cargo check --all-targets --all-features --workspace --examples --tests --benches
# See '.cargo/config' for list of enabled/disabled clippy lints
- name: Check clippy warnings
run: cargo xclippy -D warnings
- name: Doctests
run: cargo test --doc --workspace
# TODO: Uncomment once https://github.com/EmbarkStudios/cargo-deny-action/issues/67 is released
# - name: Cargo-deny
# uses: EmbarkStudios/cargo-deny-action@v1
bench-regression:
runs-on: warp-ubuntu-latest-x64-32x
steps:
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://git@github.com
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: argumentcomputer/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Set env
run: |
echo "TESTS=fib_e2e" | tee -a $GITHUB_ENV
echo "LOAM_FIB_ARG=50000" | tee -a $GITHUB_ENV
- name: Get benchmark for PR
id: bench_pr
run: |
BENCH_RESULTS='[]'
for test_name in ${{ env.TESTS }}; do
cargo nextest run -E "test($test_name)" --release --nocapture --run-ignored all | tee out.txt 2>&1
BENCH=$(grep 'Total time' out.txt | awk -F'= ' '{ print $2 }')
BENCH_RESULTS=$(echo $BENCH_RESULTS | jq -c ". += [{\"${test_name}\": \"$BENCH\"}]")
done
echo "BENCH_RESULTS=$BENCH_RESULTS" | tee -a "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Get bench for base branch
id: regression-check
continue-on-error: false
run: |
counter=0
BENCH_RESULTS='${{ steps.bench_pr.outputs.BENCH_RESULTS }}'
echo "$BENCH_RESULTS"
SLOW_TESTS=""
REGRESSION="false"
for test_name in ${{ env.TESTS }}; do
cargo nextest run -E "test($test_name)" --release --nocapture --run-ignored all | tee out.txt 2>&1
BENCH_BASE=$(grep 'Total time' out.txt | awk -F'= ' '{ print $2 }')
BENCH_PR=$(echo "$BENCH_RESULTS" | jq ".[$counter] | to_entries | .[0].value" | sed 's/"//g')
echo "$test_name summary"
echo "Base = $BENCH_BASE, PR = $BENCH_PR"
if [[ -z $BENCH_BASE || -z $BENCH_PR ]]; then
exit 1
fi
BENCH_BASE_NUM=${BENCH_BASE%% *}
BENCH_PR_NUM=${BENCH_PR%% *}
# 10% slowdown threshold
REGRESSION_THRESHOLD=$(echo "$BENCH_BASE_NUM * 1.10" | bc)
if (( $(echo "$BENCH_PR_NUM >= $REGRESSION_THRESHOLD" | bc -l) )); then
echo "Performance regression for test ${test_name}"
REGRESSION="true"
SLOW_TESTS+="\`${test_name}\`\n"
SLOW_TESTS+="Bench result before: $BENCH_BASE\n"
SLOW_TESTS+="Bench result after: $BENCH_PR\n"
fi
counter=$((counter + 1))
done
echo "regression=$REGRESSION" | tee -a $GITHUB_OUTPUT
echo "slow-tests<<EOF" >> $GITHUB_OUTPUT
echo -e "$SLOW_TESTS" | tee -a $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "WORKFLOW_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
- name: Comment on failing run
if: steps.regression-check.outputs.regression == 'true' && github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Benchmark regression check failed :x:
${{ steps.regression-check.outputs.slow-tests }}
${{ env.WORKFLOW_URL }}
- uses: JasonEtco/create-an-issue@v2
if: steps.regression-check.outputs.regression == 'true' && github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_URL: ${{ env.WORKFLOW_URL }}
SLOW_TESTS: ${{ steps.regression-check.outputs.slow-tests }}
with:
update_existing: true
filename: .github/BENCH_REGRESSION.md