-
Notifications
You must be signed in to change notification settings - Fork 2
335 lines (291 loc) · 12.4 KB
/
Copy pathdump_slicer_configs.yml
File metadata and controls
335 lines (291 loc) · 12.4 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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
name: Build and Extract JSON
on:
schedule:
- cron: "0 22 * * *"
workflow_dispatch:
inputs:
runner:
type: choice
options:
- ubuntu-24.04
- ubicloud-standard-16-ubuntu-2404
- ubicloud-standard-30-ubuntu-2404
default: ubuntu-24.04
description: The runner for this action
required: true
slicer:
type: choice
options:
- all
- OrcaSlicer
- PrusaSlicer
- BambuStudio
- ElegooSlicer
- QIDIStudio
- CrealityPrint
- AnycubicSlicerNext
default: all
description: Slicer to dump configs for
required: true
build-type:
type: choice
options:
- all
- nightly
- latest_release
default: all
description: Build type to run
required: true
release-tag:
type: string
default: ''
description: Optional release tag override for testing one version
required: false
disable-caching:
type: boolean
default: false
description: Disable caching
force-latest-release-rebuild:
type: boolean
default: false
description: Force rebuilding latest_release even when the tag was already built
permissions:
contents: write
jobs:
build_slicers:
strategy:
fail-fast: false
matrix:
slicer:
- OrcaSlicer
- PrusaSlicer
- BambuStudio
- ElegooSlicer
# - QIDIStudio
- CrealityPrint
build-type:
- nightly
- latest_release
include:
- slicer: OrcaSlicer
repo: OrcaSlicer/OrcaSlicer
release_tag: ''
- slicer: PrusaSlicer
repo: prusa3d/PrusaSlicer
release_tag: version_2.9.3
- slicer: BambuStudio
repo: BambuLab/BambuStudio
release_tag: v02.05.00.67
- slicer: ElegooSlicer
repo: ELEGOO-3D/ElegooSlicer
release_tag: ''
# - slicer: QIDIStudio
# repo: QIDITECH/QIDISlicer
- slicer: CrealityPrint
repo: CrealityOfficial/CrealityPrint
release_tag: ''
- slicer: AnycubicSlicerNext
repo: ANYCUBIC-3D/AnycubicSlicerNext
release_tag: ''
runs-on: ${{ inputs.runner || 'ubuntu-24.04' }}
env:
DEPS_CACHE_KEY: ''
BUILD_CACHE_REF: ''
continue_build: 'true'
latest_release_at_head: 'false'
steps:
- name: Apply dispatch filters
run: |
selected_slicer="${{ inputs.slicer || 'all' }}"
selected_build_type="${{ inputs.build-type || 'all' }}"
if [[ "$selected_slicer" != "all" && "$selected_slicer" != "${{ matrix.slicer }}" ]]; then
echo "Skipping ${{ matrix.slicer }} because slicer filter is $selected_slicer."
echo "continue_build=false" >> "$GITHUB_ENV"
exit 0
fi
if [[ "$selected_build_type" != "all" && "$selected_build_type" != "${{ matrix.build-type }}" ]]; then
echo "Skipping ${{ matrix.build-type }} because build-type filter is $selected_build_type."
echo "continue_build=false" >> "$GITHUB_ENV"
exit 0
fi
- name: Checkout repository
if: env.continue_build == 'true'
uses: actions/checkout@v4
- name: Setup
if: env.continue_build == 'true'
run: |
set -euo pipefail
git clone https://github.com/${{ matrix.repo }} slicer-src --depth 1 --
latest_release_tag="${{ inputs.release-tag || matrix.release_tag }}"
if [[ -z "$latest_release_tag" ]]; then
latest_release_json=$(curl -fsSL "https://api.github.com/repos/${{ matrix.repo }}/releases/latest")
latest_release_tag=$(echo "$latest_release_json" | jq -r '.tag_name')
else
latest_release_json=$(curl -fsSL "https://api.github.com/repos/${{ matrix.repo }}/releases/tags/${latest_release_tag}" || echo '{}')
fi
latest_release_hash=$(curl -fsSL "https://api.github.com/repos/${{ matrix.repo }}/commits/refs/tags/${latest_release_tag}" | jq -r '.sha')
upstream_published_at=$(echo "$latest_release_json" | jq -r '.published_at // empty')
head_hash=$(curl -fsSL "https://api.github.com/repos/${{ matrix.repo }}/commits/HEAD" | jq -r '.sha')
latest_stored_tag=$(jq -r '.latest // empty' "slicers/${{ matrix.slicer }}/out/_index.json" 2>/dev/null || true)
release_config_present=$(jq -r --arg tag "$latest_release_tag" '(.versions[$tag].config? != null)' "slicers/${{ matrix.slicer }}/out/_index.json" 2>/dev/null || echo false)
echo latest_release_tag=$latest_release_tag
echo latest_release_hash=$latest_release_hash
echo latest_stored_tag=$latest_stored_tag
echo release_config_present=$release_config_present
echo upstream_published_at=$upstream_published_at
echo head_hash=$head_hash
echo "latest_release_tag=$latest_release_tag" >> "$GITHUB_ENV"
echo "latest_release_hash=$latest_release_hash" >> "$GITHUB_ENV"
echo "upstream_published_at=$upstream_published_at" >> "$GITHUB_ENV"
echo "head_hash=$head_hash" >> "$GITHUB_ENV"
if [[ "$release_config_present" != "true" ]] || [[ "${{ inputs.force-latest-release-rebuild || false }}" == "true" ]]; then
git -C slicer-src fetch origin refs/tags/$latest_release_tag
if [[ "$head_hash" == "$latest_release_hash" ]]; then
echo "Latest release found at HEAD"
latest_release_at_head=true
echo "latest_release_at_head=true" >> "$GITHUB_ENV"
fi
elif [[ "${{ matrix.build-type }}" == "latest_release" ]]; then
echo "The latest release has already been built. Exiting..."
echo "continue_build=false" >> "$GITHUB_ENV"
exit 0
fi
if [[ "${{ matrix.build-type }}" == "latest_release" ]] && [[ "${latest_release_at_head:-false}" == "true" ]] && [[ "${{ inputs.build-type || 'all' }}" != "latest_release" ]]; then
echo "The latest release is at the HEAD of the repo. The nightly build will generate release files. Exiting..."
echo "continue_build=false" >> "$GITHUB_ENV"
exit 0
fi
mkdir -p slicer-out
if [[ "${{ matrix.build-type }}" == "nightly" ]]; then
build_ref_hash="$head_hash"
version_dir="nightly"
else
build_ref_hash="$latest_release_hash"
version_dir="$latest_release_tag"
fi
echo "BUILD_CACHE_REF=${{ matrix.build-type }}-${build_ref_hash}" >> "$GITHUB_ENV"
cat > slicer-out/config.sh <<EOF
build_type=${{ matrix.build-type }}
version_dir=$version_dir
tag=$latest_release_tag
slicer=${{ matrix.slicer }}
repo=${{ matrix.repo }}
latest_release_at_head=${latest_release_at_head:-false}
upstream_ref=$build_ref_hash
upstream_published_at=$upstream_published_at
created_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)
workflow_run_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
EOF
- name: Finalize Setup
if: env.continue_build == 'true'
env:
build_ref: ${{ matrix.build-type == 'latest_release' && 'FETCH_HEAD' || 'HEAD' }}
run: |
sudo apt-get update
sudo apt-get install -y xvfb
git -C slicer-src checkout ${{ env.build_ref }}
./tools/apply_versioned_patches.sh "${{ matrix.slicer }}" "${{ matrix.build-type == 'nightly' && 'nightly' || env.latest_release_tag }}" dump
- name: Install dependencies
if: env.continue_build == 'true'
run: |
./slicers/${{ matrix.slicer }}/steps/install-deps.sh
- name: Get dependencies cache key
if: env.continue_build == 'true'
run: |
cd slicer-src
echo "DEPS_CACHE_KEY=$(git log -1 --pretty="format:%H" -- deps)" >> $GITHUB_ENV
- name: Cache built dependencies
if: env.continue_build == 'true' && !inputs.disable-caching
id: cache-build-deps
uses: actions/cache@v4
with:
path: slicer-src/deps/build
key: ${{ runner.os }}-${{ matrix.slicer }}-x86-64-build-deps-${{ env.DEPS_CACHE_KEY }}-${{ hashFiles(format('slicers/{0}/steps/build-deps.sh', matrix.slicer)) }}
- name: Build dependencies
if: env.continue_build == 'true' && (inputs.disable-caching || steps.cache-build-deps.outputs.cache-hit != 'true')
run: |
./slicers/${{ matrix.slicer }}/steps/build-deps.sh
- name: Cache built slicer
if: env.continue_build == 'true' && !inputs.disable-caching
id: cache-build-slicer
uses: actions/cache@v4
with:
path: slicer-src/build
key: ${{ runner.os }}-${{ matrix.slicer }}-build-slicer-${{ env.BUILD_CACHE_REF }}-${{ hashFiles('slicer-src/src/libslic3r/PrintConfig.cpp', 'slicer-src/src/slic3r/GUI/Tab.cpp', 'tools/apply_versioned_patches.sh', format('slicers/{0}/patches/**/*.patch', matrix.slicer)) }}
- name: Build slicer
if: env.continue_build == 'true' && (inputs.disable-caching || steps.cache-build-slicer.outputs.cache-hit != 'true')
run: |
./slicers/${{ matrix.slicer }}/steps/build.sh
- name: Run slicer
if: env.continue_build == 'true'
run: |
./slicers/${{ matrix.slicer }}/steps/run.sh
- name: Upload extracted JSON files
if: env.continue_build == 'true'
uses: actions/upload-artifact@v4
with:
name: configs-${{ matrix.slicer }}-${{ matrix.build-type }}
path: slicer-out/*
commit_artifacts:
needs: build_slicers
runs-on: ubuntu-24.04
if: success() || failure()
concurrency:
group: slicer-out-${{ github.ref_name }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Commit extracted configs
run: |
set -euo pipefail
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
for folder in artifacts/configs-*; do
[[ -d "$folder" ]] || continue
echo "Begin processing $folder"
source "$folder/config.sh"
rm "$folder/config.sh"
target="slicers/$slicer/out/$version_dir"
mkdir -p "$target"
cp -rf "$folder"/* "$target" || true
./tools/update_slicer_index.py \
--index "slicers/$slicer/out/_index.json" \
--version "$version_dir" \
--kind config \
--created-at "$created_at" \
--upstream-ref "$upstream_ref" \
--upstream-published-at "$upstream_published_at" \
--source-repo "$repo" \
--workflow-run-url "$workflow_run_url" \
$([[ "$version_dir" != "nightly" ]] && echo --latest)
if [[ "$build_type" == "nightly" && "$latest_release_at_head" == "true" ]]; then
release_target="slicers/$slicer/out/$tag"
mkdir -p "$release_target"
cp -rf "$target"/* "$release_target" || true
./tools/update_slicer_index.py \
--index "slicers/$slicer/out/_index.json" \
--version "$tag" \
--latest \
--kind config \
--created-at "$created_at" \
--upstream-ref "$upstream_ref" \
--upstream-published-at "$upstream_published_at" \
--source-repo "$repo" \
--workflow-run-url "$workflow_run_url"
fi
git add "slicers/$slicer/out"
if git diff --cached --quiet; then
echo "No config changes for $slicer $version_dir."
else
git commit -m "chore(${slicer,,}): dump configuration of ${version_dir} @ ${upstream_ref:0:12}"
fi
done
git pull --rebase origin "${GITHUB_REF_NAME}"
git push origin "HEAD:${GITHUB_REF_NAME}"