Repository navigation
132 lines (117 loc) · 3.85 KB
/
Copy pathtests.yaml
File metadata and controls
132 lines (117 loc) · 3.85 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
name: Tests
on:
workflow_dispatch: # Enables the web UI manual trigger
pull_request:
branches: [main]
paths:
- ".github/workflows/**"
- ".github/actions/**"
- "bin/**"
- "scripts/**"
- "pyproject.toml"
- "uv.lock"
- "data/generated/**"
- "data/manual/**"
- "src/**"
- "tests/**"
push:
branches: [main]
paths:
- ".github/workflows/**"
- ".github/actions/**"
- "bin/**"
- "scripts/**"
- "pyproject.toml"
- "uv.lock"
- "data/generated/**"
- "data/manual/**"
- "src/**"
- "tests/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# actions: read is needed to pull the iptoasn artifact across workflows.
permissions:
contents: read
actions: read
jobs:
Tests:
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v7.0.1
- name: Cache uv downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: uv-${{ runner.os }}-
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- name: Install mise and the pinned toolchain
uses: jdx/mise-action@7a4e45a543138629540c9a1616d08632b893e492 # v5.0.1
- name: Install dependencies
run: bin/setup
# iptoasn is required build data; reuse the artifact update-iptoasn
# publishes daily (45-day retention).
- name: Find latest iptoasn artifact run
id: iptoasn-run
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(gh run list --workflow=update-iptoasn.yaml --status=success \
--limit=1 --json databaseId -q '.[0].databaseId')
if [ -z "$run_id" ]; then
echo "::error::No successful update-iptoasn run found; cannot fetch required iptoasn data"
exit 1
fi
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
- name: Download iptoasn artifact
uses: actions/download-artifact@v8
with:
pattern: iptoasn-*
path: data/source/iptoasn
github-token: ${{ github.token }}
run-id: ${{ steps.iptoasn-run.outputs.run_id }}
merge-multiple: true
- name: Run tests
run: |
set -o pipefail
# Intentional pipe to tee; SC2266 misreads it as a mistaken ||.
# shellcheck disable=SC2266
bin/test 2>&1 | tee test-output.log
- name: Capture build logs
if: always()
run: |
{
echo "=== UV Version ==="
uv --version
printf '\n=== Python Version ===\n'
python --version
printf '\n=== System Info ===\n'
uname -a
printf '\n=== Dependency Tree ===\n'
uv tree 2>&1 || echo "Failed to generate dependency tree"
printf '\n=== Lock File Info ===\n'
ls -la uv.lock 2>&1 || echo "No uv.lock found"
} > build-info.log
- name: Upload failure artifacts
uses: actions/upload-artifact@v7
if: always()
with:
name: test-failure-logs-${{ github.run_id }}
path: |
test-output.log
build-info.log
.venv/pyvenv.cfg
retention-days: 7
- name: Notification if failure
if: ${{ failure() }}
run: |
curl -Ss -X POST -H 'Content-type: application/json' \
--data '{
"token": "${{ secrets.PUSHOVER_API_TOKEN }}",
"user": "${{ secrets.PUSHOVER_USER_KEY }}",
"title": "Test run failed",
"message": "❌ Tests failed for iana-data"
}' \
https://api.pushover.net/1/messages.json