diff --git a/.codeql-prebuild-cpp-Linux.sh b/.codeql-prebuild-cpp-Linux.sh index bc947e3..56fb8f3 100644 --- a/.codeql-prebuild-cpp-Linux.sh +++ b/.codeql-prebuild-cpp-Linux.sh @@ -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 @@ -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" diff --git a/.codeql-prebuild-cpp-Windows.sh b/.codeql-prebuild-cpp-Windows.sh index 5b6dca5..c622ed4 100644 --- a/.codeql-prebuild-cpp-Windows.sh +++ b/.codeql-prebuild-cpp-Windows.sh @@ -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" diff --git a/.codeql-prebuild-cpp-macOS.sh b/.codeql-prebuild-cpp-macOS.sh index 0b48a98..9a5f596 100644 --- a/.codeql-prebuild-cpp-macOS.sh +++ b/.codeql-prebuild-cpp-macOS.sh @@ -6,7 +6,7 @@ gcc_version=11 # install dependencies brew install \ cmake \ - gcc@${gcc_version} \ + gcc@${gcc_version} # build mkdir -p build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4607212..f44146b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,16 @@ 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 @@ -28,8 +35,39 @@ jobs: 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 { @@ -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 @@ -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 @@ -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