#97: try fix mesa on ubuntu 24 #222
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test (macos) | |
# Trigger the workflow on push or pull request | |
on: | |
push: | |
branches: | |
- 97-add-more-environments-to-test-in-ci | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
host: [ | |
{ | |
base: macos-12, | |
compiler: { cc: clang, cxx: clang++ }, | |
gcov: llvm-gcov, | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'], | |
vtk: '9.3.1' | |
}, | |
{ | |
base: macos-13, | |
compiler: { cc: clang, cxx: clang++ }, | |
gcov: llvm-gcov, | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'], | |
vtk: '9.3.1' | |
}, | |
{ | |
base: macos-14, | |
compiler: { cc: clang, cxx: clang++ }, | |
gcov: llvm-gcov, | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'], | |
vtk: '9.3.1' | |
}, | |
{ | |
base: "ubuntu-22.04", | |
compiler: { cc: gcc-11, cxx: g++-11 }, | |
gcov: gcov, | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'], | |
vtk: '9.3.0' | |
}, | |
{ | |
base: "ubuntu-24.04", | |
compiler: { cc: gcc-13, cxx: g++-13 }, | |
gcov: gcov, | |
python: ['3.8', '3.9', '3.10', '3.11', '3.12'], | |
vtk: '9.3.1' | |
} | |
] | |
runs-on: ${{ matrix.host.base }} | |
name: vt-tv build and test (${{ matrix.host.base }}-${{ matrix.host.compiler.cc }}, vtk-${{ matrix.host.vtk }}, py[${{ join(matrix.host.python, ', ') }}]) | |
env: | |
VTK_SRC_DIR: /opt/src/vtk | |
VTK_BUILD_DIR: /opt/build/vtk | |
CACHE_KEY: ${{ matrix.host.base }}-${{ matrix.host.compiler.cc }}-vtk-${{ matrix.host.vtk }} | |
VT_TV_BUILD_DIR: /opt/build/vt-tv | |
VT_TV_TESTS_ENABLED: "ON" | |
VT_TV_COVERAGE_ENABLED: ${{ matrix.host.compiler.gcov == '' && 'OFF' || 'ON' }} | |
VT_TV_OUTPUT_DIR: ${{ github.workspace }}/output | |
VT_TV_TESTS_OUTPUT_DIR: ${{ github.workspace }}/output/tests | |
VT_TV_ARTIFACTS_DIR: /tmp/artifacts | |
CONDA_PATH: /opt/miniconda # ~/miniconda3 | |
CC: ~ | |
CXX: ~ | |
GCOV: ~ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set folder permissions | |
run: | | |
sudo chown -R $(whoami) /opt | |
mkdir -p ${{ env.VTK_SRC_DIR }} ${{ env.VT_TV_BUILD_DIR }} | |
- name: Set environment variables | |
run: | | |
echo "CC=$(which ${{ matrix.host.compiler.cc }})" >> $GITHUB_ENV | |
echo "CXX=$(which ${{ matrix.host.compiler.cxx }})" >> $GITHUB_ENV | |
echo "GCOV=$(which ${{ matrix.host.gcov }})" >> $GITHUB_ENV | |
- name: Install dependencies (macOS) | |
if: ${{ runner.os == 'macOS'}} | |
run: | | |
brew update && brew install coreutils lcov xquartz | |
- name: Install dependencies (Ubuntu) | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
sudo apt-get update -y -q && \ | |
sudo apt-get install -y -q --no-install-recommends \ | |
${{ matrix.host.compiler.cc }} \ | |
${{ matrix.host.compiler.cxx }} \ | |
git \ | |
xz-utils \ | |
bzip2 \ | |
zip \ | |
gpg \ | |
wget \ | |
gpgconf \ | |
software-properties-common \ | |
libsigsegv2 \ | |
libsigsegv-dev \ | |
pkg-config \ | |
zlib1g \ | |
zlib1g-dev \ | |
m4 \ | |
gfortran-11 \ | |
make \ | |
cmake-data \ | |
cmake \ | |
pkg-config \ | |
libncurses5-dev \ | |
m4 \ | |
libgl1-mesa-dev \ | |
libglu1-mesa-dev \ | |
mesa-common-dev \ | |
libosmesa6-dev \ | |
mesa-utils \ | |
perl \ | |
curl \ | |
xvfb \ | |
lcov \ | |
&& \ | |
sudo apt-get clean && \ | |
sudo rm -rf /var/lib/apt/lists/* | |
- name: Install Latest Mesa Drivers (Ubuntu 24.04) | |
if: ${{matrix.host.base == 'ubuntu-24.04'}} | |
run: | | |
# Start virtual display (Linux) | |
DISPLAY_0=$(echo $DISPLAY) | |
if [[ $(uname -a) != *"Darwin"* ]]; then | |
bash ci/xvfb_start.sh :99 | |
export DISPLAY=:99 | |
fi | |
glxinfo | grep "OpenGL version" | |
sudo add-apt-repository ppa:oibaf/graphics-drivers -y | |
sudo apt update | |
sudo apt upgrade | |
glxinfo | grep "OpenGL version" | |
# Restore display (none) | |
if [[ $(uname -a) != *"Darwin"* ]]; then | |
bash ci/xvfb_stop.sh :99 | |
export DISPLAY=DISPLAY_0 | |
fi | |
- name: Load cache (VTK, Miniconda3) | |
id: base-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ env.VTK_SRC_DIR }} | |
${{ env.VTK_BUILD_DIR }} | |
${{ env.CONDA_PATH }} | |
~/.zshrc | |
~/.bash_profile | |
key: ${{ env.CACHE_KEY }} | |
save-always: true | |
- name: Setup Miniconda3 | |
if: ${{steps.base-cache.outputs.cache-hit != 'true'}} | |
run: | | |
mkdir -p ~/miniconda3 | |
if [[ $(uname -a) == *"Darwin"* ]]; then | |
if [[ $(arch) == 'arm64' ]]; then | |
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda.sh | |
else | |
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda.sh | |
fi | |
else | |
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o ~/miniconda.sh | |
fi | |
bash ~/miniconda.sh -b -u -p ${{ env.CONDA_PATH }} | |
rm -rf ~/miniconda.sh | |
${{ env.CONDA_PATH }}/bin/conda init bash | |
${{ env.CONDA_PATH }}/bin/conda init zsh | |
if [ -f ~/.zshrc ]; then | |
. ~/.zshrc | |
fi | |
if [ -f ~/.profile ]; then | |
. ~/.profile | |
fi | |
if [ -f ~/.bashrc ]; then | |
. ~/.bashrc | |
fi | |
echo "Conda path: $(which conda)" | |
echo "Conda version: $(conda --version)" | |
echo "> Activate base environment" | |
conda activate | |
PYTHON_VERSIONS=(`echo '${{ join(matrix.host.python) }}' | sed 's/,/\n/g'`) | |
for python_version in "${PYTHON_VERSIONS[@]}" | |
do | |
echo "::group::Create conda environment (py${python_version})" | |
conda create -y -n py${python_version} python=${python_version} | |
conda deactivate | |
. ${{ env.CONDA_PATH }}/etc/profile.d/conda.sh && conda activate py${python_version} | |
echo "Python version: $(python --version)" | |
pip install nanobind | |
echo "::endgroup::" | |
done | |
- name: Setup VTK ${{ matrix.host.vtk }} | |
if: ${{steps.base-cache.outputs.cache-hit != 'true'}} | |
run: | | |
mkdir -p ${{ env.VTK_SRC_DIR }} | |
git clone --recursive --branch v${{ matrix.host.vtk }} https://gitlab.kitware.com/vtk/vtk.git ${{ env.VTK_SRC_DIR }} | |
VTK_DIR=${{ env.VTK_BUILD_DIR }} VTK_SRC_DIR=${{ env.VTK_SRC_DIR }} bash ${{ github.workspace }}/ci/vtk_build.sh | |
- name: Build | |
run: | | |
cd ${{ github.workspace }} | |
chmod +x ./ci/build.sh | |
mkdir -p ${{ env.VT_TV_BUILD_DIR }} | |
CC="${{ env.CC }}" \ | |
CXX="${{ env.CXX }}" \ | |
VTK_DIR="${{ env.VTK_BUILD_DIR }}" \ | |
VT_TV_BUILD_DIR="${{ env.VT_TV_BUILD_DIR }}" \ | |
VT_TV_CLEAN=OFF \ | |
VT_TV_TESTS_ENABLED=${{ env.VT_TV_TESTS_ENABLED }} \ | |
VT_TV_COVERAGE_ENABLED=${{ env.VT_TV_COVERAGE_ENABLED }} \ | |
GCOV="${{ env.GCOV }}" \ | |
VT_TV_PYTHON_BINDINGS_ENABLED=OFF \ | |
VT_TV_WERROR_ENABLED=ON \ | |
./build.sh | |
- name: Test | |
run: | | |
cd ${{ github.workspace }} | |
chmod +x ./ci/test.sh | |
VTK_DIR=${{ env.VTK_BUILD_DIR }} \ | |
VT_TV_COVERAGE_ENABLED=${{ env.VT_TV_COVERAGE_ENABLED }} \ | |
VT_TV_OUTPUT_DIR="${{ env.VT_TV_OUTPUT_DIR }}" \ | |
./ci/test.sh | |
- name: Build Python package (${{ join(matrix.host.python, ', ') }}) | |
run: | | |
cd ${{ github.workspace }} | |
chmod +x ./ci/python_build.sh | |
PYTHON_VERSIONS=(`echo '${{ join(matrix.host.python) }}' | sed 's/,/\n/g'`) | |
export VTK_DIR=${{ env.VTK_BUILD_DIR }} | |
for python_version in "${PYTHON_VERSIONS[@]}" | |
do | |
echo "::group::Build Python package (${python_version})" | |
VTK_DIR=${{ env.VTK_BUILD_DIR }} \ | |
CONDA_PATH=${{ env.CONDA_PATH }} \ | |
VT_TV_CONDA_ENV=py${python_version} \ | |
./ci/python_build.sh | |
echo "::endgroup::" | |
done | |
- name: Test Python bindings (${{ join(matrix.host.python) }}) | |
run: | | |
cd ${{ github.workspace }} | |
chmod +x ./ci/python_test.sh | |
PYTHON_VERSIONS=(`echo '${{ join(matrix.host.python) }}' | sed 's/,/\n/g'`) | |
for python_version in "${PYTHON_VERSIONS[@]}" | |
do | |
echo "::group::Test Python Bindings (${python_version})" | |
CONDA_PATH=${{ env.CONDA_PATH }} \ | |
VT_TV_CONDA_ENV=py${python_version} \ | |
VT_TV_OUTPUT_DIR="${{ env.VT_TV_OUTPUT_DIR }}/python_tests" \ | |
./ci/python_test.sh | |
echo "::endgroup::" | |
done | |
- name: Collect artifacts | |
run: | | |
mkdir -p ${{ env.VT_TV_ARTIFACTS_DIR }} | |
# > go to output directory | |
pushd ${{ env.VT_TV_OUTPUT_DIR }} | |
echo "> add junit test report artifact" | |
cp "junit-report.xml" ${{ env.VT_TV_ARTIFACTS_DIR }}/ || true | |
if [[ "${{ env.VT_TV_COVERAGE_ENABLED }}" == "ON" ]]; then | |
echo "> add `coverage --list` file artifact" | |
lcov --list lcov_vt-tv_test_no_deps.info > ${{ env.VT_TV_ARTIFACTS_DIR }}/lcov-list-report.txt | |
echo "> add total lines coverage file artifact (percentage of lines covered)" | |
# might be useful for generating later a badge in ci | |
LCOV_SUMMARY=$(lcov --summary lcov_vt-tv_test_no_deps.info) | |
LCOV_TOTAL_LINES_COV=$(echo $LCOV_SUMMARY | grep -E -o 'lines......: ([0-9.]+)*' | grep -o -E '[0-9]+.[0-9]+') | |
echo $LCOV_TOTAL_LINES_COV > lcov-lines-total.txt | |
cp lcov-lines-total.txt ${{ env.VT_TV_ARTIFACTS_DIR }}/ | |
fi | |
popd | |
echo "> add tests output mesh files and png artifacts" | |
if [ -d "${{ env.VT_TV_TESTS_OUTPUT_DIR }}" ]; then | |
cp "${{ env.VT_TV_TESTS_OUTPUT_DIR }}/"*".vtp" ${{ env.VT_TV_ARTIFACTS_DIR }}/ || true | |
cp "${{ env.VT_TV_TESTS_OUTPUT_DIR }}/"*".png" ${{ env.VT_TV_ARTIFACTS_DIR }}/ || true | |
fi | |
echo "> list of collected artifacts:" | |
pushd ${{ env.VT_TV_ARTIFACTS_DIR }} | |
find ${{ env.VT_TV_ARTIFACTS_DIR }} | while read line; do echo "- $line"; done | |
popd | |
- name: Unit tests | |
if: ${{ env.VT_TV_TESTS_ENABLED == 'ON' }} | |
uses: phoenix-actions/test-reporting@v15 | |
with: | |
name: Tests report | |
path: ${{ env.VT_TV_ARTIFACTS_DIR }}/junit-report.xml | |
reporter: java-junit | |
output-to: step-summary | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: vt-tv-artifacts-${{ env.CACHE_KEY }} | |
path: ${{ env.VT_TV_ARTIFACTS_DIR }} |