Skip to content

Commit

Permalink
update test workflows and related codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
levalup committed Jul 1, 2024
1 parent 3274a3b commit 38d5537
Show file tree
Hide file tree
Showing 20 changed files with 345 additions and 122 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Multi-GCC

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
build-gcc:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
gcc_version: ['latest', '12', '11', '10', '9', '8', '7', '6', '5', '4.8.5']
build_type: [Release]

name: "In Container GCC ${{matrix.gcc_version}} ${{matrix.build_type}}"

container:
image: gcc:${{matrix.gcc_version}}

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

- uses: friendlyanon/fetch-core-count@v1
id: cores

- name: Set output
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure
run: >-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
run: >-
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config ${{ matrix.build_type }}
-- -j ${{steps.cores.outputs.count}}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}
61 changes: 61 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build MacOS

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
build-macos:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ${{matrix.os}}

strategy:
matrix:
os: [ 'macos-14.5' ]
xcode: [ '15.4' ]
build_type: [ Release ]

env:
DEVELOPER_DIR: /Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer

name: "On ${{matrix.os}} Xcode ${{matrix.xcode}} ${{matrix.build_type}}"

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

- uses: friendlyanon/fetch-core-count@v1
id: cores

- name: Set output
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure
run: >-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
run: >-
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config ${{ matrix.build_type }}
-- -j ${{steps.cores.outputs.count}}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}
74 changes: 74 additions & 0 deletions .github/workflows/build-mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build MinGW

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
build-mingw:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ${{matrix.os}}

defaults:
run:
shell: msys2 {0}

strategy:
fail-fast: false

matrix:
os: [ windows-latest ]
build_type: [ Release ]
config:
- msystem: "MINGW64"
install: >-
git mingw-w64-x86_64-cmake
mingw-w64-x86_64-gcc mingw-w64-x86_64-g++
mingw-w64-x86_64-ninja
name: "On ${{matrix.os}} ${{matrix.config.msystem}} ${{matrix.build_type}}"

env:
CMAKE_GENERATOR: 'Ninja'

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

- uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{matrix.config.msystem}}
install: ${{matrix.config.install}}

- name: Set output
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure
run: >-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
run: >-
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}
125 changes: 39 additions & 86 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,138 +4,91 @@ name: Build

on:
push:
branches: [ "master" ]
tags:
- 'r*'
branches:
- master
- develop

pull_request:
branches: [ "master" ]
branches:
- master
- develop

jobs:
build:
if: >-
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
! contains(toJSON(github.event.commits.*.message), '[skip github]')
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 4 configurations:
# 1. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
# 3. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 4. <Windows, Release, latest MinGW compiler toolchain on the default runner image, default generator>
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
c_compiler: [gcc, clang, cl]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
cmake_generator: ''
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
cmake_generator: ''
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
cmake_generator: ''
exclude:
- os: windows-latest
c_compiler: gcc
cpp_compiler: g++
cmake_generator: 'MinGW Makefiles'
exclude:
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

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

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install MinGW (Windows)
if: matrix.os == 'windows-latest' && matrix.cmake_generator == 'MinGW Makefiles'
run: |
choco install mingw --force -y
echo "C:\tools\mingw64\bin" >> $GITHUB_PATH
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
if: matrix.cmake_generator == ''
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Configure CMake With Generator
if: matrix.cmake_generator != ''
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-G "${{ matrix.cmake_generator }}"
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}

build-gcc:
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
gcc_version: [9, 10, 11, 12]
build_type: [Release]
name: "On ${{matrix.os}} ${{matrix.c_compiler}} ${{matrix.build_type}}"

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

- name: Set reusable strings
- uses: friendlyanon/fetch-core-count@v1
id: cores

- name: Set output
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install GCC ${{ matrix.gcc_version }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-${{ matrix.gcc_version }} g++-${{ matrix.gcc_version }}
- name: Configure CMake
- name: Configure
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=g++-${{ matrix.gcc_version }}
-DCMAKE_C_COMPILER=gcc-${{ matrix.gcc_version }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: >-
cmake --build ${{ steps.strings.outputs.build-output-dir }}
--config ${{ matrix.build_type }}
-- -j ${{steps.cores.outputs.count}}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ matrix.build_type }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --output-on-failure --build-config ${{ matrix.build_type }}
Loading

0 comments on commit 38d5537

Please sign in to comment.