-
Notifications
You must be signed in to change notification settings - Fork 15
184 lines (167 loc) · 5.62 KB
/
ci_compatible.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: CI compatibility
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# At the end of every day
- cron: "0 0 * * *"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
defaults:
run:
shell: bash
jobs:
generator:
runs-on: ubuntu-latest
timeout-minutes: 5
# Map a step output to a job output
outputs:
matrix: ${{ steps.diff-files.outputs.runtimes }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Get PR diff
id: diff-files
env:
PR_NUMBER: "${{ github.event.pull_request.number }}"
run: |
pip install -q -r requirements.txt
pr_runtimes=$(python _actions/assistant.py list_runtimes $PR_NUMBER)
echo $pr_runtimes
echo "runtimes={include: $pr_runtimes}" >> $GITHUB_OUTPUT
- run: echo "[]" > projects.json
- name: Upload placeholder
uses: actions/upload-artifact@v3
with:
name: compatibility-${{ github.sha }}
path: projects.json
pytester:
needs: generator
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 25
fail-fast: false
matrix: ${{ fromJSON(needs.generator.outputs.matrix) }}
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
- name: Testing the project
uses: ./.github/actions/pytester
with:
python: ${{ matrix.python }}
config: ${{ matrix.config }}
- name: Dumping the job's detail
if: always()
uses: ./.github/actions/job-dump
with:
artifact-name: project-${{ github.sha }}-${{ strategy.job-index }}
collector:
runs-on: ubuntu-latest
needs: [generator, pytester]
if: always()
strategy:
max-parallel: 1 # run sequential to prevent download/upload collisions
matrix: ${{ fromJSON(needs.generator.outputs.matrix) }}
steps:
- name: Download 📥 summary
uses: actions/download-artifact@v3
with:
name: compatibility-${{ github.sha }}
- name: Download 📥 project
uses: actions/download-artifact@v3
with:
name: project-${{ github.sha }}-${{ strategy.job-index }}
- run: ls -l
- name: append result
run: |
import json
with open("projects.json") as fp:
data = json.load(fp)
with open("meta.json") as fp:
data.append(json.load(fp))
with open("projects.json", "w") as fp:
json.dump(data, fp)
shell: python
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
name: compatibility-${{ github.sha }}
path: projects.json
watcher:
runs-on: ubuntu-latest
needs: pytester
if: always()
steps:
- run: echo "${{ needs.pytester.result }}"
- name: failing...
if: needs.pytester.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result)
timeout-minutes: 1
run: sleep 90
messenger:
runs-on: ubuntu-latest
needs: collector
# always and success is need for running if eventually pytester failed
if: always() && needs.collector.result == 'success'
steps:
- uses: actions/checkout@v4
- name: Download 📥 summary
uses: actions/download-artifact@v3
with:
name: compatibility-${{ github.sha }}
- run: cat projects.json
- name: Prepare Slack payload
run: |
pip install -q -r requirements.txt
payload=$(python _actions/assistant.py slack_payload projects.json)
echo "$payload" > payload-slack-content.json
cat payload-slack-content.json
- name: Post to a Slack channel
if: contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name)
uses: slackapi/[email protected]
with:
# channel-id: C02NJMSLFJR # alerts-ecosystem-ci
# For posting a rich message using Block Kit - https://app.slack.com/block-kit-builder
payload-file-path: "./payload-slack-content.json"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
archiver:
runs-on: ubuntu-latest
needs: collector
# always and success is need for running if eventually pytester failed
if: always() && needs.collector.result == 'success'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
ref: "archive"
fetch-depth: 0 # fetch all history for all branches and tags
- name: Sync with main
run: |
git config user.name github-actions
git config user.email [email protected]
git merge origin/main
- name: Download 📥 summary
uses: actions/download-artifact@v3
with:
name: compatibility-${{ github.sha }}
- name: Update results
run: |
cat projects.json
git add projects.json
git status
git commit -m "compatibility update $(date +"%Y-%m-%d")"
- name: Kick
if: contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name)
run: git push