diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 0cae85189b..41d489d4d8 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -48,17 +48,16 @@ concurrency: jobs: - build_linux: # Separate so unit tests can wait on just Linux builds to complete. + build_linux: name: Build Linux strategy: fail-fast: false # Don't run scheduled builds on forks: if: ${{ !cancelled() && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }} - uses: ./.github/workflows/build_deps.yml + uses: ./.github/workflows/build_check_cache.yml with: os: ubuntu-24.04 build-deps-only: ${{ inputs.build-deps-only || false }} - force-build: ${{ github.event_name == 'schedule' }} secrets: inherit build_all: name: Build Non-Linux @@ -71,7 +70,7 @@ jobs: arch: arm64 # Don't run scheduled builds on forks: if: ${{ !cancelled() && (github.event_name != 'schedule' || github.repository == 'OrcaSlicer/OrcaSlicer') }} - uses: ./.github/workflows/build_deps.yml + uses: ./.github/workflows/build_check_cache.yml with: os: ${{ matrix.os }} arch: ${{ matrix.arch }} @@ -113,7 +112,7 @@ jobs: path: build/tests/**/*.log - name: Publish Test Results if: always() - uses: EnricoMi/publish-unit-test-result-action/linux@v2 + uses: EnricoMi/publish-unit-test-result-action@v2 with: files: "ctest_results.xml" flatpak: diff --git a/.github/workflows/build_check_cache.yml b/.github/workflows/build_check_cache.yml new file mode 100644 index 0000000000..00b5f71ecd --- /dev/null +++ b/.github/workflows/build_check_cache.yml @@ -0,0 +1,62 @@ +name: Check Cache + +on: + workflow_call: + inputs: + os: + required: true + type: string + arch: + required: false + type: string + build-deps-only: + required: false + type: boolean + force-build: + required: false + type: boolean + +jobs: + check_cache: # determines if there is a cache and outputs variables used in caching process + name: Check Cache + runs-on: ${{ inputs.os }} + outputs: + cache-key: ${{ steps.set_outputs.outputs.cache-key }} + cache-path: ${{ steps.set_outputs.outputs.cache-path }} + valid-cache: ${{ steps.cache_deps.outputs.cache-hit }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + lfs: 'true' + + - name: set outputs + id: set_outputs + env: + dep-folder-name: ${{ inputs.os != 'macos-14' && '/OrcaSlicer_dep' || '' }} + output-cmd: ${{ inputs.os == 'windows-latest' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"'}} + run: | + echo cache-key=${{ inputs.os }}-cache-orcaslicer_deps-build-${{ hashFiles('deps/**') }} >> ${{ env.output-cmd }} + echo cache-path=${{ github.workspace }}/deps/build${{ env.dep-folder-name }} >> ${{ env.output-cmd }} + + - name: load cache + id: cache_deps + uses: actions/cache@v4 + with: + path: ${{ steps.set_outputs.outputs.cache-path }} + key: ${{ steps.set_outputs.outputs.cache-key }} + lookup-only: true + + build_deps: # call next step + name: Build Deps + needs: [check_cache] + uses: ./.github/workflows/build_deps.yml + with: + cache-key: ${{ needs.check_cache.outputs.cache-key }} + cache-path: ${{ needs.check_cache.outputs.cache-path }} + valid-cache: ${{ needs.check_cache.outputs.valid-cache == 'true' }} + os: ${{ inputs.os }} + arch: ${{ inputs.arch }} + build-deps-only: ${{ inputs.build-deps-only }} + force-build: ${{ inputs.force-build }} + secrets: inherit diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index c6288330a1..b255b6abf7 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -1,6 +1,15 @@ on: workflow_call: inputs: + cache-key: + required: true + type: string + cache-path: + required: true + type: string + valid-cache: + required: true + type: boolean os: required: true type: string @@ -17,62 +26,55 @@ on: jobs: build_deps: name: Build Deps + if: ${{ !cancelled() && (inputs.build-deps-only || inputs.force-build || inputs.valid-cache != true) }} runs-on: ${{ inputs.os }} - outputs: - artifact-name: ${{ env.ARTIFACT_NAME }} - artifact-path: ${{ env.DEPS_PATH }} env: - DO_BUILD: ${{ inputs.build-deps-only || inputs.force-build }} - DEPS_PATH: ${{ github.workspace }}/deps/build${{ inputs.os != 'macos-14' && '/OrcaSlicer_dep' || '' }} - ARTIFACT_NAME: OrcaSlicer_dep_${{ inputs.os }}_${{ inputs.arch }} + date: steps: + + # Setup the environment - name: Checkout uses: actions/checkout@v6 with: lfs: 'true' - # Cached deps are just the final outputs, no intermediate files. - # So building XOR cache loading. - # We use `lookup-only` to skip pulling cache. - name: load cached deps - uses: actions/cache/restore@v5 - id: cache-load + uses: actions/cache@v4 with: - path: ${{ env.DEPS_PATH }} - key: ${{ inputs.os }}-${{ inputs.arch }}-cache-orcaslicer_deps-build-${{ hashFiles('deps/**') }} - lookup-only: ${{ env.DO_BUILD == 'true' }} # Doing this instead of `if` preserves the outputs of this step + path: ${{ inputs.cache-path }} + key: ${{ inputs.cache-key }} - uses: lukka/get-cmake@latest - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') }} with: cmakeVersion: "~3.28.0" # use most recent 3.28.x version - name: setup dev on Windows - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && inputs.os == 'windows-latest' }} + if: inputs.os == 'windows-latest' uses: microsoft/setup-msbuild@v2 - name: Get the date on Ubuntu and macOS - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && inputs.os != 'windows-latest' }} + if: inputs.os != 'windows-latest' run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV shell: bash - name: Get the date on Windows - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && inputs.os == 'windows-latest' }} + if: inputs.os == 'windows-latest' run: echo "date=$(Get-Date -Format 'yyyyMMdd')" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8 shell: pwsh + + # Build Dependencies - name: Build on Windows - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && inputs.os == 'windows-latest' }} + if: inputs.os == 'windows-latest' working-directory: ${{ github.workspace }} run: | choco install strawberryperl .\build_release_vs.bat deps + .\build_release_vs.bat pack + cd ${{ github.workspace }}/deps/build - # Windows and Linux don't need to delete any directories, because they only package up deps/build/OrcaSlicer_dep. - # But Mac has multiple and we're preserving their directory structure relationship. - # So the garbage siblings of OrcaSlicer_dep can be deleted to save artifact and cache space. - name: Build on Mac ${{ inputs.arch }} - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && inputs.os == 'macos-14' }} + if: inputs.os == 'macos-14' working-directory: ${{ github.workspace }} run: | brew install automake texinfo libtool @@ -85,40 +87,53 @@ jobs: done brew install zstd + - name: Apt-Install Dependencies - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && inputs.os == 'ubuntu-24.04' }} + if: inputs.os == 'ubuntu-24.04' uses: ./.github/actions/apt-install-deps - name: Build on Ubuntu - if: ${{ !cancelled() && (env.DO_BUILD == 'true' || steps.cache-load.outputs.cache-hit != 'true') && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} + if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' working-directory: ${{ github.workspace }} run: | + mkdir -p ${{ github.workspace }}/deps/build/destdir ./build_linux.sh -dr + cd deps/build + tar -czvf OrcaSlicer_dep_ubuntu_$(date +"%Y%m%d").tar.gz destdir - - name: Upload OrcaSlicer_dep director(ies) for use later - if: ${{ !cancelled() && ! env.ACT}} - uses: actions/upload-artifact@v6 - with: - name: ${{ env.ARTIFACT_NAME }} - path: ${{ env.DEPS_PATH }} - retention-days: 10 # It's not too big, but we don't need it for a very long time. - if-no-files-found: error - - name: Save cache from main branch - if: ${{ !cancelled() && github.ref == 'refs/heads/main' && steps.cache-load.outputs.cache-hit != 'true' }} - uses: actions/cache/save@v5 + # Upload Artifacts + # - name: Upload Mac ${{ inputs.arch }} artifacts + # if: inputs.os == 'macos-14' + # uses: actions/upload-artifact@v5 + # with: + # name: OrcaSlicer_dep_mac_${{ env.date }} + # path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep*.tar.gz + + - name: Upload Windows artifacts + if: inputs.os == 'windows-latest' + uses: actions/upload-artifact@v5 with: - path: ${{ env.DEPS_PATH }} - key: ${{ steps.cache-load.outputs.cache-primary-key }} + name: OrcaSlicer_dep_win64_${{ env.date }} + path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep*.zip + + - name: Upload Ubuntu artifacts + if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} + env: + ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} + uses: actions/upload-artifact@v5 + with: + name: OrcaSlicer_dep_ubuntu_${{ env.ubuntu-ver }}_${{ env.date }} + path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep_ubuntu_*.tar.gz build_orca: name: Build OrcaSlicer needs: [build_deps] - if: ${{ !cancelled() && (!inputs.build-deps-only || inputs.force-build) }} + if: ${{ !cancelled() && !inputs.build-deps-only && (inputs.force-build || (inputs.valid-cache == true && needs.build_deps.result == 'skipped') || (inputs.valid-cache != true && success())) }} uses: ./.github/workflows/build_orca.yml with: - artifact-name: ${{ needs.build_deps.outputs.artifact-name }} - artifact-path: ${{ needs.build_deps.outputs.artifact-path }} + cache-key: ${{ inputs.cache-key }} + cache-path: ${{ inputs.cache-path }} os: ${{ inputs.os }} arch: ${{ inputs.arch }} secrets: inherit diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index d70b4c9200..aef491f006 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -1,10 +1,10 @@ on: workflow_call: inputs: - artifact-name: + cache-key: required: true type: string - artifact-path: + cache-path: required: true type: string os: @@ -30,11 +30,12 @@ jobs: with: lfs: 'true' - - name: Download deps artifacts - uses: actions/download-artifact@v7 + - name: load cached deps + uses: actions/cache@v4 with: - name: ${{ inputs.artifact-name }} - path: ${{ inputs.artifact-path }} + path: ${{ inputs.cache-path }} + key: ${{ inputs.cache-key }} + fail-on-cache-miss: true - uses: lukka/get-cmake@latest with: @@ -180,14 +181,14 @@ jobs: - name: Upload artifacts mac if: inputs.os == 'macos-14' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_Mac_universal_${{ env.ver }} path: ${{ github.workspace }}/OrcaSlicer_Mac_universal_${{ env.ver }}.dmg - name: Upload OrcaSlicer_profile_validator DMG mac if: inputs.os == 'macos-14' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_profile_validator_Mac_universal_DMG_${{ env.ver }} path: ${{ github.workspace }}/OrcaSlicer_profile_validator_Mac_universal_${{ env.ver }}.dmg @@ -254,28 +255,28 @@ jobs: - name: Upload artifacts Win zip if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_Windows_${{ env.ver }}_portable path: ${{ github.workspace }}/build/OrcaSlicer - name: Upload artifacts Win installer if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_Windows_${{ env.ver }} path: ${{ github.workspace }}/build/OrcaSlicer*.exe - name: Upload artifacts Win PDB if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: PDB path: ${{ github.workspace }}/build/src/Release/Debug_PDB_${{ env.ver }}_for_developers_only.7z - name: Upload OrcaSlicer_profile_validator Win if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_profile_validator_Windows_${{ env.ver }} path: ${{ github.workspace }}/build/src/Release/OrcaSlicer_profile_validator.exe @@ -335,7 +336,7 @@ jobs: # and doesn't preserve file permissions - name: Upload Test Artifact if: inputs.os == 'ubuntu-24.04' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: ${{ github.sha }}-tests overwrite: true @@ -357,7 +358,7 @@ jobs: env: ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} path: './build/OrcaSlicer_Linux_AppImage${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage' @@ -366,7 +367,7 @@ jobs: if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} env: ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v5 with: name: OrcaSlicer_profile_validator_Linux_ubuntu_${{ env.ubuntu-ver }}_${{ env.ver }} path: './build/src/Release/OrcaSlicer_profile_validator' diff --git a/build_linux.sh b/build_linux.sh index 3159557146..9a9a9160ba 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -21,7 +21,7 @@ function usage() { echo " -p: boost ccache hit rate by disabling precompiled headers (default: ON)" echo " -r: skip RAM and disk checks (low RAM compiling)" echo " -s: build the Orca Slicer (optional)" - echo " -t: build tests (optional)" + echo " -t: build tests (optional), requires -s flag" echo " -u: install system dependencies (asks for sudo password; build prerequisite)" echo " -l: use Clang instead of GCC (default: GCC)" echo " -L: use ld.lld as linker (if available)"