diff --git a/.github/workflows/CI_master.yml b/.github/workflows/CI_master.yml index 6cde36562c..1de7510563 100644 --- a/.github/workflows/CI_master.yml +++ b/.github/workflows/CI_master.yml @@ -45,12 +45,24 @@ jobs: with: artifactBasename: Ubuntu_20-04-${{ github.run_id }} + Ubuntu_22-04_Conda: + needs: [Prepare] + uses: ./.github/workflows/sub_buildUbuntu2204Conda.yml + with: + artifactBasename: Ubuntu_22-04_Conda-${{ github.run_id }} + Windows: needs: [Prepare] uses: ./.github/workflows/sub_buildWindows.yml with: artifactBasename: Windows-${{ github.run_id }} + Windows_Conda: + needs: [Prepare] + uses: ./.github/workflows/sub_buildWindowsConda.yml + with: + artifactBasename: Windows_Conda-${{ github.run_id }} + Lint: needs: [Prepare] uses: ./.github/workflows/sub_lint.yml @@ -61,7 +73,14 @@ jobs: changedPythonFiles: ${{ needs.Prepare.outputs.changedPythonFiles }} WrapUp: - needs: [Prepare, Ubuntu_20-04, Windows, Lint] + needs: [ + Prepare, + Ubuntu_20-04, + Ubuntu_22-04_Conda, + Windows, + Windows_Conda, + Lint + ] if: always() uses: ./.github/workflows/sub_wrapup.yml with: diff --git a/.github/workflows/actions/linux/build/action.yml b/.github/workflows/actions/linux/build/action.yml index 3e0162d2fe..98a0d056f5 100644 --- a/.github/workflows/actions/linux/build/action.yml +++ b/.github/workflows/actions/linux/build/action.yml @@ -46,12 +46,12 @@ runs: steps: - name: Build id: build - shell: bash + shell: bash -l {0} run: | (stdbuf -oL -eL cmake --build ${{ inputs.builddir }} -j$(nproc) ${{ inputs.extraParameters }}) \ 2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }} - name: Write report - shell: bash + shell: bash -l {0} if: always() run: | if [ ${{ steps.build.outcome }} == 'success' ] diff --git a/.github/workflows/actions/linux/configure/action.yml b/.github/workflows/actions/linux/configure/action.yml index 643101f1c2..2b33ef3d0c 100644 --- a/.github/workflows/actions/linux/configure/action.yml +++ b/.github/workflows/actions/linux/configure/action.yml @@ -50,12 +50,12 @@ runs: steps: - name: Configure CMake id: configure - shell: bash + shell: bash -l {0} run: | (stdbuf -oL -eL cmake -S ${{ inputs.sourcedir }} -B ${{ inputs.builddir }} -D CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE ${{inputs.extraParameters }}) \ 2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }} - name: Write report - shell: bash + shell: bash -l {0} if: always() run: | if [ ${{ steps.configure.outcome }} == 'success' ] diff --git a/.github/workflows/actions/linux/generateCacheKey/action.yml b/.github/workflows/actions/linux/generateCacheKey/action.yml index 59673c9fe9..36053fe6c6 100644 --- a/.github/workflows/actions/linux/generateCacheKey/action.yml +++ b/.github/workflows/actions/linux/generateCacheKey/action.yml @@ -37,8 +37,8 @@ runs: using: "composite" steps: - id: generateCacheKey - shell: bash + shell: bash -l {0} run: | - cacheKey=$(lsb_release -ds | tr -d ' ')-$( basename ${{ inputs.compiler }})$(${{ inputs.compiler }} -dumpfullversion -dumpversion) + cacheKey=$(lsb_release -ds | tr -d ' ')-$(basename ${{ inputs.compiler }})$(${{ inputs.compiler }} -dumpfullversion -dumpversion) echo "Generated cache key : $cacheKey" echo "cacheKey=$cacheKey" >> $GITHUB_OUTPUT diff --git a/.github/workflows/actions/linux/install/action.yml b/.github/workflows/actions/linux/install/action.yml index 87b91ad93d..05bb57252f 100644 --- a/.github/workflows/actions/linux/install/action.yml +++ b/.github/workflows/actions/linux/install/action.yml @@ -46,12 +46,12 @@ runs: steps: - name: Install id: install - shell: bash + shell: bash -l {0} run: | (stdbuf -oL -eL sudo cmake --install ${{ inputs.builddir }} ${{ inputs.extraParameters }}) \ 2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }} - name: Write report - shell: bash + shell: bash -l {0} if: always() run: | if [ ${{ steps.install.outcome }} == 'success' ] diff --git a/.github/workflows/actions/runCPPTests/runAllTests/action.yml b/.github/workflows/actions/runCPPTests/runAllTests/action.yml index bdb434c220..bc6b3972ba 100644 --- a/.github/workflows/actions/runCPPTests/runAllTests/action.yml +++ b/.github/workflows/actions/runCPPTests/runAllTests/action.yml @@ -84,7 +84,7 @@ runs: testName: Sketcher - name: Compose summary report based on test results if: always() - shell: bash + shell: bash -l {0} run: | # Print global result if [ ${{ job.status }} != "success" ] @@ -104,4 +104,3 @@ runs: echo "" >> ${{ inputs.reportFile }} echo "" >> ${{ inputs.reportFile }} echo "" >> ${{ inputs.reportFile }} - diff --git a/.github/workflows/actions/runCPPTests/runSingleTest/action.yml b/.github/workflows/actions/runCPPTests/runSingleTest/action.yml index 642433f2c4..b99c01466a 100644 --- a/.github/workflows/actions/runCPPTests/runSingleTest/action.yml +++ b/.github/workflows/actions/runCPPTests/runSingleTest/action.yml @@ -44,12 +44,12 @@ runs: using: "composite" steps: - name: Run C++ tests - shell: bash + shell: bash -l {0} run: stdbuf -oL -eL ${{ inputs.testCommand }} |& tee -a ${{ inputs.testLogFile }} - name: Parse test results if: always() id: report - shell: bash + shell: bash -l {0} run: | result=$(sed -ne "/Global test environment tear-down/,/^$/{/^$/d;p}" ${{ inputs.testLogFile }}) if grep -qF "[ FAILED ]" <<< $result diff --git a/.github/workflows/actions/runPythonTests/action.yml b/.github/workflows/actions/runPythonTests/action.yml index b69e461ad3..26b362d2bb 100644 --- a/.github/workflows/actions/runPythonTests/action.yml +++ b/.github/workflows/actions/runPythonTests/action.yml @@ -43,11 +43,11 @@ runs: steps: - name: Run tests id: runTests - shell: bash + shell: bash -l {0} run: | stdbuf -oL -eL ${{ inputs.testCommand }} |& sed -Ee "/[[:blank:]]*\([[:digit:]]{1,3} %\)[[:blank:]]*/d" | tee -a ${{ inputs.logFile }} - name: Write report - shell: bash + shell: bash -l {0} if: always() run: | sed -ne "/^\(FAILED\|ERROR\):/,/^[[:blank:]]*$/bF; /^Traceback/,/^[^[:blank:]]/{/^Traceback/bT; /^[^[:blank:]]/G; bT}; b; :T w ${{ inputs.logFile }}_tracebacks" -e "b; :F w ${{ inputs.logFile }}_failedtests" ${{ inputs.logFile }} diff --git a/.github/workflows/sub_buildUbuntu2204Conda.yml b/.github/workflows/sub_buildUbuntu2204Conda.yml new file mode 100644 index 0000000000..bb3ae8e32d --- /dev/null +++ b/.github/workflows/sub_buildUbuntu2204Conda.yml @@ -0,0 +1,194 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# *************************************************************************** +# * * +# * Copyright (c) 2023 0penBrain. * +# * * +# * This file is part of FreeCAD. * +# * * +# * FreeCAD is free software: you can redistribute it and/or modify it * +# * under the terms of the GNU Lesser General Public License as * +# * published by the Free Software Foundation, either version 2.1 of the * +# * License, or (at your option) any later version. * +# * * +# * FreeCAD is distributed in the hope that it will be useful, but * +# * WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * +# * Lesser General Public License for more details. * +# * * +# * You should have received a copy of the GNU Lesser General Public * +# * License along with FreeCAD. If not, see * +# * . * +# * * +# *************************************************************************** + +# This is a build and test workflow for CI of FreeCAD. +# This workflow aims at building and testing FreeCAD on a Conda environment on Linux. + +name: Build Ubuntu 22.04 (Conda) +on: + workflow_call: + inputs: + artifactBasename: + type: string + required: true + testOnBuildDir: + default: false + type: boolean + required: false + allowedToFail: + default: false + type: boolean + required: false + outputs: + reportFile: + value: ${{ jobs.Build.outputs.reportFile }} + +jobs: + Build: + runs-on: ubuntu-22.04 + continue-on-error: ${{ inputs.allowedToFail }} + env: + CCACHE_DIR: ${{ github.workspace }}/ccache + CCACHE_CONFIGPATH: ${{ github.workspace }}/ccache/config + CCACHE_MAXSIZE: 1G + CCACHE_COMPILERCHECK: "%compiler% -dumpfullversion -dumpversion" # default:mtime + CCACHE_COMPRESS: true + CCACHE_COMPRESSLEVEL: 1 + builddir: ${{ github.workspace }}/build/release/ + logdir: /tmp/logs/ + reportdir: /tmp/report/ + reportfilename: ${{ inputs.artifactBasename }}-report.md + defaults: + run: + shell: bash -l {0} + outputs: + reportFile: ${{ steps.Init.outputs.reportFile }} + + steps: + - name: Checking out source code + uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: .conda/freecad + environment-file: conda/conda-env.yaml + channels: conda-forge,defaults + channel-priority: true + miniforge-version: latest + - name: Install FreeCAD dependencies + run: | + ./conda/setup-environment.sh + - name: Set Environment Variables + run: | + echo "CC=$CC" >> "$GITHUB_ENV" + echo "CXX=$CXX" >> "$GITHUB_ENV" + - name: Make needed directories, files and initializations + id: Init + run: | + mkdir -p ${{ env.CCACHE_DIR }} + mkdir -p ${{ env.CCACHE_CONFIGPATH }} + mkdir -p ${{ env.builddir }} + mkdir -p ${{ env.logdir }} + mkdir -p ${{ env.reportdir }} + echo "reportFile=${{ env.reportfilename }}" >> $GITHUB_OUTPUT + - name: Generate cache key + id: genCacheKey + uses: ./.github/workflows/actions/linux/generateCacheKey + with: + compiler: ${{ env.CXX }} + - name: Restore Compiler Cache + uses: pat-s/always-upload-cache@v3 + with: + path: ${{ env.CCACHE_DIR }} + key: FC-${{ steps.genCacheKey.outputs.cacheKey }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + FC-${{ steps.genCacheKey.outputs.cacheKey }}-${{ github.ref }}- + FC-${{ steps.genCacheKey.outputs.cacheKey }}- + - name: Print CCache statistics before build, reset stats and print config + run: | + ccache -s + ccache -z + ccache -p + - name: CMake Configure + uses: ./.github/workflows/actions/linux/configure + with: + extraParameters: --preset conda-linux-release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/.conda/freecad/opt/freecad + builddir: ${{ env.builddir }} + logFile: ${{ env.logdir }}Cmake.log + errorFile: ${{ env.logdir }}CmakeErrors.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: CMake Build + uses: ./.github/workflows/actions/linux/build + with: + builddir: ${{ env.builddir }} + logFile: ${{ env.logdir }}Build.log + errorFile: ${{ env.logdir }}BuildErrors.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: Print ccache statistics after Build + run: | + ccache -s + - name: FreeCAD CLI tests on build dir + if: inputs.testOnBuildDir + timeout-minutes: 10 + uses: ./.github/workflows/actions/runPythonTests + with: + testDescription: "CLI tests on build dir" + testCommand: ${{ env.builddir }}/bin/FreeCADCmd -t 0 + logFile: ${{ env.logdir }}TestCLIBuild.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: FreeCAD GUI tests on build dir + if: inputs.testOnBuildDir + timeout-minutes: 15 + uses: ./.github/workflows/actions/runPythonTests + with: + testDescription: "GUI tests on build dir" + testCommand: xvfb-run ${{ env.builddir }}/bin/FreeCAD -t 0 + logFile: ${{ env.logdir }}TestGUIBuild.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: C++ tests + timeout-minutes: 1 + uses: ./.github/workflows/actions/runCPPTests/runAllTests + with: + reportdir: ${{ env.reportdir }} + builddir: ${{ env.builddir }} + reportFile: ${{ env.reportdir }}${{ env.reportfilename }} + - name: CMake Install + uses: ./.github/workflows/actions/linux/install + with: + builddir: ${{ env.builddir }} + logFile: ${{ env.logdir }}Install.log + errorFile: ${{ env.logdir }}InstallErrors.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: FreeCAD CLI tests on install + timeout-minutes: 10 + uses: ./.github/workflows/actions/runPythonTests + with: + testDescription: "CLI tests on install" + testCommand: ${{ github.workspace }}/.conda/freecad/opt/freecad/bin/FreeCADCmd -t 0 + logFile: ${{ env.logdir }}TestCLIInstall.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: FreeCAD GUI tests on install + timeout-minutes: 15 + uses: ./.github/workflows/actions/runPythonTests + with: + testDescription: "GUI tests on install" + testCommand: xvfb-run ${{ github.workspace }}/.conda/freecad/opt/freecad/bin/FreeCAD -t 0 + logFile: ${{ env.logdir }}TestGUIInstall.log + reportFile: ${{env.reportdir}}${{ env.reportfilename }} + - name: Upload logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifactBasename }}-Logs + path: | + ${{ env.logdir }} + /var/crash/*FreeCAD* + - name: Upload report + if: always() + uses: actions/upload-artifact@v3 + with: + name: ${{ env.reportfilename }} + path: | + ${{env.reportdir}}${{ env.reportfilename }} diff --git a/.github/workflows/sub_buildWindowsConda.yml b/.github/workflows/sub_buildWindowsConda.yml new file mode 100644 index 0000000000..4ce65d27bd --- /dev/null +++ b/.github/workflows/sub_buildWindowsConda.yml @@ -0,0 +1,129 @@ +# *************************************************************************** +# * Copyright (c) 2023 0penBrain * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +# This is a build and test workflow for CI of FreeCAD. +# This workflow aims at building and testing FreeCAD using a Conda environment on Windows with MSVC. + +name: Build Windows (Conda) +on: + workflow_call: + inputs: + artifactBasename: + type: string + required: true + allowedToFail: + default: false + type: boolean + required: false + outputs: + reportFile: + value: ${{ jobs.Build.outputs.reportFile }} + +jobs: + Build: + runs-on: windows-latest + continue-on-error: ${{ inputs.allowedToFail }} + env: + CCACHE_DIR: C:/FC/cache/ + CCACHE_COMPILERCHECK: "%compiler%" # default:mtime + CCACHE_MAXSIZE: 1G + CCACHE_COMPRESS: true + CCACHE_COMPRESSLEVEL: 1 + CCACHE_NOHASHDIR: true + CCACHE_DIRECT: true + #CCACHE_SLOPPINESS: "pch_defines,time_macros" # Can't get PCH to work on Windows + CCACHE_LOGFILE: C:/logs/ccache.log + ## Have to use C:\ because not enough space on workspace drive + builddir: C:/FC/build/ + logdir: C:/logs/ + reportdir: C:/report/ + reportfilename: ${{ inputs.artifactBasename }}-report.md + outputs: + reportFile: ${{ steps.Init.outputs.reportFile }} + + steps: + - name: Checking out source code + uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: .conda/freecad + environment-file: conda/conda-env.yaml + channels: conda-forge,defaults + channel-priority: true + miniforge-version: latest + - name: Install FreeCAD dependencies + run: | + conda config --add envs_dirs $PWD/.conda + mamba-devenv -f conda/environment.devenv.yml + - name: Make needed directories, files and initializations + id: Init + run: | + mkdir ${{ env.CCACHE_DIR }} + mkdir ${{ env.builddir }} + mkdir ${{ env.logdir }} + mkdir ${{ env.reportdir }} + echo "reportFile=${{ env.reportfilename }}" >> $GITHUB_OUTPUT + - name: Restore compiler cache + uses: pat-s/always-upload-cache@v3 + with: + path: ${{ env.CCACHE_DIR }} + key: FC-Windows-Conda-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + FC-Windows-Conda-${{ github.ref }}- + FC-Windows-Conda- + - name: Print Ccache statistics before build, reset stats and print config + run: | + ccache -s + ccache -z + ccache -p + - name: Configuring CMake + shell: cmd /C CALL {0} + run: > + conda\cmake.cmd --preset conda-windows-release -DFREECAD_USE_PCH:BOOL=OFF -DFREECAD_RELEASE_PDB:BOOL=OFF -DFREECAD_USE_CCACHE:BOOL=ON + - name: Compiling sources + shell: cmd /C CALL {0} + run: > + conda\cmake.cmd --build build\release + - name: Print Ccache statistics after build + run: | + ccache -s + - name: CMake Install + shell: cmd /C CALL {0} + run: | + conda\cmake.cmd --install build\release + - name: C++ unit tests + if: false # Disabled because seems to not exist on Windows build + timeout-minutes: 1 + run: | + . build\release\test\Tests_run --gtest_output=json:${{ env.reportdir }}gtest_results.json # 2>&1 | tee -filepath ${{ env.logdir }}/unitTests.log + - name: FreeCAD CLI tests + run: | + . build\release\bin\FreeCADCmd -t 0 # 2>&1 | tee -filepath ${{ env.logdir }}/integrationTests.log + - name: Upload logs + if: always() + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifactBasename }}-Logs + path: | + ${{ env.logdir }}