Repository navigation
219 lines (188 loc) · 7.09 KB
/
Copy pathdowntime-runner.yaml
File metadata and controls
219 lines (188 loc) · 7.09 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
name: Downtime-Runner
on:
schedule:
# Run nightly at 2:17
# https://stackoverflow.com/questions/59560214/github-action-works-on-push-but-not-scheduled
- cron: 17 2 * * *
permissions:
actions: read
contents: read
env:
PRECOMMIT_REPOSITORY: ${{ github.repository }}
PATCHWORK_CHECK_USERNAME: ${{ vars.PATCHWORK_CHECK_USERNAME }}
PATCHWORK_FILTER_EMAILS: ${{ vars.PATCHWORK_FILTER_EMAILS }}
PATCHWORK_REPORTING_ENABLED: ${{ vars.PATCHWORK_REPORTING_ENABLED }}
jobs:
check_last_runner:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install Python dependencies
run: |
pip install -r ../requirements.txt --break-system-packages
- name: Install dependencies
run: |
sudo apt install zip -y
- name: Download last successful run artifact
run: |
mkdir result
mkdir temp
python ./scripts/download_artifact.py -name "downtime_runner_success" -repo "${PRECOMMIT_REPOSITORY}" -token ${{ secrets.GITHUB_TOKEN }} -outdir result || true
ls result
- name: Check if artifact was found
id: continue
run: |
if ( test -f result/end_date.txt ); then
START_DATE=$(cat result/end_date.txt)
echo "start_date=$START_DATE" >> $GITHUB_OUTPUT
fi
- name: Build success artifact
if: ${{ steps.continue.outputs.start_date == '' }}
run: |
TZ=UTC date -d "$(date -d 'yesterday' '+%Y-%m-%d')" "+%Y-%m-%dT%H:%M:%S" > yesterday_date.txt
YESTERDAY=$(cat yesterday_date.txt)
# Get yestderay noon
TZ=UTC date -d "@$((($(TZ=UTC date -d $YESTERDAY +%s) + 43200)))" '+%Y-%m-%dT%H:%M:%S' > end_date.txt
- name: Upload success artifact
if: ${{ steps.continue.outputs.start_date == '' }}
uses: actions/upload-artifact@v4
with:
name: downtime_runner_success
path: |
riscv-gnu-toolchain/end_date.txt
retention-days: 90
outputs:
start_date: ${{ steps.continue.outputs.start_date }}
fetch_patches:
# This is a dedicated self hosted runner that will always* run this on time
needs: [check_last_runner]
runs-on: ubuntu-24.04
concurrency:
group: precommit-patchwork-fetch-${{ github.repository }}
cancel-in-progress: false
if: ${{ needs.check_last_runner.outputs.start_date != '' }}
defaults:
run:
working-directory: riscv-gnu-toolchain
steps:
- uses: actions/checkout@v4
- name: Setup env
uses: ./.github/actions/common/setup-env
with:
free_up_space: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install Python dependencies
run: |
pip install -r ../requirements.txt --break-system-packages
- name: Install dependencies
run: |
sudo apt install zip -y
- name: Get Timestamps
id: timestamps
run: |
TZ=UTC date -d "$(date -d 'yesterday' '+%Y-%m-%d')" "+%Y-%m-%dT%H:%M:%S" > yesterday_date.txt
YESTERDAY=$(cat yesterday_date.txt)
# Get yesterday noon
TZ=UTC date -d "@$((($(TZ=UTC date -d $YESTERDAY +%s) + 43200)))" '+%Y-%m-%dT%H:%M:%S' > end_date.txt
echo ${{ needs.check_last_runner.outputs.start_date }} > start_date.txt
echo "timestamps"
echo "start time: $(cat start_date.txt)"
echo "end time: $(cat end_date.txt)"
echo "end_date=$(cat end_date.txt)" >> "$GITHUB_OUTPUT"
- name: Perform patch checks
run: |
python scripts/check_patch_checks.py -start $(cat start_date.txt) -end $(cat end_date.txt)
- name: Get list of new patches
run: |
mkdir -p patch_urls
mkdir -p patchworks_metadata
if [ -f ./patch_numbers_to_run.txt ]; then
python scripts/create_patches_files.py -file ./patch_numbers_to_run.txt
fi
- name: List patch artifacts
id: list_patches
run: |
if [ -f ./artifact_names.txt ]; then
export PATCHLIST="$(cat artifact_names.txt)"
else
export PATCHLIST='[]'
fi
echo "patch_list=$PATCHLIST" >> $GITHUB_OUTPUT
- name: Upload patch urls
if: ${{ steps.list_patches.outputs.patch_list != '[]' }}
uses: actions/upload-artifact@v4
with:
name: patch_urls
path: |
riscv-gnu-toolchain/patch_urls
retention-days: 90
- name: Upload patchworks metadata
if: ${{ steps.list_patches.outputs.patch_list != '[]' }}
uses: actions/upload-artifact@v4
with:
name: patchworks_metadata_files
path: |
riscv-gnu-toolchain/patchworks_metadata
retention-days: 90
outputs:
list_of_patch_names: ${{ steps.list_patches.outputs.patch_list }}
end_date: ${{ steps.timestamps.outputs.end_date }}
init-submodules:
needs: [check_last_runner, fetch_patches]
if: ${{ needs.fetch_patches.outputs.list_of_patch_names != '[]' }}
uses: ./.github/workflows/init-submodules.yaml
secrets: inherit
checkpoint:
needs: [check_last_runner, fetch_patches, init-submodules, patch_matrix]
# Empty queues intentionally skip the downstream jobs. Failed or cancelled
# processing must retain the old checkpoint so the next scan can retry it.
if: ${{ !cancelled() && needs.check_last_runner.result == 'success' && needs.fetch_patches.result == 'success' && (needs.fetch_patches.outputs.list_of_patch_names == '[]' || (needs.init-submodules.result == 'success' && needs.patch_matrix.result == 'success')) }}
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Record completed recovery window
env:
RECOVERY_END_DATE: ${{ needs.fetch_patches.outputs.end_date }}
run: |
test -n "$RECOVERY_END_DATE"
printf '%s\n' "$RECOVERY_END_DATE" > end_date.txt
- name: Upload success artifact
uses: actions/upload-artifact@v4
with:
name: downtime_runner_success
path: end_date.txt
if-no-files-found: error
retention-days: 90
patch_matrix:
needs: [check_last_runner, fetch_patches, init-submodules]
strategy:
fail-fast: false
matrix:
patch_name: ${{ fromJSON(needs.fetch_patches.outputs.list_of_patch_names) }}
uses: ./.github/workflows/run-checks.yaml
permissions:
actions: read
contents: read
issues: write
with:
patch_name: ${{ matrix.patch_name }}
baseline_hash: ${{ needs.init-submodules.outputs.baseline_hash }}
tot_hash: ${{ needs.init-submodules.outputs.tot_hash }}
secrets: inherit