-
Notifications
You must be signed in to change notification settings - Fork 72
305 lines (269 loc) · 7.97 KB
/
build.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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: build
run-name: Build Melee & publish GitHub Pages
on: [push, pull_request]
env:
IMAGE_REPO: doldecomp/melee
permissions:
contents: read
id-token: write
packages: read
pages: write
jobs:
build-make:
name: Make
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
OUTPUT: ${{ github.workspace }}/output
strategy:
matrix:
make_flags: ["GENERATE_MAP=1"]
fail-fast: false
steps:
- name: Get image name
env:
IMAGE_SUFFIX: build-linux:latest
run: |
echo "IMAGE=$IMAGE_REPO/$IMAGE_SUFFIX" >> $GITHUB_ENV
- name: Checkout Melee repository
uses: actions/checkout@v3
- name: Log into container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull build image
run: docker pull "$REGISTRY/$IMAGE"
- name: Build Melee
env:
MAKE_FLAGS: ${{ matrix.make_flags }}
run: |
mkdir -p "$OUTPUT"
docker run --rm \
--user "$(id -u):$(id -g)" \
--volume "$PWD":/input:ro \
--volume "$OUTPUT:/output" \
--env MAKE_FLAGS="$MAKE_FLAGS" \
"$REGISTRY/$IMAGE"
- name: Upload map
if: matrix.make_flags == 'GENERATE_MAP=1'
uses: actions/upload-artifact@v4
with:
name: GALE01.map
path: ${{ env.OUTPUT }}/ssbm.us.1.2/GALE01.map
if-no-files-found: error
- name: Set step summary
if: matrix.make_flags == 'GENERATE_MAP=1'
run: |
printf "\`\`\`\n%s\n\`\`\`" "$(cat "$OUTPUT/PROGRESS.md")" \
>> $GITHUB_STEP_SUMMARY
build-ninja:
name: Ninja
runs-on: ubuntu-latest
if: github.repository == 'doldecomp/melee'
container: ghcr.io/doldecomp/build-melee:main
strategy:
fail-fast: false
matrix:
version: [GALE01]
mode: ["link", "diff"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
sparse-checkout: |
src
extern
tools
config
- name: Git config
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global advice.detachedHead false
- name: Prepare
run: ln -s /orig .
- name: Build
run: |
set -eou pipefail
export RUST_LOG=error
mode='${{matrix.mode}}'
config_args='--compilers /compilers --max-errors 0 --verbose --version ${{matrix.version}}'
function run_configure {
echo "$config_args" | xargs python configure.py
}
case "$mode" in
'link')
config_args="--map --require-protos $config_args"
run_configure
ninja || ninja diff
;;
'diff')
root='build/${{matrix.version}}'
expected="$root/expected-report.json"
current="$root/report.json"
changes="$root/changes-report.json"
head="$(git rev-parse HEAD)"
function run_ninja {
ninja all_source "$current"
}
case '${{github.event_name}}' in
'pull_request')
git fetch origin HEAD
git checkout FETCH_HEAD
;;
'push')
git checkout 'HEAD^'
;;
*) exit 1 ;;
esac
run_configure
run_ninja
cp "$current" "$expected"
git checkout "$head"
run_ninja
build/tools/objdiff-cli report changes -o "$changes" "$expected" "$current"
python tools/diff_changes.py "$changes"
status="$?"
exit "$status"
;;
*) exit 1 ;;
esac
- name: Upload progress
if: matrix.mode == 'link' && github.ref_name == github.event.repository.default_branch
continue-on-error: true
env:
PROGRESS_API_KEY: ${{secrets.PROGRESS_API_KEY}}
run: |
python tools/upload_progress.py \
-b 'https://progress.decomp.club/' \
-p melee \
-v ${{matrix.version}} \
'build/${{matrix.version}}/progress.json'
- name: Upload map
if: matrix.mode == 'link'
uses: actions/upload-artifact@v4
with:
name: ${{matrix.version}}_maps
path: build/${{matrix.version}}/**/*.MAP
- name: Upload report
if: matrix.mode == 'diff'
uses: actions/upload-artifact@v4
with:
name: ${{matrix.version}}_report
path: build/${{matrix.version}}/report.json
check-issues:
name: Issues
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- name: Get image name
env:
IMAGE_SUFFIX: check-issues:latest
run: |
echo "IMAGE=$IMAGE_REPO/$IMAGE_SUFFIX" >> $GITHUB_ENV
- name: Checkout Melee repository
uses: actions/checkout@v3
- name: Log into container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull build image
run: docker pull "$REGISTRY/$IMAGE"
- name: Check for code issues
run: |
docker run --rm \
--user "$(id -u):$(id -g)" \
--volume "$PWD:/input:ro" \
"$REGISTRY/$IMAGE"
gen-pages:
name: Generate pages
runs-on: ubuntu-latest
needs: build-ninja
env:
REGISTRY: ghcr.io
OUTPUT: ${{github.workspace}}/output
steps:
- name: Get image name
env:
IMAGE_SUFFIX: gen-pages:latest
run: |
echo "IMAGE=$IMAGE_REPO/$IMAGE_SUFFIX" >> $GITHUB_ENV
- name: Checkout Melee repository
uses: actions/checkout@v3
- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull generator image
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE }}
- name: Generate pages
run: |
mkdir -p "${{ env.OUTPUT }}"
docker run --rm \
--user "$(id -u):$(id -g)" \
--volume "$PWD:/input:ro" \
--volume "${{ env.OUTPUT }}:/output" \
${{ env.REGISTRY }}/${{ env.IMAGE }}
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.OUTPUT }}
deploy-pages:
concurrency:
group: deploy
cancel-in-progress: false
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
needs: gen-pages
if: github.ref_name == github.event.repository.default_branch
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Set up GitHub Pages
uses: actions/configure-pages@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
build-nix:
name: Nix
runs-on: ubuntu-latest
if: github.repository == 'doldecomp/melee'
env:
REGISTRY: ghcr.io
IMAGE: doldecomp/build-melee:main
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
sparse-checkout: |
src
extern
tools
config
.nix
- name: Log into container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Grab Melee DOL
run: |
image="$REGISTRY/$IMAGE"
docker pull "$image"
container_id=$(docker create "$image")
docker cp "$container_id":/orig .
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: DeterminateSystems/magic-nix-cache-action@v2
- run: nix-build
- run: nix-shell --run "echo OK"