mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-24 18:37:39 +00:00
* Add caching system for presets * Removing user\bundle serialization and keeping it only for system presets * Integrate caching into WebGuideDialog which speeds up time of SetupWizzard and PrinterSelection dialog * Add CI\CD step to prepare cache file in ahead of time so user does not need to wait * Add partial cache generation when only one of the vendros is changed to speed up recalculation time * Handle corrupted files * Add cache to GuideDialog as previos version didn't work as expected * Add inspecting tool and fix CI cache generation * Generate cache per vendor * Simplify code by mergin it in PresetBundle * Simplify code a bit more * Add cereal serialize() to VendorProfile, PrinterModel, Preset, and Semver * Remove CachedPrinterModel/VendorProfile/Preset mirror structs from VendorCache * Fix use-after-free in CallAfter lambda; replace raw thread pointer with unique_ptr * Use get_vendor_cache_key() to match cache keys written by the app * Remove BOM added by VSC * Skip invalid vendors * Remove leftover cache file * Fix build for windows arm64 * Revert json cache back * Update check for stale cache * Serealize all value fields for Preset class to minimize regression later * Minimize field duplication by moving Cache thing into PresetBundle * Add tests for Cache system * Add a bit more tests * Merge branch 'main' into feature/cache_profiles_and_optimize_loading_speed * Rvert from per-verndor to single cache file Replace N per-vendor .cache files with a single system_presets.cache that holds all vendors and presets in one serialized blob. Cache load is now all-or-nothing: on hit all vendors are applied from the bundle (sub-second); on miss all vendors are parsed from JSON and a fresh bundle is written to the user cache dir. Invalidation is driven by bundle_key - a sorted concatenation of all vendor JSON version strings. Any vendor update invalidates the whole cache and triggers re-parse on next launch. Guide wizard (WebGuideDialog) loads the bundled cache into a plain PresetBundle instead of a separate VendorGuideData struct, removing the duplicate data model. generate_system_cache simplified from a per-vendor loop to a single save_system_presets_cache() call producing one output file. * Transfer all Preset fields from cache via move assignmet apply_vendor_preset_group was copying fields manually and missed bundle_id, user_id, base_id, sync_info, updated_time, key_values, ini_str. Replace field-by-field copy with move assignment of the fully-deserialized Preset, then restore the vendor pointer which is excluded from serialization. * Ignore cache for future * Remove not used files * Ship one preset cache per vendor in place of the profile JSONs Each vendor's system presets serialize into a single <vendor>.opc built at package time, and a shipped build carries that file alone — the profile JSON and its sub-file tree are pruned. The vendor loader, the setup wizard's profile list and the resource installer all read a vendor through its cache, falling back to parsing whenever one is absent, stale or unreadable, so the cache stays an optimization and never a source of truth. Caches hold presets in source form and resolve inheritance at load, through the same code the JSON path uses. * Make the preset cache self-describing and load each vendor from the system folder alone The cached DynamicPrintConfig is keyed by name, through a per-file dictionary of the distinct opt_keys, the type each was written as, and the distinct enum value names, instead of by serialization_key_ordinal — a position assigned by declaration order at static init, where inserting one option shifts every later ordinal and the lookup then succeeds on the wrong option. Because a name-keyed payload drops the options this build cannot place rather than being rejected wholesale, the schema fingerprint goes, and with it the two fallbacks that existed only because an installed cache died on every app upgrade: the second lookup tier into resources/profiles and the parse fallback to the same place. A vendor is loaded from <data_dir>/system/ and nowhere else, as on main — which is what makes the app write its .opc files there again. * Simplify the preset cache internals after review * Use the shared temp-dir helper in the preset bundle loading test * Bound stamp string reads in the preset cache * Speed up the setup wizard with a profile-data cache The wizard's per-vendor fast path threw on vendors present only in resources, falling back to a ~29 s raw JSON scan on every open. Each vendor now loads from the directory it was found in, and the derived model/machine/filament/process catalog is cached whole in <data_dir>/cache/wizard_profile_data.json, stamped by each vendor's name and version - a fresh cache makes an open one file read, with no bundle built and no presets installed (~0.2 s vs ~2 s). * Remove debug SVG dump from a geometry test * Move the per-vendor cache file format into PresetCacheFormat * Move the vendor install helpers from PresetBundle into Utils * rename * fix flatpak * change cache version to 1 --------- Co-authored-by: SoftFever <softfeverever@gmail.com>
309 lines
12 KiB
YAML
309 lines
12 KiB
YAML
name: Build all
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- release/*
|
|
- belt-printer
|
|
paths:
|
|
- 'deps/**'
|
|
- 'src/**'
|
|
- '**/CMakeLists.txt'
|
|
- 'version.inc'
|
|
- 'localization/**'
|
|
- 'resources/**'
|
|
- ".github/workflows/build_*.yml"
|
|
- 'scripts/build_preset_cache.*'
|
|
- 'scripts/flatpak/**'
|
|
- 'scripts/msix/**'
|
|
- 'tests/**'
|
|
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- release/*
|
|
paths:
|
|
- 'deps/**'
|
|
- 'deps_src/**'
|
|
- 'src/**'
|
|
- '**/CMakeLists.txt'
|
|
- 'version.inc'
|
|
- ".github/workflows/build_*.yml"
|
|
- 'build_linux.sh'
|
|
- 'build_release_vs.bat'
|
|
- 'build_release_vs2022.bat'
|
|
- 'build_release_macos.sh'
|
|
- 'scripts/build_preset_cache.*'
|
|
- 'scripts/flatpak/**'
|
|
- 'scripts/msix/**'
|
|
- 'tests/**'
|
|
|
|
|
|
schedule:
|
|
- cron: '0 17 * * *' # run once a day at 1 AM Singapore time (UTC+8)
|
|
|
|
workflow_dispatch: # allows for manual dispatch
|
|
inputs:
|
|
build-deps-only:
|
|
description: 'Only build dependencies (bypasses caching)'
|
|
type: boolean
|
|
default: false
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
|
|
jobs:
|
|
build_linux:
|
|
strategy:
|
|
fail-fast: false
|
|
# SELF_HOSTED skips arm64 (no arm self-hosted server). amd64's empty arch
|
|
# is load-bearing: it keeps the historical 'linux-clang' deps cache key and
|
|
# the unsuffixed asset names.
|
|
matrix:
|
|
include: ${{ fromJSON(vars.SELF_HOSTED
|
|
&& '[{"arch":"","os":"orca-lnx-server"}]'
|
|
|| '[{"arch":"","os":"ubuntu-24.04"},{"arch":"aarch64","os":"ubuntu-24.04-arm"}]') }}
|
|
# Don't run scheduled builds on forks:
|
|
if: ${{ !cancelled() && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }}
|
|
uses: ./.github/workflows/build_check_cache.yml
|
|
with:
|
|
os: ${{ matrix.os }}
|
|
arch: ${{ matrix.arch }}
|
|
build-deps-only: ${{ inputs.build-deps-only || false }}
|
|
secrets: inherit
|
|
build_windows:
|
|
name: Build Windows ${{ matrix.arch }}
|
|
strategy:
|
|
fail-fast: false
|
|
# SELF_HOSTED skips arm64 (the self-hosted Windows server is x64-only).
|
|
matrix:
|
|
include: ${{ fromJSON(vars.SELF_HOSTED
|
|
&& '[{"arch":"x64","os":"orca-win-server"}]'
|
|
|| '[{"arch":"x64","os":"windows-latest"},{"arch":"arm64","os":"windows-11-arm"}]') }}
|
|
# Don't run scheduled builds on forks:
|
|
if: ${{ !cancelled() && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }}
|
|
uses: ./.github/workflows/build_check_cache.yml
|
|
with:
|
|
os: ${{ matrix.os }}
|
|
arch: ${{ matrix.arch }}
|
|
build-deps-only: ${{ inputs.build-deps-only || false }}
|
|
force-build: ${{ github.event_name == 'schedule' }}
|
|
secrets: inherit
|
|
build_macos_arch:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
arch:
|
|
- arm64
|
|
- x86_64
|
|
# Don't run scheduled builds on forks:
|
|
if: ${{ !cancelled() && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }}
|
|
uses: ./.github/workflows/build_check_cache.yml
|
|
with:
|
|
os: ${{ vars.SELF_HOSTED && 'orca-macos-arm64' || 'macos-14' }}
|
|
arch: ${{ matrix.arch }}
|
|
build-deps-only: ${{ inputs.build-deps-only || false }}
|
|
force-build: ${{ github.event_name == 'schedule' }}
|
|
secrets: inherit
|
|
build_macos_universal:
|
|
name: Build macOS Universal
|
|
needs: build_macos_arch
|
|
if: ${{ !cancelled() && needs.build_macos_arch.result == 'success' && !inputs.build-deps-only && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }}
|
|
uses: ./.github/workflows/build_orca.yml
|
|
with:
|
|
os: ${{ vars.SELF_HOSTED && 'orca-macos-arm64' || 'macos-14' }}
|
|
arch: universal
|
|
macos-combine-only: true
|
|
secrets: inherit
|
|
# One test job per built arch, on the runner that built it.
|
|
unit_tests_linux_x86_64:
|
|
name: Linux x86_64
|
|
needs: build_linux
|
|
if: ${{ !cancelled() && success() }}
|
|
uses: ./.github/workflows/unit_tests.yml
|
|
with:
|
|
os: ${{ vars.SELF_HOSTED && 'orca-lnx-server' || 'ubuntu-24.04' }}
|
|
artifact: ${{ github.sha }}-tests-linux-x86_64
|
|
unit_tests_linux_aarch64:
|
|
name: Linux aarch64
|
|
needs: build_linux
|
|
if: ${{ !cancelled() && success() && !vars.SELF_HOSTED }}
|
|
uses: ./.github/workflows/unit_tests.yml
|
|
with:
|
|
os: ubuntu-24.04-arm
|
|
artifact: ${{ github.sha }}-tests-linux-aarch64
|
|
unit_tests_windows_x64:
|
|
name: Windows x64
|
|
needs: build_windows
|
|
if: ${{ !cancelled() && success() }}
|
|
uses: ./.github/workflows/unit_tests.yml
|
|
with:
|
|
os: ${{ vars.SELF_HOSTED && 'orca-win-server' || 'windows-latest' }}
|
|
artifact: ${{ github.sha }}-tests-windows-x64
|
|
unit_tests_windows_arm64:
|
|
name: Windows arm64
|
|
needs: build_windows
|
|
if: ${{ !cancelled() && success() && !vars.SELF_HOSTED }}
|
|
uses: ./.github/workflows/unit_tests.yml
|
|
with:
|
|
os: windows-11-arm
|
|
artifact: ${{ github.sha }}-tests-windows-arm64
|
|
test-dir: build-arm64/tests
|
|
unit_tests_macos_arm64:
|
|
name: macOS arm64
|
|
needs: build_macos_arch
|
|
if: ${{ !cancelled() && success() }}
|
|
uses: ./.github/workflows/unit_tests.yml
|
|
with:
|
|
os: ${{ vars.SELF_HOSTED && 'orca-macos-arm64' || 'macos-14' }}
|
|
artifact: ${{ github.sha }}-tests-macos-arm64
|
|
test-dir: build/arm64/tests
|
|
# Slice a two-colour cube through every shipped printer so all custom g-code
|
|
# (change_filament_gcode, machine start/end, etc.) is expanded - catches
|
|
# slicing regressions the static profile checks and unit tests can't see.
|
|
# Profile-only PRs are covered by check_profiles.yml's nightly binary; this
|
|
# covers src/engine PRs with the PR-built binary.
|
|
slice_check_linux:
|
|
name: Slice check (Linux ${{ vars.SELF_HOSTED && 'x86_64' || 'aarch64' }})
|
|
needs: build_linux
|
|
if: ${{ !cancelled() && success() }}
|
|
# Follows whichever Linux leg built the validator.
|
|
runs-on: ${{ vars.SELF_HOSTED && 'orca-lnx-server' || 'ubuntu-24.04-arm' }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v7
|
|
- name: Download profile validator
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: ${{ github.sha }}-profile-validator-linux-${{ vars.SELF_HOSTED && 'x86_64' || 'aarch64' }}
|
|
path: validator-bin
|
|
- name: Validate slice (expand custom g-code)
|
|
timeout-minutes: 60
|
|
run: |
|
|
chmod +x validator-bin/OrcaSlicer_profile_validator
|
|
./validator-bin/OrcaSlicer_profile_validator -p "${{ github.workspace }}/resources/profiles" -s -l 2
|
|
publish_test_results:
|
|
name: Publish Test Results
|
|
needs: [unit_tests_linux_x86_64, unit_tests_linux_aarch64, unit_tests_windows_x64, unit_tests_windows_arm64, unit_tests_macos_arm64]
|
|
if: ${{ !cancelled() }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Test Results
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: test-results-*
|
|
path: test-results
|
|
# Best-effort: a read-only token (e.g. fork PRs) can't write the check, so
|
|
# don't let a publish failure fail the run. The test jobs gate correctness.
|
|
- name: Publish Test Results
|
|
continue-on-error: true
|
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
with:
|
|
files: "test-results/**/*.xml"
|
|
- name: Delete Test Results
|
|
if: success()
|
|
uses: geekyeggo/delete-artifact@v6
|
|
with:
|
|
name: test-results-*
|
|
failOnError: false
|
|
flatpak:
|
|
name: "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
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
variant:
|
|
- arch: x86_64
|
|
runner: ubuntu-24.04
|
|
- arch: aarch64
|
|
runner: ubuntu-24.04-arm
|
|
# Don't run scheduled builds on forks; skip entirely on self-hosted runners
|
|
if: ${{ !cancelled() && !vars.SELF_HOSTED && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }}
|
|
|
|
runs-on: ${{ matrix.variant.runner }}
|
|
env:
|
|
date:
|
|
ver:
|
|
ver_pure:
|
|
# Belt-printer nightlies share the main nightly release but carry a `_belt`
|
|
# suffix so they never overwrite the main assets.
|
|
nightly_suffix: ${{ github.ref == 'refs/heads/belt-printer' && '_belt' || '' }}
|
|
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
|
|
# Manage flatpak-builder cache externally so PRs restore but never upload
|
|
- name: Restore flatpak-builder cache
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: .flatpak-builder
|
|
key: flatpak-builder-${{ matrix.variant.arch }}-${{ github.event.pull_request.base.sha }}
|
|
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
|
|
key: flatpak-builder-${{ matrix.variant.arch }}-${{ github.sha }}
|
|
restore-keys: flatpak-builder-${{ matrix.variant.arch }}-
|
|
- 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
|
|
- name: Inject git commit hash into Flatpak manifest
|
|
run: |
|
|
sed -i "/name: OrcaSlicer/{n;s|buildsystem: simple|buildsystem: simple\n build-options:\n env:\n git_commit_hash: \"$git_commit_hash\"|}" \
|
|
scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
|
|
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: false
|
|
arch: ${{ matrix.variant.arch }}
|
|
upload-artifact: false
|
|
- 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' || github.ref == 'refs/heads/belt-printer')
|
|
uses: WebFreak001/deploy-nightly@v3.2.0
|
|
with:
|
|
upload_url: https://uploads.github.com/repos/OrcaSlicer/OrcaSlicer/releases/137995723/assets{?name,label}
|
|
release_id: 137995723
|
|
asset_path: /__w/OrcaSlicer/OrcaSlicer/OrcaSlicer-Linux-flatpak_${{ env.ver }}_${{ matrix.variant.arch }}.flatpak
|
|
asset_name: OrcaSlicer-Linux-flatpak_nightly${{ env.nightly_suffix }}_${{ matrix.variant.arch }}.flatpak
|
|
asset_content_type: application/octet-stream
|
|
max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted
|