Skip to content

Commit

Permalink
add workflow to build with all available C standards
Browse files Browse the repository at this point in the history
  • Loading branch information
pmqs committed Feb 5, 2024
1 parent abd3d1a commit a6393e9
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/c-std.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: C Standard

on:
workflow_dispatch:
push:
pull_request:

jobs:
configure:
name: ${{ matrix.compiler }} + ${{ matrix.builder }} -std=${{ matrix.std }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest

compiler:
- gcc
- clang

builder:
- configure
- cmake

std:
- c89
- gnu89
# c94 is iso9899:199409 for both gcc & clang
- iso9899:199409
- c99
- gnu99
- c11
- gnu11
- c17
- gnu17
- c2x
- gnu2x

steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: 'false'

- name: Install packages (Ubuntu)
run: |
sudo apt-get update
- name: Generate project files (configure)
if: matrix.builder == 'configure'
run: |
./configure
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std }} -Werror

- name: Compile source code (configure)
if: matrix.builder == 'configure'
run: make -j2

- name: Run test cases (configure)
if: matrix.builder == 'configure'
run: |
make test
make cover
- name: Generate project files (cmake)
if: matrix.builder == 'cmake'
run: |
cmake -S . -B . -D CMAKE_BUILD_TYPE=Release -D ZLIB_BUILD_EXAMPLES=OFF
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std }} -Werror

- name: Compile source code (cmake)
if: matrix.builder == 'cmake'
run: cmake --build . --config Release

- name: Run test cases (cmake)
if: matrix.builder == 'cmake'
run: ctest -C Release --output-on-failure --max-width 120

- name: Upload build errors (configure)
uses: actions/upload-artifact@v4
if: failure() && matrix.builder == 'configure'
with:
name: ${{ matrix.compiler }} ${{ matrix.std }} (configure)
path: |
./configure.log
if-no-files-found: ignore
retention-days: 7

- name: Upload build errors (cmake)
uses: actions/upload-artifact@v4
if: failure() && matrix.builder == 'cmake'
with:
name: ${{ matrix.compiler }} ${{ matrix.std }} (cmake)
path: |
**/CMakeFiles/CMakeOutput.log
**/CMakeFiles/CMakeError.log
if-no-files-found: ignore
retention-days: 7

0 comments on commit a6393e9

Please sign in to comment.