mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-23 14:10:55 -05:00
* Move the Flatpak Jobs Into a Reusable Workflow
build_flatpak.yml holds the Flatpak build and its two sandbox unit-test jobs, moved verbatim, so a second workflow can call them. Build all calls it for every event it built the Flatpak for before.
* Build the Flatpak, macOS x86_64 and Windows arm64 for Pull Requests on Request
Build all no longer builds them for a pull request: the Flatpak is the slowest
Linux leg, a macOS x86_64 build holds one of the few hosted macOS runners for
an hour, and Windows arm64 doubles the Windows legs. Pushes, the nightly and
dispatches still build everything, and a pull request's macOS arm64 build ships
as its own DMG in place of the universal one.
The new build_optional.yml builds them on a label (build-flatpak,
build-macos-x86_64, build-windows-arm64), from when it is added and on every
later push, and builds the Flatpak and Windows arm64 without a label when the
pull request changes anything outside the sources, tests, profiles,
translations and docs, which is where what breaks only those legs lives. Each
build keeps its own concurrency group, which cancel_closed_pr_builds.yml joins.
The macOS admission script now counts the macOS jobs of both workflows, and
build_check_cache.yml names the workflows in its env instead of deriving one
from the caller. The label bot lets a contributor ask for the Flatpak.
* Run the Windows Build Script Tests Only When a Pull Request Changes Them
The three suites build their own fixtures and read nothing else from the
tree, so on a pull request a short Linux job looks for a change to the scripts
or the suites first, and the Windows builds accept the skipped job. Pushes and
the nightly still run them every time.
* Read WORKFLOW Through a Checked Expansion
Shellcheck's SC2153 takes a bare uppercase reference next to the lowercase variable for a misspelling.
* Let the Pull Request Author Ask for Any Optional Build Through the Bot
GitHub starts no workflow from an event the job's own token causes, so the
label bot mints a GitHub App installation token when the app's secrets exist
and adds the build-* labels with it; without them the build starts with the
next push. The run a label starts is an ordinary pull_request run, so a first
pull request's waits for a maintainer's approval as Build all does.
* Build Everything the Labels Ask for in Every Optional Builds Run
Each label added starts a run of its own, and the pull request's checks show
the newest run only, so a run that built its own label's leg alone left the
others looking skipped. Every run now builds everything the labels and the
changed files ask for; the concurrency group of each build cancels the one an
earlier run of the commit started, so the newest run ends with them all.
* Filter Optional Builds Like Build All and Add a build-all Label
The workflow takes Build all's pull_request paths plus the Flatpak packaging,
so a pull request Build all skips, one that only changes an unrelated
workflow or script, gets no optional build and starts none on a label. The
build-all label asks for every optional build at once.
* Keep the Flatpak on Every Pull Request
flatpak-builder compiles with the GNOME SDK's default flags, which include
-D_GLIBCXX_ASSERTIONS, so the Flatpak's unit tests are the only pull request
check that aborts on an out-of-range vector access where the other legs'
Release builds read garbage and pass. Since August that caught four bugs
that changed only src/, tests/ or resources/, which the infra rule would not
have built, and the leg runs on hosted Linux runners, so gating it freed no
macOS runner. Build all calls build_flatpak.yml on pull requests again; the
optional builds are the macOS x86_64 and Windows arm64 ones, and build-all
means those two.
* Revert "Keep the Flatpak on Every Pull Request"
This reverts commit 998e31a99b.
The Flatpak stays behind the build-flatpak label and the infra rule, as
the maintainers prefer.
* Build the Linux Legs With libstdc++'s Assertions
flatpak-builder compiles with the GNOME SDK's default flags, which include
-D_GLIBCXX_ASSERTIONS, so the Flatpak's unit tests were the only pull
request check that aborts on an out-of-range vector access where the other
legs' Release builds read garbage and pass. Pull requests build the Flatpak
on request only now. SLIC3R_GLIBCXX_ASSERTIONS defines the macro for the
OrcaSlicer build, and the Linux legs turn it on, so every pull request keeps
those checks on a leg that always runs. The checks are libstdc++'s
lightweight subset: no class changes layout, so the prebuilt deps link as
they are.
262 lines
12 KiB
YAML
262 lines
12 KiB
YAML
# The Flatpak build and its unit tests, for build_all.yml and for a pull request
|
|
# that asks for it (build_optional.yml).
|
|
name: Build Flatpak
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
jobs:
|
|
flatpak:
|
|
name: Build Flatpak
|
|
container:
|
|
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-50
|
|
options: --privileged
|
|
volumes:
|
|
- /usr/local/lib/android:/usr/local/lib/android
|
|
- /usr/share/dotnet:/usr/share/dotnet
|
|
- /opt/ghc:/opt/ghc1
|
|
- /usr/local/share/boost:/usr/local/share/boost1
|
|
- /opt/hostedtoolcache:/opt/hostedtoolcache1
|
|
# Updating a runtime renames its old deployment, which fails with
|
|
# "Invalid cross-device link" on hosts whose Docker overlay cannot
|
|
# rename directories from an image layer. A volume is not overlay.
|
|
- /var/lib/flatpak
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
variant:
|
|
- arch: x86_64
|
|
runner: ubuntu-24.04
|
|
- arch: aarch64
|
|
runner: ubuntu-24.04-arm
|
|
runs-on: ${{ matrix.variant.runner }}
|
|
env:
|
|
date:
|
|
ver:
|
|
ver_pure:
|
|
steps:
|
|
- name: "Remove unneeded stuff to free disk space"
|
|
run:
|
|
rm -rf /usr/local/lib/android/* /usr/share/dotnet/* /opt/ghc1/* "/usr/local/share/boost1/*" /opt/hostedtoolcache1/*
|
|
- uses: actions/checkout@v7
|
|
- name: Get the version and date
|
|
run: |
|
|
ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
|
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
ver="PR-${{ github.event.number }}"
|
|
git_commit_hash="${{ github.event.pull_request.head.sha }}"
|
|
else
|
|
ver=V$ver_pure
|
|
git_commit_hash="${{ github.sha }}"
|
|
fi
|
|
echo "ver=$ver" >> $GITHUB_ENV
|
|
echo "ver_pure=$ver_pure" >> $GITHUB_ENV
|
|
echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
|
echo "git_commit_hash=$git_commit_hash" >> $GITHUB_ENV
|
|
shell: bash
|
|
- name: Compute the flatpak-builder cache key
|
|
id: fp_cache_key
|
|
run: echo "key=flatpak-builder-${{ matrix.variant.arch }}-${{ hashFiles('deps/**', 'scripts/flatpak/com.orcaslicer.OrcaSlicer.yml', 'scripts/flatpak/make_deps_tar.sh') }}" >> "$GITHUB_OUTPUT"
|
|
shell: bash
|
|
# Manage flatpak-builder cache externally so PRs restore but never upload.
|
|
# The compiler cache under it is keyed per run below, so it is left out.
|
|
- name: Restore flatpak-builder cache
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: |
|
|
.flatpak-builder/*
|
|
!.flatpak-builder/ccache
|
|
key: ${{ steps.fp_cache_key.outputs.key }}
|
|
restore-keys: flatpak-builder-${{ matrix.variant.arch }}-
|
|
- name: Save/restore flatpak-builder cache
|
|
if: github.event_name != 'pull_request'
|
|
uses: actions/cache@v6
|
|
with:
|
|
path: |
|
|
.flatpak-builder/*
|
|
!.flatpak-builder/ccache
|
|
key: ${{ steps.fp_cache_key.outputs.key }}
|
|
restore-keys: flatpak-builder-${{ matrix.variant.arch }}-
|
|
# Compiler cache for the OrcaSlicer module, as in build_orca.yml. Pull
|
|
# requests only restore it; every other run (main, release branches, the
|
|
# nightly, a dispatch) saves it. orca_deps stays on the state cache above.
|
|
- name: Name the compiler cache leg
|
|
run: |
|
|
leg="Flatpak-${{ matrix.variant.arch }}"
|
|
echo "CCACHE_LEG=$leg" >> "$GITHUB_ENV"
|
|
echo "CCACHE_ENTRY=ccache-$leg-${{ github.run_id }}-${{ github.run_attempt }}" >> "$GITHUB_ENV"
|
|
shell: bash
|
|
- name: Restore compiler cache
|
|
id: ccache_restore
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: .flatpak-builder/ccache
|
|
key: ${{ env.CCACHE_ENTRY }}
|
|
restore-keys: ccache-${{ env.CCACHE_LEG }}-
|
|
- name: Disable debug info for faster CI builds
|
|
run: |
|
|
sed -i '/^build-options:/a\ no-debuginfo: true\n strip: true' \
|
|
scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
|
|
shell: bash
|
|
# flatpak-builder reuses a module from its cache when the definition and
|
|
# sources are unchanged, so a re-run of the same commit would skip the
|
|
# OrcaSlicer module and ship no test asset. A per-run value in that module's
|
|
# env keeps it rebuilding; orca_deps stays cached, and the compiler cache
|
|
# still serves the rebuild. run-tests on the same module builds the test
|
|
# binaries.
|
|
- name: Inject commit hash, run-tests and cache buster into Flatpak manifest
|
|
env:
|
|
flatpak_builder_cache_buster: ${{ github.run_id }}-${{ github.run_attempt }}
|
|
run: |
|
|
sed -i "/name: OrcaSlicer/{n;s|buildsystem: simple|buildsystem: simple\n run-tests: true\n build-options:\n env:\n flatpak_builder_cache_buster: \"$flatpak_builder_cache_buster\"\n git_commit_hash: \"$git_commit_hash\"|}" \
|
|
scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
|
|
shell: bash
|
|
# flatpak-builder's --ccache only wraps cc and gcc, and the manifest builds
|
|
# with clang, so CMake's launcher runs ccache instead; --ccache is still what
|
|
# mounts the cache directory into the sandbox. The settings go into that
|
|
# directory's own config file, which the sandbox reads too.
|
|
- name: Enable compiler cache
|
|
run: |
|
|
printf ' %s\n' \
|
|
'CMAKE_C_COMPILER_LAUNCHER: ccache' \
|
|
'CMAKE_CXX_COMPILER_LAUNCHER: ccache' > "$RUNNER_TEMP/ccache-env.yml"
|
|
sed -i "/^ git_commit_hash: /r $RUNNER_TEMP/ccache-env.yml" \
|
|
scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
|
|
grep -q '^ CMAKE_CXX_COMPILER_LAUNCHER: ccache$' scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
|
|
mkdir -p .flatpak-builder/ccache
|
|
export CCACHE_DIR=$PWD/.flatpak-builder/ccache
|
|
ccache --set-config=max_size=3G
|
|
# The compiler is reinstalled every run, so its mtime means nothing.
|
|
ccache --set-config=compiler_check=content
|
|
# Headers a fresh checkout has just written, the few files that use
|
|
# __DATE__ or __TIME__, and the precompiled header, whose macros ccache
|
|
# cannot see.
|
|
ccache --set-config=sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime
|
|
# Hash the includes the compiler reports instead of preprocessing every
|
|
# miss before compiling it.
|
|
ccache --set-config=depend_mode=true
|
|
# The restored directory carries the previous run's counters.
|
|
ccache -z
|
|
shell: bash
|
|
- name: Check the manifest keeps orca_deps cacheable
|
|
run: ./scripts/flatpak/check_manifest_cacheable.sh
|
|
shell: bash
|
|
- name: Pack deps/ for the Flatpak manifest
|
|
run: ./scripts/flatpak/make_deps_tar.sh
|
|
shell: bash
|
|
- uses: flatpak/flatpak-github-actions/flatpak-builder@master
|
|
with:
|
|
bundle: OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak
|
|
manifest-path: scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
|
|
# cache only turns on flatpak-builder --ccache; the caching itself is above.
|
|
cache: true
|
|
restore-cache: false
|
|
save-cache: false
|
|
arch: ${{ matrix.variant.arch }}
|
|
upload-artifact: false
|
|
keep-build-dirs: true
|
|
# The build has just touched everything it can use, so an object untouched
|
|
# for a week is dead, usually orphaned by a flag change.
|
|
- name: Compiler cache statistics
|
|
if: always()
|
|
run: |
|
|
export CCACHE_DIR=$PWD/.flatpak-builder/ccache
|
|
ccache --evict-older-than 7d
|
|
ccache -s -v || ccache -s
|
|
shell: bash
|
|
# Save the new entry first, then drop the older ones for this leg on this
|
|
# ref, so a failed save leaves the previous entry in place. A cancelled or
|
|
# failed build saves too, since what it compiled is still valid; a restore
|
|
# that did not finish does not, since the directory may be a truncated copy.
|
|
- name: Save compiler cache
|
|
id: ccache_save
|
|
if: ${{ always() && steps.ccache_restore.outcome == 'success' && github.event_name != 'pull_request' }}
|
|
uses: actions/cache/save@v6
|
|
with:
|
|
path: .flatpak-builder/ccache
|
|
key: ${{ env.CCACHE_ENTRY }}
|
|
- name: Drop older compiler cache entries
|
|
if: ${{ always() && steps.ccache_save.outcome == 'success' }}
|
|
# The container has no gh, so this is the list and delete over the REST API.
|
|
# Older means a lower run id, so two runs finishing close together keep
|
|
# the newer entry whichever of them cleans up last.
|
|
continue-on-error: true
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
api="$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/caches"
|
|
# The save step reports success even when its tar failed, so keep
|
|
# the older entries unless the new one is listed.
|
|
if ! curl -sSf -H "Authorization: Bearer $GH_TOKEN" \
|
|
"$api?ref=$GITHUB_REF&key=$CCACHE_ENTRY" \
|
|
| jq -e --arg entry "$CCACHE_ENTRY" 'any(.actions_caches[]; .key == $entry)' > /dev/null; then
|
|
echo "$CCACHE_ENTRY was not saved; keeping the older entries."
|
|
exit 0
|
|
fi
|
|
curl -sSf -H "Authorization: Bearer $GH_TOKEN" \
|
|
"$api?ref=$GITHUB_REF&key=ccache-$CCACHE_LEG-&per_page=100" \
|
|
| jq -r --arg prefix "ccache-$CCACHE_LEG-" --argjson run "$GITHUB_RUN_ID" \
|
|
'.actions_caches[] | select((.key | ltrimstr($prefix) | split("-")[0] | tonumber?) < $run) | .id' \
|
|
| while read -r id; do
|
|
curl -sSf -X DELETE -H "Authorization: Bearer $GH_TOKEN" "$api/$id"
|
|
done
|
|
shell: bash
|
|
- name: Upload artifacts Flatpak
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak
|
|
path: '/__w/OrcaSlicer/OrcaSlicer/OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak'
|
|
- name: Deploy Flatpak to nightly release
|
|
if: github.repository == 'OrcaSlicer/OrcaSlicer' && github.ref == 'refs/heads/main'
|
|
uses: ./.github/actions/deploy-nightly
|
|
with:
|
|
asset_path: /__w/OrcaSlicer/OrcaSlicer/OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak
|
|
asset_name: OrcaSlicer-Linux-flatpak_nightly_${{ matrix.variant.arch }}.flatpak
|
|
# The asset is /app (the exes link it at runtime) plus the build tree
|
|
# slimmed to what ctest needs.
|
|
- name: Package flatpak test asset
|
|
shell: bash
|
|
run: |
|
|
d=$(ls -d .flatpak-builder/build/OrcaSlicer-* | tail -1)
|
|
find "$d/build_flatpak" -mindepth 1 -maxdepth 1 ! -name tests -exec rm -rf {} +
|
|
# Strip debug info (the SDK builds with -g, only the app gets stripped);
|
|
# the bounds checks are compiled in, so a stripped exe still catches them.
|
|
find "$d/build_flatpak/tests" -type f -perm -u+x -exec strip --strip-unneeded {} + 2>/dev/null || true
|
|
# At runtime the tests read tests/ (TEST_DATA_DIR), scripts/, and under
|
|
# resources/ the shipped profiles (PROFILES_DIR), the printers/ maps, and
|
|
# the icon SVGs (NativeCommands icon names are checked against them).
|
|
find "$d" -mindepth 1 -maxdepth 1 -type d \
|
|
! -name tests ! -name build_flatpak ! -name scripts ! -name resources -exec rm -rf {} +
|
|
find "$d/resources" -mindepth 1 -maxdepth 1 ! -name profiles ! -name printers ! -name images -exec rm -rf {} +
|
|
# Only the SVGs are read; the png/ico/icns/gif assets are ~35MB of dead weight.
|
|
find "$d/resources/images" -mindepth 1 -maxdepth 1 ! -name '*.svg' -exec rm -rf {} + 2>/dev/null || true
|
|
tar -cf flatpak-test-asset.tar flatpak_app "$d"
|
|
- name: Upload flatpak test asset
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ github.sha }}-flatpak-tests-${{ matrix.variant.arch }}
|
|
path: flatpak-test-asset.tar
|
|
retention-days: 1
|
|
# keep-build-dirs would otherwise land in the flatpak-builder cache saved post-job.
|
|
- name: Drop the kept build dirs before the flatpak-builder cache saves
|
|
if: always()
|
|
shell: bash
|
|
run: rm -rf .flatpak-builder/build
|
|
unit_tests_flatpak_x86_64:
|
|
name: Flatpak x86_64
|
|
needs: flatpak
|
|
if: ${{ !cancelled() && success() }}
|
|
uses: ./.github/workflows/unit_tests_flatpak.yml
|
|
with:
|
|
os: ubuntu-24.04
|
|
artifact: ${{ github.sha }}-flatpak-tests-x86_64
|
|
unit_tests_flatpak_aarch64:
|
|
name: Flatpak aarch64
|
|
needs: flatpak
|
|
if: ${{ !cancelled() && success() }}
|
|
uses: ./.github/workflows/unit_tests_flatpak.yml
|
|
with:
|
|
os: ubuntu-24.04-arm
|
|
artifact: ${{ github.sha }}-flatpak-tests-aarch64
|