Skip to content

Commit

Permalink
Update GitHub Actions workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
nealkruis committed Dec 22, 2023
1 parent 101f85a commit dfc4cff
Showing 1 changed file with 85 additions and 43 deletions.
128 changes: 85 additions & 43 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,91 @@
# Started cmake workflow: https://github.com/actions/starter-workflows/pull/47/files
name: Build and Test

name: Cmake CI
on: push

# Controls when the action will run.
# Triggers the workflow on push or pull request events
on: [push, pull_request]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
build-and-test:
strategy:
fail-fast: false
matrix:
os: [windows-latest]

# Steps represent a sequence of tasks that will be executed as part of the job
include:
- os: ubuntu
os_ver: "22.04"
config: Release
coverage: false
cc: gcc-11
cxx: g++-11
- os: ubuntu
os_ver: "20.04"
config: Release
coverage: false
cc: gcc-10
cxx: g++-10
- os: windows
os_ver: "2022"
config: Release
coverage: false
cc: cl
cxx: cl
- os: macos
os_ver: "12"
config: Release
coverage: false
cc: clang
cxx: clang++
- os: macos
os_ver: "11"
config: Release
coverage: false
cc: clang
cxx: clang++
- os: ubuntu
os_ver: "20.04"
config: Debug
coverage: true
cc: gcc-10
cxx: g++-10
defaults:
run:
shell: bash
name: ${{ matrix.os }}-${{ matrix.os_ver }} ${{ matrix.cxx }} ${{ matrix.config }} coverage=${{ matrix.coverage }}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
runs-on: ${{ matrix.os }}-${{ matrix.os_ver }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v1

# Sets up the build directory and cmake
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set Project Name
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
- name: Create Build Directory
run: cmake -E make_directory ${{github.workspace}}/build
# - name: Set coverage variables
# id: cov
# run: |
# if ${{matrix.coverage}}; then
# echo "COVERAGE=ON" >> $GITHUB_OUTPUT
# echo "STATIC_LIB=OFF" >> $GITHUB_OUTPUT
# else
# echo "COVERAGE=OFF" >> $GITHUB_OUTPUT
# echo "STATIC_LIB=ON" >> $GITHUB_OUTPUT
# fi
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="${{ matrix.config }}" -D${{ env.REPOSITORY_NAME }}_BUILD_TESTING="ON" -D${{ env.REPOSITORY_NAME }}_STATIC_LIB="${{ steps.cov.outputs.STATIC_LIB }}" -D${{ env.REPOSITORY_NAME }}_COVERAGE="${{ steps.cov.outputs.COVERAGE }}"
- name: Build
run: cmake --build build --config ${{ matrix.config }}
- name: Test
run: ctest -C ${{ matrix.config }} --output-on-failure
working-directory: build
# - name: Code Coverage Analysis
# if: "matrix.coverage"
# run: make gcov
# working-directory: build
# - name: Upload Code Coverage Report
# if: "matrix.coverage"
# uses: codecov/codecov-action@v3
# with:
# flags: integration
# functionalities: "gcov"
# move_coverage_to_trash: true

0 comments on commit dfc4cff

Please sign in to comment.