Skip to content

Continuous Integration Tests #46

Continuous Integration Tests

Continuous Integration Tests #46

Workflow file for this run

# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Continuous Integration Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
schedule:
- cron: 30 15 * * *
jobs:
gtest-test:
strategy:
fail-fast: false
matrix:
platform:
- description: Ubuntu GNU
os: ubuntu-latest
toolchain: cmake/gnu-toolchain.cmake
- description: Ubuntu LLVM
os: ubuntu-latest
toolchain: cmake/llvm-toolchain.cmake
- description: Windows MSVC
os: windows-latest
toolchain: cmake/msvc-toolchain.cmake
- description: Macos Appleclang
os: macos-latest
toolchain: cmake/appleclang-toolchain.cmake
cmake_args:
- description: Default
- description: MaxSan
args: -DBEMAN_BUILDSYS_SANITIZER=MaxSan
name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cmake_args.description }}"
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4
- name: Install Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: ~3.25.0
ninjaVersion: ^1.11.1
- name: Setup MSVC
if: startsWith(matrix.platform.os, 'windows')
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Setup Macos
if: startsWith(matrix.platform.os, 'macos')
run: sudo chmod -R 777 /opt/
- name: Print installed softwares
shell: bash
run: |
echo "Build system:"
cmake --version
ninja --version
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=20 -DCMAKE_TOOLCHAIN_FILE="${{ matrix.platform.toolchain }}" ${{ matrix.cmake_args.args }}
env:
CMAKE_GENERATOR: Ninja Multi-Config
- name: Build Release
run: |
# Portable commands only
cmake --build build --config Release --parallel --verbose
cmake --install build --config Release --prefix /opt/beman.any_view
ls -R /opt/beman.any_view
- name: Test Release
run: ctest --test-dir build --build-config Release
- name: Build Debug
run: |
# Portable commands only
cmake --build build --config Debug --parallel --verbose
cmake --install build --config Debug --prefix /opt/beman.any_view
ls -R /opt/beman.any_view
- name: Test Debug
run: ctest --test-dir build --build-config Debug
configuration-test:
runs-on: ubuntu-latest
strategy:
matrix:
design:
- description: Enum Flags
arg: -DBEMAN_ANY_VIEW_DESIGN=ENUM
- description: Range Traits
arg: -DBEMAN_ANY_VIEW_DESIGN=TRAITS
- description: Named Template Arguments
arg: -DBEMAN_ANY_VIEW_DESIGN=NAMED
option_name:
- description: Copyable
arg: -DBEMAN_ANY_VIEW_OPTION=COPYABLE
- description: Move-Only
arg: -DBEMAN_ANY_VIEW_OPTION=MOVE_ONLY
name: "CMake: ${{ matrix.design.description }} design with ${{ matrix.option_name.description }} option"
steps:
- uses: actions/checkout@v4
- name: Setup build environment
uses: lukka/get-cmake@latest
with:
cmakeVersion: ~3.25.0
ninjaVersion: ^1.11.1
- name: Print installed softwares
run: |
cmake --version
ninja --version
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=20 ${{ matrix.design.arg }} ${{ matrix.option_name.arg }}
env:
CMAKE_GENERATOR: Ninja Multi-Config
- name: Build Release
run: |
# Portable commands only
cmake --build build --config Release --parallel --verbose
cmake --install build --config Release --prefix /opt/beman.any_view
ls -R /opt/beman.any_view
- name: Build Debug
run: |
# Portable commands only
cmake --build build --config Debug --parallel --verbose
cmake --install build --config Debug --prefix /opt/beman.any_view
ls -R /opt/beman.any_view
compiler-test:
runs-on: ubuntu-24.04
strategy:
matrix:
compilers:
- class: GNU
version: 14
- class: GNU
version: 13
- class: GNU
version: 12
- class: LLVM
version: 20
- class: LLVM
version: 19
- class: LLVM
version: 18
- class: LLVM
version: 17
name: "Compiler: ${{ matrix.compilers.class }} ${{ matrix.compilers.version }}"
steps:
- uses: actions/checkout@v4
- name: Setup build environment
uses: lukka/get-cmake@latest
with:
cmakeVersion: ~3.25.0
ninjaVersion: ^1.11.1
- name: Install Compiler
id: install-compiler
run: |
if [ "${{ matrix.compilers.class }}" = "GNU" ]; then
CC=gcc-${{ matrix.compilers.version }}
CXX=g++-${{ matrix.compilers.version }}
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install -y $CC
sudo apt-get install -y $CXX
$CC --version
$CXX --version
else
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo bash llvm.sh ${{ matrix.compilers.version }}
CC=clang-${{ matrix.compilers.version }}
CXX=clang++-${{ matrix.compilers.version }}
$CC --version
$CXX --version
fi
echo "CC=$CC" >> "$GITHUB_OUTPUT"
echo "CXX=$CXX" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=20
env:
CC: ${{ steps.install-compiler.outputs.CC }}
CXX: ${{ steps.install-compiler.outputs.CXX }}
CMAKE_GENERATOR: Ninja Multi-Config
- name: Build Debug
run: |
cmake --build build --config Debug --verbose
cmake --install build --config Debug --prefix /opt/beman.any_view
find /opt/beman.any_view -type f
- name: Test Debug
run: ctest --test-dir build --build-config Debug
create-issue-when-fault:
runs-on: ubuntu-latest
needs: [ gtest-test, configuration-test, compiler-test ]
if: failure() && github.event_name == 'schedule'
steps:
# See https://github.com/cli/cli/issues/5075
- uses: actions/checkout@v4
- name: Create issue
run: |
issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end')
body="**Build-and-Test Failure Report**
- **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z')
- **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
- **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
The scheduled build-and-test triggered by cron has failed.
Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error."
if [[ $issue_num -eq -1 ]]; then
gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body"
else
gh issue comment --repo ${{ github.repository }} $issue_num --body "$body"
fi
env:
GH_TOKEN: ${{ github.token }}