Skip to content

Testing - Refactoring GH build and test action #149

Testing - Refactoring GH build and test action

Testing - Refactoring GH build and test action #149

# This workflow builds and tests OCCT on multiple platforms (Windows, macOS, Linux with Clang, and Linux with GCC).
# It is triggered on pull requests to any branch.
# The workflow includes steps to prepare and build the project on each platform, run tests, and upload the results.
# Concurrency is set to ensure that only one instance of the workflow runs per pull request at a time.
name: Build and Test OCCT on Multiple Platforms
on:
pull_request:
branches:
- '**'
push:
branches:
- 'master'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
prepare-and-build:
strategy:
matrix:
os: [windows-2022, macos-15, ubuntu-24.04]
compiler: [msvc, clang, gcc]
exclude:
- os: macos-15
compiler: msvc
- os: ubuntu-24.04
compiler: msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Set up MSVC
if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: x64
- name: Install dependencies (Windows)
if: matrix.os == 'windows-2022'
run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip
curl -L -o mesa3d.7z https://github.com/pal1000/mesa-dist-win/releases/download/24.2.5/mesa3d-24.2.5-release-msvc.7z
7z x mesa3d.7z -omesa3d
cd mesa3d
.\systemwidedeploy.cmd 1
shell: pwsh
- name: Install dependencies (macOS)
if: matrix.os == 'macos-15'
run: |
brew update
brew install tcl-tk tbb gl2ps xerces-c libxmu libxi libxft libxpm glew freetype freeimage draco glfw
wget https://github.com/Tencent/rapidjson/archive/858451e5b7d1c56cf8f6d58f88cf958351837e53.zip -O rapidjson.zip
unzip rapidjson.zip
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake ${{ matrix.compiler }} make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev
wget https://github.com/Tencent/rapidjson/archive/858451e5b7d1c56cf8f6d58f88cf958351837e53.zip -O rapidjson.zip
unzip rapidjson.zip
- name: Configure OCCT
run: |
mkdir -p build
cd build
cmake -G "${{ matrix.cmake_generator }}" ${matrix.cmake_arch} \
-D CMAKE_C_COMPILER=${{ matrix.compiler }} \
-D CMAKE_CXX_COMPILER=${{ matrix.compiler }}++ \
-D BUILD_USE_PCH=ON \
-D BUILD_INCLUDE_SYMLINK=ON \
-D CMAKE_BUILD_TYPE=Release \
-D INSTALL_DIR=${{ github.workspace }}/install \
-D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \
-D USE_RAPIDJSON=ON \
-D USE_DRACO=ON \
-D USE_FREETYPE=ON \
-D USE_OPENGL=ON \
-D USE_FREEIMAGE=ON \
-D USE_FFMPEG=ON \
-D USE_GLES2=ON \
-D USE_OPENVR=ON \
-D USE_VTK=ON \
-D USE_TBB=ON ..
- name: Build OCCT
run: |
cd build
cmake --build . --target install --config Release -- -j
- name: Upload install directory
uses: actions/upload-artifact@v4.4.3
with:
name: install-${{ matrix.os }}-${{ matrix.compiler }}
path: install
retention-days: 7
test:
strategy:
matrix:
os: [windows-2022, macos-15, ubuntu-24.04]
compiler: [msvc, clang, gcc]
exclude:
- os: macos-15
compiler: msvc
- os: ubuntu-24.04
compiler: msvc
runs-on: ${{ matrix.os }}
needs: prepare-and-build
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
- name: Set up MSVC
if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: x64
- name: Install dependencies (Windows)
if: matrix.os == 'windows-2022'
run: |
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
Remove-Item 3rdparty-vc14-64.zip
curl -L -o mesa3d.7z https://github.com/pal1000/mesa-dist-win/releases/download/24.2.5/mesa3d-24.2.5-release-msvc.7z
7z x mesa3d.7z -omesa3d
cd mesa3d
.\systemwidedeploy.cmd 1
choco install -y vcredist2010
refreshenv
shell: pwsh
- name: Install dependencies (macOS)
if: matrix.os == 'macos-15'
run: |
brew update
brew install tcl-tk tbb gl2ps xerces-c libxmu libxi libxft libxpm glew freetype freeimage draco glfw
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake ${{ matrix.compiler }} make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev
sudo apt-get install -y xvfb mesa-utils libgl1-mesa-dri
Xvfb :99 -screen 0 1920x1080x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
- name: Download test data
run: |
cd data
wget https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_8_0/opencascade-dataset-7.8.0.tar.xz
tar -xf opencascade-dataset-7.8.0.tar.xz
- name: Download and extract install directory
uses: actions/download-artifact@v4.1.7
with:
name: install-${{ matrix.os }}-${{ matrix.compiler }}
path: install
- name: Set execute permissions on DRAWEXE
if: matrix.os != 'windows-2022'
run: chmod +x install/bin/DRAWEXE
- name: Run tests
run: |
cd install
cd bin
if [ "${{ matrix.os }}" == "windows-2022" ]; then
call env.bat ${{ matrix.compiler }} win64 release
else
source env.sh
fi
./DRAWEXE -v -c testgrid
shell: bash
env:
DISPLAY: :99
LIBGL_ALWAYS_SOFTWARE: 1
CSF_TestScriptsPath: ${{ github.workspace }}/tests
CSF_TestDataPath: ${{ github.workspace }}/data
- name: Upload test results
uses: actions/upload-artifact@v4.4.3
id: artifact-upload-step
with:
name: results-${{ matrix.os }}-${{ matrix.compiler }}
path: install/bin/results
retention-days: 15
summarize:
name: Summarize and Send PR Message
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
needs: [test]
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake gcc g++ make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev
- name: Install Xvfb and Mesa
run: |
sudo apt-get update
sudo apt-get install -y xvfb mesa-utils libgl1-mesa-dri
Xvfb :99 -screen 0 1920x1080x24 &
echo "DISPLAY=:99" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
- name: Get latest workflow run ID from target branch
id: get_run_id
run: |
workflow_name="Build and Test OCCT on Multiple Platforms"
target_branch="${{ github.event.pull_request.base.ref }}"
echo "Fetching latest run ID for workflow: $workflow_name on branch: $target_branch"
response=$(curl -s \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs?branch=$target_branch")
latest_run_id=$(echo "$response" | jq -r --arg workflow_name "$workflow_name" '.workflow_runs[] | select(.name==$workflow_name) | .id' | head -n 1)
echo "latest_run_id=$latest_run_id" >> $GITHUB_ENV
- name: Download all test results from master
uses: actions/download-artifact@v4.1.7
with:
name: results-${{ matrix.os }}-${{ matrix.compiler }}
path: install/bin/results/master/${{ matrix.os }}-${{ matrix.compiler }}
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ env.latest_run_id }}
- name: Download all test results
uses: actions/download-artifact@v4.1.7
with:
name: results-${{ matrix.os }}-${{ matrix.compiler }}
path: install/bin/results/current/${{ matrix.os }}-${{ matrix.compiler }}
- name: Run tests
run: |
echo "Comparing test results..."
cd install
cd bin
if [ "${{ matrix.os }}" == "windows-2022" ]; then
call env.bat ${{ matrix.compiler }} win64 release
else
source env.sh
fi
./DRAWEXE -v -c testdiff results/current/${{ matrix.os }}-${{ matrix.compiler }} results/master/${{ matrix.os }}-${{ matrix.compiler }}
shell: bash
env:
DISPLAY: :99
LIBGL_ALWAYS_SOFTWARE: 1
- name: Upload updated test results
uses: actions/upload-artifact@v4.4.3
with:
name: results-${{ matrix.os }}-${{ matrix.compiler }}
overwrite: true
path: install/bin/results/current/${{ matrix.os }}-${{ matrix.compiler }}
- name: Upload test compare result logs
uses: actions/upload-artifact@v4.4.3
with:
name: test-compare-results
overwrite: true
path: |
install/bin/results/current/**/diff-*.html
install/bin/results/current/**/diff-*.log
install/bin/results/current/**/summary.html
install/bin/results/current/**/tests.log