Skip to content

Commit

Permalink
build: use strategy matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed May 3, 2024
1 parent c2ae74a commit bda3314
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 36 deletions.
11 changes: 4 additions & 7 deletions .codeql-prebuild-cpp-Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y

sudo apt-get install -y \
build-essential \
gcc-${gcc_version} \
g++-${gcc_version} \
cmake \
ninja-build

# clean apt cache
sudo apt-get clean
Expand All @@ -20,11 +20,8 @@ sudo rm -rf /var/lib/apt/lists/*
# build
mkdir -p build
cd build || exit 1
cmake \
-DCMAKE_C_COMPILER="$(which gcc-${gcc_version})" \
-DCMAKE_CXX_COMPILER="$(which g++-${gcc_version})" \
-G "Unix Makefiles" ..
make -j"$(nproc)"
cmake -G Ninja ..
ninja

# skip autobuild
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"
5 changes: 3 additions & 2 deletions .codeql-prebuild-cpp-Windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ pacman --noconfirm -S \
make \
mingw-w64-x86_64-binutils \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-ninja \
mingw-w64-x86_64-toolchain

# build
mkdir -p build
cd build || exit 1
cmake -G "MinGW Makefiles" ..
mingw32-make -j"$(nproc)"
cmake -G Ninja ..
ninja

# skip autobuild
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"
2 changes: 1 addition & 1 deletion .codeql-prebuild-cpp-macOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gcc_version=11
# install dependencies
brew install \
cmake \
gcc@${gcc_version} \
gcc@${gcc_version}

# build
mkdir -p build
Expand Down
77 changes: 51 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,56 @@ concurrency:
cancel-in-progress: true

jobs:
build_win:
name: Windows
runs-on: windows-2019
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Build
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Dependencies Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
ninja-build
- name: Setup Dependencies macOS
if: runner.os == 'macOS'
run: |
brew install \
cmake \
ninja
- name: Setup Dependencies Windows
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
make
mingw-w64-x86_64-binutils
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
mingw-w64-x86_64-toolchain
- name: Prepare tests
id: prepare-tests
if: runner.os == 'Windows'
shell: pwsh
run: |
# function to download and extract a zip file
function DownloadAndExtract {
Expand Down Expand Up @@ -80,17 +118,6 @@ jobs:
./deviceinstaller64 enableidd 1
}
- name: Setup Dependencies Windows
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
make
mingw-w64-x86_64-binutils
mingw-w64-x86_64-cmake
mingw-w64-x86_64-toolchain
- name: Setup python
id: setup-python
uses: actions/setup-python@v5
Expand All @@ -99,28 +126,27 @@ jobs:

- name: Python Path
id: python-path
shell: msys2 {0}
run: |
# replace backslashes with double backslashes
python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g')
if [ "${{ runner.os }}" == "Windows" ]; then
# replace backslashes with double backslashes
python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g')
else
python_path="${{ steps.setup-python.outputs.python-path }}"
fi
# step output
echo "python-path=${python_path}"
echo "python-path=${python_path}" >> $GITHUB_OUTPUT
- name: Build Windows
shell: msys2 {0}
- name: Build
run: |
mkdir build
mkdir -p build
cd build
cmake \
-G "MinGW Makefiles" \
..
mingw32-make -j$(nproc)
cmake -G Ninja ..
ninja
- name: Run tests
id: test
shell: msys2 {0}
working-directory: build
run: |
./tests/test_libdisplaydevice --gtest_color=yes
Expand All @@ -129,7 +155,6 @@ jobs:
# any except canceled or skipped
if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
id: test_report
shell: msys2 {0}
working-directory: build
run: |
${{ steps.python-path.outputs.python-path }} -m pip install gcovr
Expand Down

0 comments on commit bda3314

Please sign in to comment.