add workflow to build with all available C standards #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: C Standard | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
jobs: | |
configure: | |
name: ${{ matrix.os }} + ${{ matrix.compiler }} + ${{ matrix.builder }} -std=${{ matrix.std }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-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) | |
if: matrix.os == 'ubuntu-latest' | |
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.os }} ${{ 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.os }} ${{ matrix.compiler }} ${{ matrix.std }} (cmake) | |
path: | | |
**/CMakeFiles/CMakeOutput.log | |
**/CMakeFiles/CMakeError.log | |
if-no-files-found: ignore | |
retention-days: 7 |