-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (182 loc) · 7.18 KB
/
Copy pathby-ecosystem-roundtrip.yaml
File metadata and controls
210 lines (182 loc) · 7.18 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
207
208
209
210
name: by ecosystem round-trip
permissions: {}
on:
pull_request:
paths:
- "crates/by_transforms/**"
- "crates/ty/**"
- "crates/ruff_python_ast/**"
- "crates/ruff_python_parser/**"
- "crates/ruff_python_codegen/**"
- "scripts/check_ecosystem_roundtrip.py"
- "scripts/setup_primer_project.py"
- "crates/ty_python_semantic/resources/primer/**"
- ".github/workflows/by-ecosystem-roundtrip.yaml"
- "Cargo.lock"
- "!**.md"
- "!**.snap"
concurrency:
group: by-ecosystem-roundtrip-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: 1
CARGO_PROFILE_PROFILING_DEBUG: line-tables-only
jobs:
build:
name: Build by (base + head)
# re-enable when we have depot support
# runs-on: ${{ github.repository == 'KotlinIsland/basedpython' && 'depot-ubuntu-22.04-32' || 'ubuntu-latest' }}
runs-on: "ubuntu-latest"
# max (6h) so the round-trip over the primer project set isn't cut short
timeout-minutes: 360
outputs:
merge-base: ${{ steps.build.outputs.merge-base }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Install Rust toolchain
run: rustup show
- name: Install mold
uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
- name: Build by for both commits
id: build
run: |
# Faster to do this separately than to use `fetch-depth: 0` with `actions/checkout`
git fetch --no-tags --filter=blob:none --unshallow origin
MERGE_BASE="$(git merge-base "${GITHUB_SHA}" "origin/${GITHUB_BASE_REF}")"
echo "merge-base=${MERGE_BASE}" >> "$GITHUB_OUTPUT"
echo "Merge base: ${MERGE_BASE}"
echo "PR commit: ${GITHUB_SHA}"
git checkout "${MERGE_BASE}"
cargo build --bin by --profile profiling
cp target/profiling/by by-base
git checkout "${GITHUB_SHA}"
cargo build --bin by --profile profiling
cp target/profiling/by by-pr
- name: Upload by binaries
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: by-builds
compression-level: 1
path: |
by-base
by-pr
roundtrip-shards:
name: Round-trip shard ${{ matrix.shard }}
needs: build
strategy:
fail-fast: false
matrix:
shard: [0, 1, 2, 3, 4, 5, 6, 7]
# re-enable when we have depot support
# runs-on: ${{ github.repository == 'KotlinIsland/basedpython' && 'depot-ubuntu-22.04-32' || 'ubuntu-latest' }}
runs-on: "ubuntu-latest"
# max (6h): the per-file round-trip over the corpus is slow on the fork's
# ubuntu-latest runners, so give each shard the whole budget
timeout-minutes: 360
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
version: "0.11.7"
- name: Download by binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: by-builds
# a large swapfile turns a memory spike between watchdog polls into disk
# thrashing (throttled to disk speed) instead of an instant kernel
# OOM-kill of the whole runner — the watchdog then has time to react and
# record the build as a (canonical) error
- name: Add swap space
run: |
sudo fallocate -l 16G /mnt/swapfile
sudo chmod 600 /mnt/swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
- name: Round-trip shard ${{ matrix.shard }}
env:
SHARD: ${{ matrix.shard }}
# opt-in cap for quick runs; empty (the default) means the whole corpus
PRIMER_LIMIT: ${{ vars.BY_ROUNDTRIP_PRIMER_LIMIT }}
run: |
chmod +x by-base by-pr
limit_arg=()
if [[ -n "$PRIMER_LIMIT" ]]; then
limit_arg=(--limit "$PRIMER_LIMIT")
fi
# the harness round-trips each project with two `by` processes
# (`transpile --reverse <dir>` then `by build`), not per file. each
# `by build` holds a whole project's db in memory, so build one
# project at a time — two concurrent builds OOM the runner on the big
# projects
uv run scripts/check_ecosystem_roundtrip.py \
by-pr \
--baseline by-base \
--shard "$SHARD" \
--num-shards 8 \
"${limit_arg[@]}" \
--project-concurrency 1 \
--json-out "roundtrip-${SHARD}.json"
- name: Upload shard results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: roundtrip-shard-${{ matrix.shard }}
path: roundtrip-${{ matrix.shard }}.json
report:
name: Generate round-trip report
needs: [build, roundtrip-shards]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
version: "0.11.7"
- name: Download shard results
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: roundtrip-shard-*
merge-multiple: true
# the round-trip findings (regressions/changed/error-changed) are reported
# in the PR comment for humans to review — they don't fail the job. the job
# fails only if the harness itself fails (a non-zero exit here is a crash,
# not a finding)
- name: Render report
env:
MERGE_BASE: ${{ needs.build.outputs.merge-base }}
REF_NAME: ${{ github.ref_name }}
run: |
uv run scripts/check_ecosystem_roundtrip.py \
--render roundtrip-*.json \
--old-label "${MERGE_BASE} (merge base)" \
--new-label "${REF_NAME}" \
> comment.md
cat comment.md >> "$GITHUB_STEP_SUMMARY"
- name: Record PR number for the comment workflow
run: echo "${{ github.event.pull_request.number }}" > pr-number.txt
# NOTE: the by-ecosystem-roundtrip_comment workflow consumes this artifact
# to post the PR comment. Update that workflow if you rename it.
- name: Upload comment
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: comment.md
path: |
comment.md
pr-number.txt