Browse Source

Check compilation with different C and C++ versions in CI (#596)

Add GNU C versions and C++ standards to matrix in GitHub Actions build. However, running with pedantic is too much for both C and C++, although C++ is just couple modules. C fails in configure step with pedantic. C without GNU extensions is also not possible at this point.

For the future, pure C and -pedantic-errors would be needed to actually test the full compliance with the standards (now only the most serious errors would be caught).

GDAL requires C++11, so not much point in testing C++98 and we start with C++11. PROJ 7.0.0 requires C99, so not much reasons to check older C for the future esp. given that we need GNU extensions at this point anyway.

Performing these GCC-based C/C++ dialect/standard checks separately from Ubuntu build checks with defaults. This avoids all C/C++ std combos being tested in both Ubuntu versions thus reducing number of jobs which need to run (2D matrix instead of 3D). This now adds 6 (2x3) additional jobs instead of 10 (2x2x3-2) if it would be combined with the Ubuntu builds.

Adding also C17 as gnu17 in a comment to be enabled in the future because that's currently the new default, but it is not available in Ubuntu 18.04.

The name of the workflow is both unique (which is more than just a visual, e.g., for queries, but also in the interface) and tailored to be displayed together with job names which are as short as possible for better display.
Vaclav Petras 5 years ago
parent
commit
706e7e1aa0
1 changed files with 47 additions and 0 deletions
  1. 47 0
      .github/workflows/gcc.yml

+ 47 - 0
.github/workflows/gcc.yml

@@ -0,0 +1,47 @@
+name: GCC C/C++ standards check
+
+on:
+- push
+- pull_request
+
+jobs:
+  build:
+    name: ${{ matrix.c }} & ${{ matrix.cpp }}
+
+    runs-on: ubuntu-18.04
+    strategy:
+      matrix:
+        c:
+        - gnu99
+        - gnu11
+        # - gnu17  # not available in Ubuntu 18.04
+        cpp:
+        - c++11
+        - c++14
+        - c++17
+      fail-fast: false
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Get dependencies
+      run: |
+        sudo apt-get update -y
+        sudo apt-get install -y wget git gawk findutils
+        xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
+            sudo apt-get install -y --no-install-recommends --no-install-suggests
+    - name: Create installation directory
+      run: |
+        mkdir $HOME/install
+    - name: Ensure one core for compilation
+      run: |
+        echo "::set-env name=MAKEFLAGS::-j1"
+    - name: Set LD_LIBRARY_PATH for compilation
+      run: |
+        echo "::set-env name=LD_LIBRARY_PATH::$HOME/install/lib"
+    - name: Build
+      env:
+        # TODO: -pedantic-errors here won't go through ./configure (with GNU C)
+        CFLAGS: "-std=${{ matrix.c }}"
+        # TODO: -pedantic-errors here won't compile
+        CXXFLAGS: "-std=${{ matrix.cpp }}"
+      run: .github/workflows/build.sh $HOME/install