Skip to content

optimised ci/cd pipeline with better parallel workflows #66

optimised ci/cd pipeline with better parallel workflows

optimised ci/cd pipeline with better parallel workflows #66

name: Cross-platform build
on:
push:
branches: ["main"]
paths:
- 'src/**/*.cpp'
- 'src/**/*.hpp'
- '.github/workflows/cross-platform-build.yml'
- 'CMakeLists.txt'
- 'auxiliary/test_cli.sh'
pull_request:
branches: ["main"]
paths:
- 'src/**/*.cpp'
- 'src/**/*.hpp'
- '.github/workflows/cross-platform-build.yml'
- 'CMakeLists.txt'
- 'auxiliary/test_cli.sh'
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
linux-compilation:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- arch: amd64
platform: linux/amd64
image: debian:bookworm
- arch: arm64
platform: linux/arm64
image: debian:bookworm
- arch: armhf
platform: linux/arm/v7
image: debian:bookworm
- arch: armel
platform: linux/arm/v6
image: debian:bookworm
- arch: i386
platform: linux/386
image: debian:bookworm
- arch: mips64el
platform: linux/mips64le
image: debian:bookworm
- arch: ppc64el
platform: linux/ppc64le
image: debian:bookworm
- arch: riscv64
platform: linux/riscv64
image: debian:sid
- arch: s390x
platform: linux/s390x
image: debian:bookworm
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Build (${{ matrix.arch }})
run: |
docker run --rm \
--platform ${{ matrix.platform }} \
-v ${{ github.workspace }}:/src \
-w /src \
${{ matrix.image }} \
bash -c "
apt-get update -q &&
apt-get install -y --no-install-recommends cmake g++ build-essential &&
cmake -B build -DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release
"
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: vmaware-linux-${{ matrix.arch }}
path: build/vmaware
if-no-files-found: error
retention-days: 30
macos-compilation:
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
include:
- arch: aarch64
cmake_arch: arm64
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Dev_Release \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} \
-S ${{ github.workspace }}
- name: Build
run: cmake --build build --config Release
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: vmaware-macos-${{ matrix.arch }}
path: build/vmaware
if-no-files-found: error
retention-days: 30
windows-compilation:
runs-on: windows-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
include:
- config: 64-debug
arch: x64
debug_output: ON
artifact: vmaware64_debug.exe
- config: 32-debug
arch: Win32
debug_output: ON
artifact: vmaware32_debug.exe
- config: 32-release
arch: Win32
debug_output: OFF
artifact: vmaware32_release.exe
- config: 64-release
arch: x64
debug_output: OFF
artifact: vmaware64_release.exe
steps:
- uses: actions/checkout@v4
- name: Disable Windows Defender real-time monitoring
shell: pwsh
run: Set-MpPreference -DisableRealtimeMonitoring $true
- name: Configure (${{ matrix.config }})
run: cmake -B build -G "Visual Studio 17 2022" -A ${{ matrix.arch }} -DDEBUG_OUTPUT=${{ matrix.debug_output }}
- name: Build (${{ matrix.config }})
run: cmake --build build --config Release
- name: Rename binary with commit info
shell: pwsh
run: |
$shortSha = "${{ github.sha }}".Substring(0,12)
$run = "${{ github.run_number }}"
Add-Content $env:GITHUB_ENV "SHORT_SHA=$shortSha"
Rename-Item build\Release\vmaware.exe "vmaware_${run}_${shortSha}.exe"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: build\Release\vmaware_${{ github.run_number }}_${{ env.SHORT_SHA }}.exe
cpp-standard-linux:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
std: [26, 23, 20, 17, 14, 11]
steps:
- uses: actions/checkout@v4
- name: Install g++-14
run: |
sudo apt-get update -q
sudo apt-get install -y --no-install-recommends g++-14 cmake
- name: Configure (C++${{ matrix.std }})
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=${{ matrix.std }} \
-DCMAKE_CXX_COMPILER=g++-14
- name: Build (C++${{ matrix.std }})
run: cmake --build build --config Release
cpp-standard-macos:
runs-on: macos-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
std: [26, 23, 20, 17, 14, 11]
steps:
- uses: actions/checkout@v4
- name: Configure (C++${{ matrix.std }})
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{ matrix.std }}
- name: Build (C++${{ matrix.std }})
run: cmake --build build --config Release
cpp-standard-windows:
runs-on: windows-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
std: [23, 20, 17, 14, 11]
steps:
- uses: actions/checkout@v4
- name: Configure (C++${{ matrix.std }})
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=${{ matrix.std }}
- name: Build (C++${{ matrix.std }})
run: cmake --build build --config Release
compiler-compat:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
include:
- compiler: g++-12
package: g++-12
- compiler: g++-13
package: g++-13
- compiler: g++-14
package: g++-14
- compiler: clang++-16
package: clang-16
- compiler: clang++-17
package: clang-17
- compiler: clang++-18
package: clang-18
steps:
- uses: actions/checkout@v4
- name: Install ${{ matrix.compiler }}
run: |
sudo apt-get update -q
sudo apt-get install -y --no-install-recommends cmake ${{ matrix.package }}
- name: Configure (${{ matrix.compiler }})
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }}
- name: Build (${{ matrix.compiler }})
run: cmake --build build --config Release
linux:
needs: [linux-compilation, cpp-standard-linux, compiler-compat]
runs-on: ubuntu-latest
steps:
- run: echo "Linux builds completed"
macos:
needs: [macos-compilation, cpp-standard-macos]
runs-on: ubuntu-latest
steps:
- run: echo "MacOS builds completed"
windows:
needs: [windows-compilation, cpp-standard-windows]
runs-on: ubuntu-latest
steps:
- run: echo "Windows builds completed"
cli-test:
needs: [linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download amd64 binary
uses: actions/download-artifact@v4
with:
name: vmaware-linux-amd64
path: build
- name: Run CLI test suite
run: |
chmod +x build/vmaware
bash auxiliary/test_cli.sh build/vmaware
platform-builds:
needs: [linux, macos, windows]
runs-on: ubuntu-latest
steps:
- run: echo "All platform builds completed"
completed:
needs: [platform-builds, cli-test]
runs-on: ubuntu-latest
steps:
- run: echo "All checks passed"