-
Notifications
You must be signed in to change notification settings - Fork 0
246 lines (212 loc) · 7.14 KB
/
ci.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
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
name: CI
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Generate a bot token with BOT_APP_ID
id: bot_token
if: vars.BOT_APP_ID && env.BOT_PRIVATE_KEY != null
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1
env:
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
with:
app-id: ${{ vars.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
- name: Set up python
uses: actions/setup-python@v5
- name: Run pre-commit on codebase
uses: pre-commit/[email protected]
- name: Auto commit action
uses: stefanzweifel/git-auto-commit-action@v5
if: failure()
with:
commit_message: 'ci: auto fixes from pre-commit'
format_and_update_ports:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Generate a bot token with BOT_APP_ID
id: bot_token
if: vars.BOT_APP_ID && env.BOT_PRIVATE_KEY != null
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1
env:
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
with:
app-id: ${{ vars.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
fetch-depth: 2
- name: Setup vcpkg
uses: ./.github/actions/setup-vcpkg
- name: Format vcpkg.json
run: |
vcpkg format-manifest --all $(find . -name "vcpkg.json")
- name: Commit format vcpkg.json
uses: stefanzweifel/git-auto-commit-action@v5
if: success()
with:
commit_message: 'ci: format vcpkg configuration'
file_pattern: vcpkg.json
- name: Exit 1 if vcpkg configuration changes have been detected
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: |
exit 1
- name: Verify all modules and update hash
run: |
for dir in ports/* ; do
echo "Test to install $dir"
vcpkg remove ${dir##ports/} --recurse || true
status=0
install_output=$(vcpkg install ${dir##ports/} --overlay-ports=ports) || status=$?
if [[ ! $status -eq 0 ]]; then
echo " Update hash on $dir/portfile.cmake"
expected=$(echo "$install_output" | grep -oP "(?<=Expected hash: ).{128}")
actual=$(echo "$install_output" | grep -oP "(?<=Actual hash: ).{128}")
sed -i "s@${expected}@${actual}@g" "$dir/portfile.cmake"
echo " Expected hash: ${expected}"
echo " Actual hash: ${actual}"
fi
done
- name: Detect hash changes against local
id: filter-hash
uses: dorny/paths-filter@v3
with:
list-files: shell
base: HEAD
filters: |
ports:
- ports/**
- name: Get ports last commit message
if: steps.filter-hash.outputs.ports == 'true'
id: ports-last-commit-message
run: |
echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
- name: Commit port hash
if: steps.filter-hash.outputs.ports == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: ports/*
commit_message: ${{ steps.ports-last-commit-message.outputs.msg }}
push_options: --force
commit_options: --amend --no-edit
skip_fetch: true
- name: Detect ports changes against default branch
id: filter-ports
uses: dorny/paths-filter@v3
with:
list-files: shell
filters: |
ports:
- ports/**
- name: Update versions
if: steps.filter-ports.outputs.ports == 'true'
run: |
for dir in ports/* ; do
vcpkg x-add-version ${dir##ports/} --overlay-ports=./ports \
--x-builtin-registry-versions-dir=./versions/ \
--x-builtin-ports-root=./ports \
--overwrite-version
done
- name: Detect versions changes against local
if: steps.filter-ports.outputs.ports == 'true'
id: filter-versions
uses: dorny/paths-filter@v3
with:
list-files: shell
base: HEAD
filters: |
versions:
- versions/**
- name: Get last commit message
if: steps.filter-versions.outputs.versions == 'true'
id: last-commit-message
run: |
echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
- name: Commit versions
if: steps.filter-versions.outputs.versions == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: versions/*
commit_message: ${{ steps.last-commit-message.outputs.msg }}
push_options: --force
commit_options: --amend --no-edit
skip_fetch: true
verify_os:
runs-on: ${{ matrix.os }}
needs: [pre-commit, format_and_update_ports]
permissions:
contents: read
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
- name: Install vcpkg
uses: ./.github/actions/setup-vcpkg
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
uses: jannekem/run-python-script-action@v1
with:
script: |
import os
import subprocess
for port in os.listdir("ports"):
subprocess.check_call(
[
"vcpkg",
"remove",
port,
"--recurse",
]
)
subprocess.check_call(
[
"vcpkg",
"install",
port,
"--overlay-ports=ports",
]
)
pass:
if: always()
needs: [verify_os]
runs-on: ubuntu-24.04
timeout-minutes: 2
permissions:
pull-requests: write
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}