diff --git a/.github/actions/apt-install-deps/action.yml b/.github/actions/apt-install-deps/action.yml new file mode 100644 index 0000000000..c850d0ea10 --- /dev/null +++ b/.github/actions/apt-install-deps/action.yml @@ -0,0 +1,11 @@ +name: 'Apt Install Deps' +description: 'Install the packages needed for building and deploying' +runs: + using: 'composite' + steps: + - name: Install dependencies from build_linux.sh + shell: bash + run: | + mkdir -p ${{ github.workspace }}/deps/build/destdir + sudo env "ORCA_UPDATER_SIG_KEY=$ORCA_UPDATER_SIG_KEY" ./build_linux.sh -ur + sudo chown $USER -R ./ diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index f9541e2cf2..ef07651217 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -33,6 +33,9 @@ on: - 'resources/**' + 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: @@ -46,24 +49,72 @@ concurrency: jobs: + build_linux: + name: Build Linux + strategy: + fail-fast: false + # Don't run scheduled builds on forks: + if: github.event_name != 'schedule' || github.repository == 'SoftFever/OrcaSlicer' + uses: ./.github/workflows/build_check_cache.yml + with: + os: ubuntu-24.04 + build-deps-only: ${{ inputs.build-deps-only || false }} + secrets: inherit build_all: - name: Build All + name: Build Non-Linux strategy: fail-fast: false matrix: include: - # Deprecate 20.04appimage - # - os: ubuntu-20.04 - - os: ubuntu-24.04 - os: windows-latest - os: macos-14 arch: arm64 + # Don't run scheduled builds on forks: + if: github.event_name != 'schedule' || github.repository == 'SoftFever/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 + unit_tests: + name: Unit Tests + runs-on: ubuntu-24.04 + needs: build_linux + if: ${{ success() }} + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + sparse-checkout: | + .github + scripts + - name: Apt-Install Dependencies + uses: ./.github/actions/apt-install-deps + - name: Restore Test Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ github.sha }}-tests + - uses: lukka/get-cmake@latest + with: + cmakeVersion: "~3.28.0" # use most recent 3.28.x version + - name: Unpackage and Run Unit Tests + timeout-minutes: 20 + run: | + tar -xvf build_tests.tar + scripts/run_unit_tests.sh + - name: Upload Test Logs + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: unit-test-logs + path: build/tests/**/*.log + - name: Publish Test Results + if: always() + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: "ctest_results.xml" flatpak: name: "Flatpak" container: @@ -82,6 +133,8 @@ jobs: runner: ubuntu-24.04 - arch: aarch64 runner: ubuntu-24.04-arm + # Don't run scheduled builds on forks: + if: github.event_name != 'schedule' || github.repository == 'SoftFever/OrcaSlicer' runs-on: ${{ matrix.variant.runner }} env: date: @@ -120,7 +173,7 @@ jobs: 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.ref == 'refs/heads/main'}} + if: github.repository == 'SoftFever/OrcaSlicer' && github.ref == 'refs/heads/main' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} diff --git a/.github/workflows/build_check_cache.yml b/.github/workflows/build_check_cache.yml index fcb55681d8..a97962aa7e 100644 --- a/.github/workflows/build_check_cache.yml +++ b/.github/workflows/build_check_cache.yml @@ -12,6 +12,9 @@ on: 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 @@ -55,4 +58,5 @@ jobs: 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 5e430bc85f..fbd3ef723e 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -19,11 +19,14 @@ on: build-deps-only: required: false type: boolean + force-build: + required: false + type: boolean jobs: build_deps: name: Build Deps - if: inputs.build-deps-only || inputs.valid-cache != true + if: inputs.build-deps-only || inputs.force-build || inputs.valid-cache != true runs-on: ${{ inputs.os }} env: date: @@ -85,28 +88,15 @@ jobs: brew install zstd - - name: Install Ubuntu Build Dependencies - if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' - working-directory: ${{ github.workspace }} - env: - apt-cmd: ${{ (inputs.os == 'ubuntu-20.04' && 'apt-fast') || (inputs.os == 'ubuntu-24.04' && 'sudo apt-get') || '' }} - webkit-ver: ${{ (inputs.os == 'ubuntu-20.04' && '4.0') || (inputs.os == 'ubuntu-24.04' && '4.1') || '' }} - run: | - ${{ env.apt-cmd }} update - ${{ env.apt-cmd }} install -y cmake git g++ build-essential libgl1-mesa-dev m4 \ - libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules pkgconf \ - libglu1-mesa-dev libcairo2-dev libgtk-3-dev libsoup2.4-dev libwebkit2gtk-${{ env.webkit-ver }}-dev \ - libgstreamer1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-base1.0-dev \ - gstreamer1.0-plugins-bad wget sudo autoconf curl libunwind-dev texinfo + - name: Apt-Install Dependencies + if: inputs.os == 'ubuntu-24.04' + uses: ./.github/actions/apt-install-deps - name: Build on Ubuntu if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' working-directory: ${{ github.workspace }} run: | - mkdir -p ${{ github.workspace }}/deps/build mkdir -p ${{ github.workspace }}/deps/build/destdir - sudo ./build_linux.sh -ur - sudo chown $USER -R ./ ./build_linux.sh -dr cd deps/build tar -czvf OrcaSlicer_dep_ubuntu_$(date +"%Y%m%d").tar.gz destdir @@ -139,7 +129,7 @@ jobs: build_orca: name: Build OrcaSlicer needs: [build_deps] - if: ${{ !cancelled() && !inputs.build-deps-only && (inputs.valid-cache == true && needs.build_deps.result == 'skipped') || (inputs.valid-cache != true && success()) }} + 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: cache-key: ${{ inputs.cache-key }} diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 29984fab2e..be9990a0bb 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -108,7 +108,7 @@ jobs: # Thanks to RaySajuuk, it's working now - name: Sign app and notary - if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && inputs.os == 'macos-14' + if: github.repository == 'SoftFever/OrcaSlicer' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && inputs.os == 'macos-14' working-directory: ${{ github.workspace }} env: BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} @@ -195,7 +195,7 @@ jobs: if-no-files-found: ignore - name: Deploy Mac release - if: github.ref == 'refs/heads/main' && inputs.os == 'macos-14' + if: github.repository == 'SoftFever/OrcaSlicer' && github.ref == 'refs/heads/main' && inputs.os == 'macos-14' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} @@ -206,7 +206,7 @@ jobs: max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted - name: Deploy Mac OrcaSlicer_profile_validator DMG release - if: github.ref == 'refs/heads/main' && inputs.os == 'macos-14' + if: github.repository == 'SoftFever/OrcaSlicer' && github.ref == 'refs/heads/main' && inputs.os == 'macos-14' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} @@ -282,7 +282,7 @@ jobs: path: ${{ github.workspace }}/build/src/Release/OrcaSlicer_profile_validator.exe - name: Deploy Windows release portable - if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' + if: github.repository == 'SoftFever/OrcaSlicer' && github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} @@ -293,7 +293,7 @@ jobs: max_releases: 1 - name: Deploy Windows release installer - if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' + if: github.repository == 'SoftFever/OrcaSlicer' && github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} @@ -304,7 +304,7 @@ jobs: max_releases: 1 - name: Deploy Windows OrcaSlicer_profile_validator release - if: github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' + if: github.repository == 'SoftFever/OrcaSlicer' && github.ref == 'refs/heads/main' && inputs.os == 'windows-latest' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} @@ -315,39 +315,34 @@ jobs: max_releases: 1 # Ubuntu - - name: Install dependencies - if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' - env: - apt-cmd: ${{ (inputs.os == 'ubuntu-20.04' && 'apt-fast') || (inputs.os == 'ubuntu-24.04' && 'sudo apt-get') || '' }} - webkit-ver: ${{ (inputs.os == 'ubuntu-20.04' && '4.0') || (inputs.os == 'ubuntu-24.04' && '4.1') || '' }} - libfuse2-pkg: ${{ (inputs.os == 'ubuntu-20.04' && 'libfuse2') || (inputs.os == 'ubuntu-24.04' && 'libfuse2t64') || '' }} - run: | - ${{ env.apt-cmd }} update - ${{ env.apt-cmd }} install -y autoconf build-essential cmake curl eglexternalplatform-dev \ - extra-cmake-modules file git libcairo2-dev libcurl4-openssl-dev libdbus-1-dev libglew-dev libglu1-mesa-dev \ - libglu1-mesa-dev libgstreamer1.0-dev libgstreamerd-3-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev \ - libgtk-3-dev libgtk-3-dev libmspack-dev libsecret-1-dev libsoup2.4-dev libssl-dev libudev-dev libwayland-dev \ - libwebkit2gtk-${{ env.webkit-ver }}-dev libxkbcommon-dev locales locales-all m4 pkgconf sudo wayland-protocols wget ${{ env.libfuse2-pkg }} + - name: Apt-Install Dependencies + if: inputs.os == 'ubuntu-24.04' + uses: ./.github/actions/apt-install-deps - - name: Install dependencies from build_linux.sh - if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' - shell: bash - run: sudo env "ORCA_UPDATER_SIG_KEY=$ORCA_UPDATER_SIG_KEY" ./build_linux.sh -ur - - - name: Fix permissions - if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' - shell: bash - run: sudo chown $USER -R ./ - - - name: Build slicer + # Tests must built at the same time as the slicer; + # if you untangle them feel free to separate them here too + - name: Build slicer and tests if: inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' shell: bash env: ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} run: | - ./build_linux.sh -isr + ./build_linux.sh -istr mv -n ./build/OrcaSlicer_Linux_V${{ env.ver_pure }}.AppImage ./build/OrcaSlicer_Linux_AppImage${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage chmod +x ./build/OrcaSlicer_Linux_AppImage${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage + tar -cvpf build_tests.tar build/tests + + # Use tar because upload-artifacts won't always preserve directory structure + # and doesn't preserve file permissions + - name: Upload Test Artifact + if: inputs.os == 'ubuntu-24.04' + uses: actions/upload-artifact@v4 + with: + name: ${{ github.sha }}-tests + overwrite: true + path: build_tests.tar + retention-days: 5 + if-no-files-found: error - name: Build orca_custom_preset_tests if: github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' @@ -378,7 +373,7 @@ jobs: path: './build/src/Release/OrcaSlicer_profile_validator' - name: Deploy Ubuntu release - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} + if: ${{ github.repository == 'SoftFever/OrcaSlicer' && ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} env: ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} uses: WebFreak001/deploy-nightly@v3.2.0 @@ -390,7 +385,7 @@ jobs: 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 - name: Deploy Ubuntu release - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' }} + if: ${{ github.repository == 'SoftFever/OrcaSlicer' && ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' }} uses: rickstaa/action-create-tag@v1 with: tag: "nightly-builds" @@ -399,7 +394,7 @@ jobs: message: "nightly-builds" - name: Deploy Ubuntu OrcaSlicer_profile_validator release - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} + if: ${{ github.repository == 'SoftFever/OrcaSlicer' && ! env.ACT && github.ref == 'refs/heads/main' && (inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04') }} env: ubuntu-ver-str: ${{ (inputs.os == 'ubuntu-24.04' && '_Ubuntu2404') || '' }} uses: WebFreak001/deploy-nightly@v3.2.0 @@ -412,7 +407,7 @@ jobs: max_releases: 1 - name: Deploy orca_custom_preset_tests - if: ${{ ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' }} + if: ${{ github.repository == 'SoftFever/OrcaSlicer' && ! env.ACT && github.ref == 'refs/heads/main' && inputs.os == 'ubuntu-24.04' }} uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/SoftFever/OrcaSlicer/releases/137995723/assets{?name,label} diff --git a/CLAUDE.md b/CLAUDE.md index bec75bea8e..eb35833082 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -65,7 +65,8 @@ build_release_vs2022.bat slicer # Performance and debug options: ./build_linux.sh -j N # limit to N cores ./build_linux.sh -1 # single core build -./build_linux.sh -b # debug build +./build_linux.sh -b # Debug build +./build_linux.sh -e # RelWithDebInfo build ./build_linux.sh -c # clean build ./build_linux.sh -r # skip RAM/disk checks ./build_linux.sh -l # use Clang instead of GCC @@ -107,9 +108,10 @@ cd build && ctest --output-on-failure Run individual test suites: ```bash # From build directory -./tests/libslic3r/libslic3r_tests -./tests/fff_print/fff_print_tests -./tests/sla_print/sla_print_tests +ctest --test-dir ./tests/libslic3r/libslic3r_tests +ctest --test-dir ./tests/fff_print/fff_print_tests +ctest --test-dir ./tests/sla_print/sla_print_tests +# and so on ``` ## Architecture @@ -254,4 +256,4 @@ Run individual test suites: - **Regression testing** important due to algorithm complexity - **Performance benchmarks** help catch performance regressions - **Memory leak** detection important for long-running GUI application -- **Cross-platform** testing required before releases \ No newline at end of file +- **Cross-platform** testing required before releases diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c81a18992..3e11ab904a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,6 @@ option(SLIC3R_PROFILE "Compile OrcaSlicer with an invasive Shiny profiler" 0) option(SLIC3R_PCH "Use precompiled headers" 1) option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1) -option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0) option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0) # If SLIC3R_FHS is 1 -> SLIC3R_DESKTOP_INTEGRATION is always 0, othrewise variable. CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integration during runtime" 1 "NOT SLIC3R_FHS" 0) @@ -171,7 +170,6 @@ endif () if (IS_CROSS_COMPILE) message("Detected cross compilation setup. Tests and encoding checks will be forcedly disabled!") - set(SLIC3R_PERL_XS OFF CACHE BOOL "" FORCE) set(BUILD_TESTS OFF CACHE BOOL "" FORCE) endif () @@ -883,13 +881,6 @@ set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT O add_dependencies(gettext_make_pot hintsToPot) -# Perl bindings, currently only used for the unit / integration tests of libslic3r. -# Also runs the unit / integration tests. -#FIXME Port the tests into C++ to finally get rid of the Perl! -if (SLIC3R_PERL_XS) - add_subdirectory(xs) -endif () - if(SLIC3R_BUILD_SANDBOXES) add_subdirectory(sandboxes) endif() diff --git a/build_linux.sh b/build_linux.sh index e2da74482d..1f35b464f6 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -7,7 +7,7 @@ SCRIPT_PATH=$(dirname "$(readlink -f "${0}")") pushd "${SCRIPT_PATH}" > /dev/null function usage() { - echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-h][-i][-j N][-p][-r][-s][-t][-u][-l][-L]" + echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-D][-e][-h][-i][-j N][-p][-r][-s][-t][-u][-l][-L]" echo " -1: limit builds to one core (where possible)" echo " -j N: limit builds to N cores (where possible)" echo " -b: build in Debug mode" @@ -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)" @@ -102,6 +102,11 @@ if [ ${OPTIND} -eq 1 ] ; then exit 1 fi +if [[ -n "${BUILD_TESTS}" ]] && [[ -z "${BUILD_ORCA}" ]] ; then + echo "-t flag requires -s flag in the same invocation" + exit 1 +fi + function check_available_memory_and_disk() { FREE_MEM_GB=$(free --gibi --total | grep 'Mem' | rev | cut --delimiter=" " --fields=1 | rev) MIN_MEM_GB=10 @@ -243,19 +248,22 @@ if [[ -n "${BUILD_ORCA}" ]] ; then echo "Building OrcaSlicer_profile_validator .." print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator ./scripts/run_gettext.sh + if [[ -n "${BUILD_TESTS}" ]] ; then + echo "Building tests ..." + print_and_run cmake --build ${BUILD_DIR} --config "${BUILD_CONFIG}" --target tests/all + fi echo "done" fi if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then pushd $BUILD_DIR > /dev/null - echo "[9/9] Generating Linux app..." build_linux_image="./src/build_linux_image.sh" if [[ -e ${build_linux_image} ]] ; then extra_script_args="" if [[ -n "${BUILD_IMAGE}" ]] ; then extra_script_args="-i" fi - print_and_run ${build_linux_image} ${extra_script_args} + print_and_run ${build_linux_image} ${extra_script_args} -R "${BUILD_CONFIG}" echo "done" fi diff --git a/doc/Home.md b/doc/Home.md index 7e2e0bf2f0..406420b2ea 100644 --- a/doc/Home.md +++ b/doc/Home.md @@ -152,6 +152,7 @@ OrcaSlicer is a powerful open source slicer for FFF (FDM) 3D Printers. This wiki ![im_code](https://github.com/SoftFever/OrcaSlicer/blob/main/resources/images/im_code.svg?raw=true) This is a documentation from someone exploring the code and is by no means complete or even completely accurate. Please edit the parts you might find inaccurate. This is probably going to be helpful nonetheless. - [How to build OrcaSlicer](How-to-build) +- [How to run tests](How-to-test) - [Localization and translation guide](Localization_guide) - [How to create profiles](How-to-create-profiles) - [How to contribute to the wiki](How-to-wiki) diff --git a/doc/developer-reference/How-to-build.md b/doc/developer-reference/How-to-build.md index fcebbf4ee7..f8e2d997b4 100644 --- a/doc/developer-reference/How-to-build.md +++ b/doc/developer-reference/How-to-build.md @@ -279,9 +279,9 @@ The build system supports multiple Linux distributions including Ubuntu/Debian a ./build_linux.sh -d ``` -3. **Build OrcaSlicer:** +3. **Build OrcaSlicer with tests:** ```shell - ./build_linux.sh -s + ./build_linux.sh -st ``` 4. **Build AppImage (optional):** @@ -291,14 +291,15 @@ The build system supports multiple Linux distributions including Ubuntu/Debian a 5. **All-in-one build (recommended):** ```shell - ./build_linux.sh -dsi + ./build_linux.sh -dsti ``` **Additional build options:** -- `-b`: Build in debug mode +- `-b`: Build in debug mode (mostly broken at runtime for a long time; avoid unless you want to be fixing failed assertions) - `-c`: Force a clean build - `-C`: Enable ANSI-colored compile output (GNU/Clang only) +- `-e`: Build RelWithDebInfo (release + symbols) - `-j N`: Limit builds to N cores (useful for low-memory systems) - `-1`: Limit builds to one core - `-l`: Use Clang instead of GCC @@ -309,10 +310,14 @@ The build system supports multiple Linux distributions including Ubuntu/Debian a > The build script automatically detects your Linux distribution and uses the appropriate package manager (apt, pacman) to install dependencies. > [!TIP] -> For first-time builds, use `./build_linux.sh -u` to install dependencies, then `./build_linux.sh -dsi` to build everything. +> For first-time builds, use `./build_linux.sh -u` to install dependencies, then `./build_linux.sh -dsti` to build everything. > [!WARNING] -> If you encounter memory issues during compilation, use `-j 1` or `-1` to limit parallel compilation, or `-r` to skip memory checks. +> If you encounter memory issues during compilation, use `-j 1` or `-1` to limit parallel compilation and `-r` to skip memory checks. + +#### Unit Testing + +See [How to Test](How-to-test) for more details. --- diff --git a/doc/developer-reference/How-to-test.md b/doc/developer-reference/How-to-test.md new file mode 100644 index 0000000000..2929384b1f --- /dev/null +++ b/doc/developer-reference/How-to-test.md @@ -0,0 +1,27 @@ +# How to Test + +This wiki page describes how to build and run tests on Linux. It should eventually provide guidance on how to add tests for a new feature. + +## Build Tests + +Can be built when you are building Orca Slicer binary by including the `-t` flag for `build_linux.sh`: + +``` +build_linux.sh -st +``` + +Test binaries will then appear under `build/tests`. As of this writing, not all tests will be built. + +## Run Unit Tests + +### Run All + +``` +ctest --test-dir build/tests +``` + +### Run a Specific Set + +``` +ctest --test-dir build/tests/slic3rutils +``` diff --git a/scripts/linux.d/debian b/scripts/linux.d/debian index ca090d670d..53e4ee5fa5 100644 --- a/scripts/linux.d/debian +++ b/scripts/linux.d/debian @@ -7,6 +7,7 @@ REQUIRED_DEV_PACKAGES=( eglexternalplatform-dev extra-cmake-modules file + g++ gettext git libcurl4-openssl-dev @@ -34,7 +35,7 @@ then if dpkg --compare-versions "${VERSION_ID}" ge 22 && dpkg --compare-versions "${VERSION_ID}" lt 24 ; then # Some extra packages needed on Ubuntu 22.x and 23.x: - REQUIRED_DEV_PACKAGES+=(curl libfuse-dev libssl-dev libcurl4-openssl-dev m4) + REQUIRED_DEV_PACKAGES+=(curl libfuse-dev m4) fi fi diff --git a/scripts/run_unit_tests.sh b/scripts/run_unit_tests.sh new file mode 100755 index 0000000000..254221dd64 --- /dev/null +++ b/scripts/run_unit_tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# This file is made to support the unit tests workflow. +# It should only require the directories build/tests and scripts/ to function, +# and cmake (with ctest) installed. +# (otherwise, update the workflow too, but try to avoid to keep things self-contained) + +ROOT_DIR="$(dirname "$0")/.." + +cd "${ROOT_DIR}" || exit 1 + +# TODO: github.com/SoftFever/OrcaSlicer/issues/10309 - Run all tests +ctest --test-dir build/tests/slic3rutils --output-junit "$(pwd)/ctest_results.xml" --output-on-failure diff --git a/src/dev-utils/platform/unix/build_linux_image.sh.in b/src/dev-utils/platform/unix/build_linux_image.sh.in index caeaccadee..ad1b492b7b 100755 --- a/src/dev-utils/platform/unix/build_linux_image.sh.in +++ b/src/dev-utils/platform/unix/build_linux_image.sh.in @@ -1,16 +1,24 @@ #!/usr/bin/env bash +# Despite the script name, this doesn't necessarily create an "image"; +# it sets up a compatibility script wrapper for the binary and arranges some resources. + export ROOT=$(echo $ROOT | grep . || pwd) export NCORES=`nproc --all` +CONFIG=Release -while getopts ":ih" opt; do +while getopts ":ihR:" opt; do case ${opt} in i ) export BUILD_IMAGE="1" ;; - h ) echo "Usage: ./build_linux_image.sh [-i]" + h ) echo "Usage: ./build_linux_image.sh [-i][-R config]" echo " -i: Generate Appimage (optional)" - exit 0 + echo " -R: Specify from which config to obtain the binary: Release, RelWithDebInfo, or Debug" + exit 1 + ;; + R ) + CONFIG=$OPTARG ;; esac done @@ -18,30 +26,26 @@ done echo -n "[9/9] Generating Linux app..." #{ # create directory and copy into it - if [ -d "package" ] - then - rm -rf package/* - rm -rf package/.* 2&>/dev/null - else - mkdir package + if [ -d "package" ]; then + rm -rf package fi - mkdir package/bin + mkdir -p package/bin - # copy Resources + # Copy Resources cp -Rf ../resources package/resources - # Find and copy the @SLIC3R_APP_CMD@ binary from Multi-Config build - if [ -f "src/Release/@SLIC3R_APP_CMD@" ]; then - cp -f src/Release/@SLIC3R_APP_CMD@ package/bin/@SLIC3R_APP_CMD@ + # Find and hard link the @SLIC3R_APP_CMD@ binary from Multi-Config build + ORIGINAL_BINARY_LOCATION="" + if [ -f "src/${CONFIG}/@SLIC3R_APP_CMD@" ]; then + ORIGINAL_BINARY_LOCATION="$(realpath "src/${CONFIG}/@SLIC3R_APP_CMD@")" elif [ -f "src/@SLIC3R_APP_CMD@" ]; then # Fallback for single-config builds - cp -f src/@SLIC3R_APP_CMD@ package/bin/@SLIC3R_APP_CMD@ + ORIGINAL_BINARY_LOCATION="$(realpath "src/@SLIC3R_APP_CMD@")" else echo "Error: @SLIC3R_APP_CMD@ binary not found in any configuration directory" exit 1 fi - # remove unneeded po from resources - ## find package/resources/localization -name "*.po" -type f -delete ## FIXME: DD - do we need this? + cp -fl "${ORIGINAL_BINARY_LOCATION}" package/bin/@SLIC3R_APP_CMD@ # create bin cat << EOF >@SLIC3R_APP_CMD@ @@ -76,10 +80,13 @@ exec "\$DIR/bin/@SLIC3R_APP_CMD@" "\$@" EOF chmod ug+x @SLIC3R_APP_CMD@ - cp -f @SLIC3R_APP_CMD@ package/@SLIC3R_APP_CMD@ - pushd package > /dev/null - tar -cvf ../@SLIC3R_APP_KEY@.tar . &>/dev/null - popd > /dev/null + cp -fl @SLIC3R_APP_CMD@ package/@SLIC3R_APP_CMD@ + # Nothing uses this tar? Remove if nobody has complained and it's been a while since this comment added. + # Original commit was https://github.com/SoftFever/OrcaSlicer/commit/f5a4862da52fc68f77b5201ddf330a9800d83228 + # and it doesn't appear to have been used there either. + #pushd package > /dev/null + #tar -cvf ../@SLIC3R_APP_KEY@.tar . &>/dev/null + #popd > /dev/null #} &> $ROOT/Build.log # Capture all command output echo "done" @@ -87,11 +94,20 @@ if [[ -n "$BUILD_IMAGE" ]] then echo -n "Creating Appimage for distribution..." #{ - pushd package > /dev/null + # AppImage script modifies files in place, so make a copy and clean up after. + rm -rf package_appimage + cp -Rf package package_appimage + pushd package_appimage > /dev/null chmod +x ../build_appimage.sh - ../build_appimage.sh - popd > /dev/null - mv package/"@SLIC3R_APP_KEY@_Linux_V@SoftFever_VERSION@.AppImage" "@SLIC3R_APP_KEY@_Linux_V@SoftFever_VERSION@.AppImage" + if ../build_appimage.sh; then + # Clean up on success. + popd > /dev/null + mv package_appimage/"@SLIC3R_APP_KEY@_Linux_V@SoftFever_VERSION@.AppImage" "@SLIC3R_APP_KEY@_Linux_V@SoftFever_VERSION@.AppImage" + rm -fR package_appimage + else + # Leave files on failure so you can debug. + popd > /dev/null + fi #} &> $ROOT/Build.log # Capture all command output echo "done" fi diff --git a/tests/slic3rutils/slic3rutils_tests_main.cpp b/tests/slic3rutils/slic3rutils_tests_main.cpp index 06989c5ee3..f0a9285c2f 100644 --- a/tests/slic3rutils/slic3rutils_tests_main.cpp +++ b/tests/slic3rutils/slic3rutils_tests_main.cpp @@ -21,7 +21,7 @@ TEST_CASE("Check SSL certificates paths", "[Http][NotWorking]") { } TEST_CASE("Http digest authentication", "[Http][NotWorking]") { - Slic3r::Http g = Slic3r::Http::get("https://jigsaw.w3.org/HTTP/Digest/"); + Slic3r::Http g = Slic3r::Http::get("https://httpbin.org/digest-auth/guest/guest"); g.auth_digest("guest", "guest"); @@ -40,7 +40,7 @@ TEST_CASE("Http digest authentication", "[Http][NotWorking]") { } TEST_CASE("Http basic authentication", "[Http][NotWorking]") { - Slic3r::Http g = Slic3r::Http::get("https://jigsaw.w3.org/HTTP/Basic/"); + Slic3r::Http g = Slic3r::Http::get("https://httpbin.org/basic-auth/guest/guest"); g.auth_basic("guest", "guest");