Skip to content

Add macOS to the pipeline #58

Add macOS to the pipeline

Add macOS to the pipeline #58

Workflow file for this run

name: C/C++ CI
on:
push:
pull_request:
branches:
- main
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: windows-latest
triplet: x64-windows
- os: ubuntu-latest
triplet: x64-linux
- os: macos-latest
triplet: x64-osx
continue-on-error: true
env:
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
steps:
- name: Set OS environment variable in lowercase letters
run: echo "CURRENT_OS=$(echo $RUNNER_OS | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
shell: bash
- name: Set up cache
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- uses: actions/checkout@v4
- name: Create vcpkg default binary cache
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
mkdir -p ${{ github.workspace }}\vcpkg\bincache
else
mkdir -p ${{ github.workspace }}/vcpkg/bincache
fi
shell: bash
- uses: lukka/get-cmake@latest
- name: Set up vcpkg
uses: lukka/run-vcpkg@v4
with:
setupOnly: true
vcpkgGitCommitId: 0affe8710a4a5b26328e909fe1ad7146df39d108
# Restore vpkg cache
- name: Restore vcpkg
uses: actions/cache@v4
with:
path: |
${{ env._VCPKG_ }}
!${{ env._VCPKG_ }}/buildtrees
!${{ env._VCPKG_ }}/packages
!${{ env._VCPKG_ }}/downloads
!${{ env._VCPKG_ }}/installed
key: |
${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}
# Ensure that the developer command promt is present on Windows runners
- uses: ilammy/msvc-dev-cmd@v1
- name: Install packages
if: runner.os == 'Linux'
run: sudo apt-get install -y libxi-dev libxtst-dev bison gperf libgles2-mesa-dev libxrandr-dev libxcursor-dev libxdamage-dev libxinerama-dev nasm
- if: runner.os == 'macOS'
run: brew install nasm
- name: Restore from cache the dependencies and generate project files
run: |
cmake -DBUILD_EXAMPLE_APP=ON -DBUILD_TESTS=ON --preset ${{ env.CURRENT_OS }}-release
- name: Build (Release configuration)
run: |
cmake --build --preset ${{ env.CURRENT_OS }}-release
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts-${{ env.CURRENT_OS }}
path: |
bin/build/${{ env.CURRENT_OS }}-release/example
bin/build/${{ env.CURRENT_OS }}-release/test/Iris.Tests
bin/build/${{ env.CURRENT_OS }}-release/test/AddressSanitizer.Tests
bin/build/${{ env.CURRENT_OS }}-release/CTestTestfile.cmake
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: windows-latest
triplet: x64-windows
- os: ubuntu-latest
triplet: x64-linux
- os: macos-latest
triplet: x64-osx
continue-on-error: true
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- name: Set environment variable in lowercase letters
run: echo "CURRENT_OS=$(echo $RUNNER_OS | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
shell: bash
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts-${{ env.CURRENT_OS }}
path: bin/build/${{ env.CURRENT_OS }}-release
- name: Set permissions
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -y libegl1-mesa && sudo chmod +x bin/build/linux-release/test/Iris.Tests/iris_tests
elif [ "$RUNNER_OS" == "macOS" ]; then
chmod 755 bin/build/macos-release/test/Iris.Tests/iris_tests
fi
shell: bash
- name: Test
run: |
ctest --preset test-${{ env.CURRENT_OS }}