-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workflow to build with all available C standards
- Loading branch information
Showing
1 changed file
with
104 additions
and
0 deletions.
There are no files selected for viewing
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
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 |