Repository navigation
276 lines (266 loc) · 13.5 KB
/
Copy pathnightly.yml
File metadata and controls
276 lines (266 loc) · 13.5 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: Nightly
# The slow checks pull requests don't wait for: every platform's tests and the release build of
# the apps, once a night on main. A night with no new commits since the last successful run is
# skipped for the build. Generated overlays run every night with a fresh seed: each new minimized
# disagreement opens its own issue, and an overlay run that fails without one is reported like a
# build failure. A build failure opens an issue (or comments on the open one); the next success
# closes it.
#
# gh workflow run nightly.yml -R opengeos/RustGIS --ref main
on:
schedule:
- cron: "41 5 * * *"
workflow_dispatch:
concurrency:
group: nightly
cancel-in-progress: false
permissions:
contents: read
jobs:
changed:
name: New commits
# Forks don't run the schedule.
if: github.repository == 'opengeos/RustGIS' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
actions: read
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- id: check
env:
GH_TOKEN: ${{ github.token }}
EVENT: ${{ github.event_name }}
run: |
set -euo pipefail
last=""
# An API error runs the build rather than failing here, which would skip the report.
if [ "$EVENT" = schedule ]; then
last="$(gh run list -R "$GITHUB_REPOSITORY" --workflow nightly.yml --event schedule --status success \
--limit 1 --json headSha --jq '.[0].headSha // ""' || true)"
fi
if [ "$last" = "$GITHUB_SHA" ]; then
echo "No commits since the last successful nightly run ($last)."
echo "run=false" >> "$GITHUB_OUTPUT"
else
echo "run=true" >> "$GITHUB_OUTPUT"
fi
rust:
needs: changed
if: needs.changed.outputs.run == 'true'
uses: ./.github/workflows/test-rust.yml
with:
os: '["ubuntu-latest", "macos-latest", "windows-latest", "windows-11-arm"]'
release-build: true
# Everyday jobs on real data: the Census Bureau's tracts for Shelby County, Tennessee, checked
# against the areas it publishes (crates/engine/tests/integration/workflows.rs). The files are public domain
# and pinned by checksum; a changed file fails the run, a download that fails skips the tests
# (`tested` tells the report, which then neither opens nor closes an issue).
workflows:
name: Workflows on real data
needs: changed
if: needs.changed.outputs.run == 'true'
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
tested: ${{ steps.data.outputs.ok }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
save-if: false
# Restored and saved as separate steps: the combined action would save a set missing a file
# whose download failed, and an exact hit is never saved again.
- id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: workflow-data
key: workflow-data-census-2024-1
- id: data
name: Download the Census files
run: |
set -uo pipefail
mkdir -p workflow-data
cd workflow-data
ok=true
while read -r sum url; do
file="${url##*/}"
if ! echo "$sum $file" | sha256sum -c --status 2>/dev/null; then
curl -sSfL --retry 3 --retry-max-time 600 --connect-timeout 30 --max-time 300 -o "$file" "$url" || { echo "::warning::could not download $url"; ok=false; continue; }
echo "$sum $file" | sha256sum -c || { echo "::error::$file has changed: update its checksum and check the test"; exit 1; }
fi
done <<'LIST'
e635ccb4f3035f8fa19b76352a63c89b893f57d0b96ecd5b713754141184bd3d https://www2.census.gov/geo/tiger/TIGER2024/TRACT/tl_2024_47_tract.zip
38cdd818f50248f67fabf4baf4b82df4ed6110dcaafebcbe4d4f9a389bb47ab8 https://www2.census.gov/geo/docs/maps-data/data/gazetteer/2024_Gazetteer/2024_gaz_tracts_47.txt
LIST
echo "ok=$ok" >> "$GITHUB_OUTPUT"
- name: Keep the Census files
if: steps.data.outputs.ok == 'true' && steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: workflow-data
key: workflow-data-census-2024-1
- name: Run the workflow tests on them
if: steps.data.outputs.ok == 'true'
env:
RUSTGIS_WORKFLOW_DATA: ${{ github.workspace }}/workflow-data
run: |
cargo test --locked -p rustgis-engine --test integration workflows:: -- --ignored
# The property tests (docs/contributing.md › Property tests), on a new seed each night this
# job runs (one with new commits) and more cases than a pull request runs; a failure gives
# the seed to run again.
- name: Run the property tests on a new seed
if: ${{ !cancelled() }}
env:
PROPERTY_SEED: ${{ github.run_id }}
PROPERTY_CASES: "2000"
run: |
cargo test --locked -p rustgis-engine --test integration never_silent_roundtrip::
PROPERTY_CASES=200 cargo test --locked -p rustgis-analysis --test parallel_serial
cargo test --locked -p rustgis-engine --test integration project_save_roundtrip::
PROPERTY_CASES=200000 cargo test --locked -p rustgis-data --test integration reprojection_round_trip::
PROPERTY_CASES=100000 cargo test --locked -p rustgis-geom --test geodesic_identities
cargo test --locked -p rustgis-data --test integration extent_query_properties::
PROPERTY_CASES=20000 cargo test --locked -p rustgis-data --test integration date_properties::
# Use a fresh seed even when the commit is the same as last night.
overlay:
name: Generated polygon overlays
if: github.repository == 'opengeos/RustGIS' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
findings: ${{ steps.findings.outputs.artifact-id }}
env:
CARGO_PROFILE_DEV_DEBUG: line-tables-only
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Compare overlays and minimize disagreements
id: compare
env:
PROPERTY_CASES: "256"
run: |
set -euo pipefail
cargo test --locked -p rustgis-analysis --test reference --no-run --message-format=json > "$RUNNER_TEMP/reference-build.jsonl"
runner="$(jq -er 'select(.reason == "compiler-artifact" and .target.name == "reference" and .executable != null) | .executable' "$RUNNER_TEMP/reference-build.jsonl")"
PROPERTY_SEED="$(python3 -c 'import secrets; print(secrets.randbits(64))')"
export PROPERTY_SEED
time uv run crates/analysis/tests/reference/generate.py --overlay "$runner" --findings "$RUNNER_TEMP/overlay-findings"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
id: findings
if: failure() && steps.compare.outcome == 'failure'
with:
name: overlay-findings
path: ${{ runner.temp }}/overlay-findings
if-no-files-found: ignore
overlay-report:
name: Report generated overlays
needs: overlay
# Only the reporting job has issue write access. Manual runs keep findings as artifacts.
# A job that ran out of time ends cancelled, but the run isn't: that is a failure too.
if: ${{ !cancelled() && github.event_name == 'schedule' && needs.overlay.result != 'skipped' }}
runs-on: ubuntu-latest
permissions:
actions: read
issues: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
if: needs.overlay.outputs.findings != ''
with:
name: overlay-findings
path: findings
- name: Open issues for new minimized disagreements
if: needs.overlay.outputs.findings != ''
env:
GH_TOKEN: ${{ github.token }}
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
# Trust only markers in this workflow's own issues, as "<state> <marker>" lines.
gh api --paginate "repos/$GITHUB_REPOSITORY/issues?state=all&per_page=100" \
| jq -r '.[] | select(.pull_request | not) | select(.user.login == "github-actions[bot]")
| .state as $s | (.body // "") | split("\n")[] | select(startswith("<!-- overlay-finding:")) | "\($s) \(.)"' > reported
for file in findings/*.json; do
tool="$(jq -er '.case.tools[0]' "$file")"
kind="$(jq -er '.kind' "$file")"
fingerprint="$(jq -er '.fingerprint' "$file")"
marker="<!-- overlay-finding:$fingerprint -->"
# A reduced input is reported once. The grouped Clip seam class is reported again
# once its issue is closed, so a fix that doesn't hold shows up.
if grep -Fxq -- "open $marker" reported; then continue; fi
if [ "$fingerprint" != clip-mask-seam ] && grep -Fxq -- "closed $marker" reported; then continue; fi
{
echo "The [nightly run]($RUN) on $GITHUB_SHA found a generated $tool disagreement."
echo
jq -r '"Seed `PROPERTY_SEED=\(.seed)`, case index `\(.index)`. \(.detail)"' "$file"
echo
echo 'Save the minimized case below as JSON and pass it to the overlay replay command in crates/analysis/tests/reference/README.md.'
echo
echo '```json'
cat "$file"
echo '```'
echo "$marker"
} > issue.md
gh issue create -R "$GITHUB_REPOSITORY" --title "Generated overlay disagrees with GEOS ($tool, $kind)" --body-file issue.md
echo "open $marker" >> reported
done
- name: Report a check that failed without findings
env:
GH_TOKEN: ${{ github.token }}
RESULT: ${{ needs.overlay.result }}
FINDINGS: ${{ needs.overlay.outputs.findings }}
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
title="Nightly generated overlay check failed"
open="$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues?state=open&per_page=100" \
| jq -sr --arg t "$title" '[.[][] | select(.pull_request | not) | select(.user.login == "github-actions[bot]") | select(.title == $t)][0].number // ""')"
if [ "$RESULT" = success ]; then
if [ -n "$open" ]; then
gh issue close "$open" -R "$GITHUB_REPOSITORY" --comment "Fixed: the nightly overlay check on $GITHUB_SHA passed ($RUN)."
fi
elif [ -z "$FINDINGS" ]; then
if [ -n "$open" ]; then
gh issue comment "$open" -R "$GITHUB_REPOSITORY" --body "Still failing on $GITHUB_SHA: $RUN"
else
gh issue create -R "$GITHUB_REPOSITORY" --title "$title" \
--body "The generated overlay check on $GITHUB_SHA failed without a minimized finding, so the comparison itself broke: $RUN. This issue closes itself when the check passes."
fi
fi
report:
name: Report
needs: [changed, rust, workflows]
# A cancelled run is neither a failure nor a fix. A job that ran out of time ends cancelled too,
# but the run isn't: that is a failure.
if: ${{ !cancelled() && github.event_name == 'schedule' && needs.changed.outputs.run == 'true' }}
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- env:
GH_TOKEN: ${{ github.token }}
# "incomplete": everything ran passed, but the real-data tests couldn't download their files.
RESULT: ${{ (needs.rust.result != 'success' || needs.workflows.result != 'success') && 'failure' || (needs.workflows.outputs.tested == 'true' && 'success' || 'incomplete') }}
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
title="Nightly build failed"
open="$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues?state=open&per_page=100" \
| jq -sr --arg t "$title" '[.[][] | select(.pull_request | not) | select(.title == $t)][0].number // ""')"
if [ "$RESULT" = incomplete ]; then
echo "The real-data tests didn't run (download failed): leaving the nightly issue as it is."
elif [ "$RESULT" = success ]; then
if [ -n "$open" ]; then
gh issue close "$open" -R "$GITHUB_REPOSITORY" --comment "Fixed: the nightly run on $GITHUB_SHA passed ($RUN)."
fi
elif [ -n "$open" ]; then
gh issue comment "$open" -R "$GITHUB_REPOSITORY" --body "Still failing on $GITHUB_SHA: $RUN"
else
gh issue create -R "$GITHUB_REPOSITORY" --title "$title" \
--body "The nightly run on $GITHUB_SHA failed ($RESULT): $RUN. This issue closes itself when a nightly run passes."
fi