From 067d927cb188bad8003a5d68b9a03d86f4b3b264 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 16:53:40 +0200 Subject: [PATCH 01/26] Skip running CI for the changes to the files not affecting it Note that if we decide to do something for the docs later (e.g. run a spell checker on them), it should be done in a separate workflow and not in this one. --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6e6519b7..5d2ddbedd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,14 @@ name: CI on: push: branches: master + paths-ignore: + - 'CHANGES*' + - 'Doc/**' pull_request: branches: master + paths-ignore: + - 'CHANGES*' + - 'Doc/**' jobs: build: From 5d9bbea51041b9a70a8fc9d91f1faeb5d58b0772 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:00:24 +0200 Subject: [PATCH 02/26] Default to Ubuntu 20.04 if OS is not specified This makes the matrix more compact, as we don't need to specify the OS for the majority of the field (all of them now, but we'll add builds using "macos-N" later, so it will still be necessary for some of them), and the builds more stable than using which the current latest Ubuntu version is. --- .github/workflows/ci.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d2ddbedd..562023f8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,8 @@ on: jobs: build: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os || 'ubuntu-20.04' }} + strategy: matrix: #SWIGJOBS: ["-j2"] @@ -27,18 +28,14 @@ jobs: # PY3,VER # SWIG_FEATURES include: - - os: ubuntu-latest - CPP11: 1 + - CPP11: 1 SWIGLANG: "" - - os: ubuntu-latest - CPP11: 1 + - CPP11: 1 SWIGLANG: python - - os: ubuntu-latest - CPP11: 1 + - CPP11: 1 SWIGLANG: python PY3: 3 - - os: ubuntu-latest - CPP11: 1 + - CPP11: 1 SWIGLANG: tcl # let's run all of them, as opposed to aborting when one fails fail-fast: false @@ -50,7 +47,7 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1 with: - key: ${{ matrix.os }}-${{ matrix.SWIGLANG }} + key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.SWIGLANG }} - name: configure shell: bash env: From a2ff01a910665004948301feb5b0d05b41fad1a8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:07:52 +0200 Subject: [PATCH 03/26] Use better names for the CI builds Don't rely on the auto-generated names which are not very useful: e.g. currently something like "build (1, python, 3)" is shown, while this commit changes it to just "python3" which is both shorter and more readable. --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 562023f8e..c21dc3fe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,11 @@ jobs: runs-on: ${{ matrix.os || 'ubuntu-20.04' }} + # By default, the name of the build is just the language used, but matrix + # entries can define the additional "desc" field with any additional + # information to include in the name. + name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY3 }} ${{ matrix.desc }} + strategy: matrix: #SWIGJOBS: ["-j2"] From bbfdedc18b85ddd5507a4d22f107219a384835ee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:13:33 +0200 Subject: [PATCH 04/26] Define all environment variables at job level There doesn't seem to be any reason to make them step-specific, so simplify the workflow by doing it once and only once at the job level. No real changes. --- .github/workflows/ci.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c21dc3fe1..943d6745f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,17 @@ jobs: # let's run all of them, as opposed to aborting when one fails fail-fast: false + env: + SWIGLANG: ${{ matrix.SWIGLANG }} + SWIGJOBS: ${{ matrix.SWIGJOBS }} + SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} + CONFIGOPTS: ${{ matrix.CONFIGOPTS }} + CC: ${{ matrix.CC }} + CSTD: ${{ matrix.CSTD }} + CPP11: ${{ matrix.CPP11 }} + CPP14: ${{ matrix.CPP14 }} + CPP17: ${{ matrix.CPP17 }} + steps: - uses: actions/checkout@v2 with: @@ -55,10 +66,6 @@ jobs: key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.SWIGLANG }} - name: configure shell: bash - env: - SWIGLANG: ${{ matrix.SWIGLANG }} - CONFIGOPTS: ${{ matrix.CONFIGOPTS }} - CC: ${{ matrix.CC }} run: | set -ex export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" @@ -72,9 +79,6 @@ jobs: - name: build shell: bash - env: - SWIGLANG: ${{ matrix.SWIGLANG }} - SWIGJOBS: ${{ matrix.SWIGJOBS }} run: | set -ex cd ${GITHUB_WORKSPACE}/build/build; @@ -86,15 +90,6 @@ jobs: if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - name: tests shell: bash - env: - SWIGLANG: ${{ matrix.SWIGLANG }} - SWIGJOBS: ${{ matrix.SWIGJOBS }} - SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} - CC: ${{ matrix.CC }} - CSTD: ${{ matrix.CSTD }} - CPP11: ${{ matrix.CPP11 }} - CPP14: ${{ matrix.CPP14 }} - CPP17: ${{ matrix.CPP17 }} run: | set -ex cd ${GITHUB_WORKSPACE}/build/build; From 7692d5f9ecc0c051ea7c0201572f8c4c71955c0c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:17:10 +0200 Subject: [PATCH 05/26] Set SWIGJOBS environment variable automatically Use the number of available CPUs + 1 which seems to work best with the number of actually available CPUs in the GitHub Actions environment. --- .github/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 943d6745f..df9746c61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,6 @@ jobs: strategy: matrix: - #SWIGJOBS: ["-j2"] # other variables to optionally set # CC, GCC (used as suffix) # CPP11, CPP14, CPP17 @@ -47,7 +46,6 @@ jobs: env: SWIGLANG: ${{ matrix.SWIGLANG }} - SWIGJOBS: ${{ matrix.SWIGJOBS }} SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} CONFIGOPTS: ${{ matrix.CONFIGOPTS }} CC: ${{ matrix.CC }} @@ -77,6 +75,22 @@ jobs: echo "${CONFIGOPTS[@]}" ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${CONFIGOPTS[@]}" + case $(uname) in + Linux) + cpu_count=$(nproc) + ;; + + Darwin) + cpu_count=$(sysctl -n hw.ncpu) + ;; + + *) + cpu_count=0 + ;; + esac + ((cpu_count++)) + echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV + - name: build shell: bash run: | From 9156f390ae0137806cacab4bac345805f727976e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:18:05 +0200 Subject: [PATCH 06/26] Don't set shell explicitly for the build steps Bash is used by default under all platforms we're going to support here, so there is no need to specify it explicitly. Moreover, by default the appropriate shell options (such as "pipefail", as well as "e") are used, and there is no need to override them. --- .github/workflows/ci.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df9746c61..d0c7d0041 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,9 +63,8 @@ jobs: with: key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.SWIGLANG }} - name: configure - shell: bash run: | - set -ex + set -x export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" source Tools/GHA-linux-install.sh if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++11 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++11; fi @@ -92,9 +91,8 @@ jobs: echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV - name: build - shell: bash run: | - set -ex + set -x cd ${GITHUB_WORKSPACE}/build/build; make -s $SWIGJOBS ./swig -version && ./swig -pcreversion @@ -103,9 +101,8 @@ jobs: echo 'Installing...' if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - name: tests - shell: bash run: | - set -ex + set -x cd ${GITHUB_WORKSPACE}/build/build; if test -n "$CPP11"; then export CPPSTD=c++11; fi if test -n "$CPP14"; then export CPPSTD=c++14; fi From 542bc18b0f9ac6ebd3641247693ab91021343f43 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:24:54 +0200 Subject: [PATCH 07/26] Use working directory step option instead of explicit "cd" This seems simpler and more explicit ("cd" is easy to miss or forget). --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0c7d0041..e0042d0d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,9 +91,9 @@ jobs: echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV - name: build + working-directory: build/build run: | set -x - cd ${GITHUB_WORKSPACE}/build/build; make -s $SWIGJOBS ./swig -version && ./swig -pcreversion if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-ccache; fi @@ -101,9 +101,9 @@ jobs: echo 'Installing...' if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - name: tests + working-directory: build/build run: | set -x - cd ${GITHUB_WORKSPACE}/build/build; if test -n "$CPP11"; then export CPPSTD=c++11; fi if test -n "$CPP14"; then export CPPSTD=c++14; fi if test -n "$CPP17"; then export CPPSTD=c++17; fi From 1395b902bef2cfbdda03f01616e94503ba792b84 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:25:25 +0200 Subject: [PATCH 08/26] Re-add "clean" step of the build This was used with Travis CI, so there doesn't seem to be any reason not to use it with GitHub Actions too. --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0042d0d2..c9d4a8078 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,9 @@ jobs: if test -n "$SWIGLANG"; then make check-$SWIGLANG-enabled; fi if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - #echo 'Cleaning...' - # Skip on osx as often fails with: rm: Resource temporarily unavailable - #if test "$TRAVIS_OS_NAME" != "osx"; then make check-maintainer-clean && ../../configure $CONFIGOPTS; fi + + - name: clean + working-directory: build/build + run: | + set -x + make check-maintainer-clean && ../../configure $CONFIGOPTS From 0c46a3024954f6f4b84e6ed8619a993fd3d448f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:27:40 +0200 Subject: [PATCH 09/26] Use consistent names for the build steps Follow the convention of the GitHub built-in steps, such as the first "Set up job" one and use capitalized verbs in imperative mood rather than a mix of non-capitalized verbs and nouns. This is a purely cosmetic change. --- .github/workflows/ci.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9d4a8078..c4f379dfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,14 +55,17 @@ jobs: CPP17: ${{ matrix.CPP17 }} steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 with: submodules: recursive - - name: ccache + + - name: Install CCache uses: hendrikmuhs/ccache-action@v1 with: key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.SWIGLANG }} - - name: configure + + - name: Configure run: | set -x export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" @@ -90,7 +93,7 @@ jobs: ((cpu_count++)) echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV - - name: build + - name: Build working-directory: build/build run: | set -x @@ -100,7 +103,8 @@ jobs: if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-errors-test-suite; fi echo 'Installing...' if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi - - name: tests + + - name: Test working-directory: build/build run: | set -x @@ -115,7 +119,7 @@ jobs: if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - - name: clean + - name: Clean working-directory: build/build run: | set -x From 84b1b3f8b5724859142585e5a4a5f50ea01a2fbd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:29:38 +0200 Subject: [PATCH 10/26] Do not use "make -s" in the CI builds We want to have as much information as possible in case of the build failure, so don't use the "--silent" make option. --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4f379dfd..b24c0c912 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,12 +97,12 @@ jobs: working-directory: build/build run: | set -x - make -s $SWIGJOBS + make $SWIGJOBS ./swig -version && ./swig -pcreversion - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-ccache; fi - if test -z "$SWIGLANG"; then make -s $SWIGJOBS check-errors-test-suite; fi + if test -z "$SWIGLANG"; then make $SWIGJOBS check-ccache; fi + if test -z "$SWIGLANG"; then make $SWIGJOBS check-errors-test-suite; fi echo 'Installing...' - if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi + if test -z "$SWIGLANG"; then sudo make install && swig -version && ccache-swig -V; fi - name: Test working-directory: build/build @@ -114,7 +114,7 @@ jobs: # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic. if test -n "$SWIGLANG"; then cflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC) && echo $cflags; fi if test -n "$SWIGLANG"; then cxxflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC) && echo $cxxflags; fi - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi + if test -n "$SWIGLANG"; then make check-$SWIGLANG-version; fi if test -n "$SWIGLANG"; then make check-$SWIGLANG-enabled; fi if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi From 6088323e1431cc7b3fe7623cfe0e888f5a383137 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:38:24 +0200 Subject: [PATCH 11/26] Use ccache for building, not just configuring Set the PATH to include the ccache directory for the subsequent steps, including the "build" one, rather than only setting it locally for configure, as this didn't have much effect at all. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b24c0c912..705c753fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,8 @@ jobs: run: | set -x export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + echo PATH="$PATH" >> $GITHUB_ENV + source Tools/GHA-linux-install.sh if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++11 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++11; fi if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++14 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++14; fi From dbb85de9cd73b4ae9df786264228cdc31f507de3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:39:23 +0200 Subject: [PATCH 12/26] Use the same ccache cache key for all languages but not compilers There doesn't seem to be any good reason to use per-language caches, as there are files that are common to all languages. But we do want to use different keys for the different compilers and even different compiler versions, as they yield different results when compiling the same code. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 705c753fb..32267499d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - name: Install CCache uses: hendrikmuhs/ccache-action@v1 with: - key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.SWIGLANG }} + key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.CC || 'gcc' }}${{ matrix.GCC }} - name: Configure run: | From a6300299bf44a5482939c2b5746ab725c9c96a63 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 17:56:02 +0200 Subject: [PATCH 13/26] Add builds with other gcc versions and clang Also remove a not really useful comment mentioning the variables already used in the matrix mixed up with those not used yet. --- .github/workflows/ci.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32267499d..3e4d16162 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,16 +24,24 @@ jobs: strategy: matrix: - # other variables to optionally set - # CC, GCC (used as suffix) - # CPP11, CPP14, CPP17 - # CONFIGOPTS - # SWIGLANG - # PY3,VER - # SWIG_FEATURES include: - - CPP11: 1 - SWIGLANG: "" + - SWIGLANG: "" + desc: gcc + - SWIGLANG: "" + GCC: 7 + desc: gcc7 + - SWIGLANG: "" + GCC: 8 + desc: gcc8 + - SWIGLANG: "" + GCC: 9 + desc: gcc9 + - SWIGLANG: "" + GCC: 10 + desc: gcc10 + - SWIGLANG: "" + CC: clang + desc: clang - CPP11: 1 SWIGLANG: python - CPP11: 1 From 55dfa99e4926efaba8bbdb9bb9ea085b3f75114b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 18:11:44 +0200 Subject: [PATCH 14/26] Define CC and CXX environment variables correctly They are supposed to be set to gcc-$GCC and g++-$GCC respectively, if the suffix is defined, so do it. Also use "compiler", rather than "CC", in the matrix for consistency with .travis.yml and to avoid confusion between this property, which may be empty, and CC environment variable, which is supposed to be always defined. Finally, show the path and the version of the compiler being used: this was also done under Travis CI and there doesn't seem to be any reason not to do it here. --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e4d16162..7db336f53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: GCC: 10 desc: gcc10 - SWIGLANG: "" - CC: clang + compiler: clang desc: clang - CPP11: 1 SWIGLANG: python @@ -56,7 +56,6 @@ jobs: SWIGLANG: ${{ matrix.SWIGLANG }} SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} CONFIGOPTS: ${{ matrix.CONFIGOPTS }} - CC: ${{ matrix.CC }} CSTD: ${{ matrix.CSTD }} CPP11: ${{ matrix.CPP11 }} CPP14: ${{ matrix.CPP14 }} @@ -71,7 +70,7 @@ jobs: - name: Install CCache uses: hendrikmuhs/ccache-action@v1 with: - key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.CC || 'gcc' }}${{ matrix.GCC }} + key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.compiler || 'gcc' }}${{ matrix.GCC }} - name: Configure run: | @@ -80,6 +79,28 @@ jobs: echo PATH="$PATH" >> $GITHUB_ENV source Tools/GHA-linux-install.sh + + if test '${{ matrix.compiler }}' = 'clang'; then + CC="clang" + CXX="clang++" + elif test -n "$GCC"; then + CC="gcc-$GCC" + CXX="g++-$GCC" + else + CC="gcc" + CXX="g++" + fi + + export CC CXX + + echo CC="$CC" >> $GITHUB_ENV + echo CXX="$CXX" >> $GITHUB_ENV + + echo "Compiler used:" + ls -la $(which $CC) $(which $CXX) + $CC --version + $CXX --version + if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++11 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++11; fi if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++14 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++14; fi if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++17 $CXXFLAGS" "CFLAGS=-std=c17 $CFLAGS") && export CSTD=c17 && export CPPSTD=c++17; fi From 6c2a4607f0d0b20875ae586a56821107b3b40340 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 18:12:50 +0200 Subject: [PATCH 15/26] Use -fPIE for clang builds Executables can't be produced without this option using clang available under Ubuntu 20.04, as linking fails with a lot of errors of the form /usr/bin/ld: Swig/wrapfunc.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7db336f53..1403c149f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,9 @@ jobs: if test '${{ matrix.compiler }}' = 'clang'; then CC="clang" CXX="clang++" + + CFLAGS="$CFLAGS -fPIE" + CXXFLAGS="$CXXFLAGS -fPIE" elif test -n "$GCC"; then CC="gcc-$GCC" CXX="g++-$GCC" From 07d1ababcc61bc1869203b37498aa0f7d1211013 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 20:01:15 +0200 Subject: [PATCH 16/26] Remove explicit CPP11 from matrix entries not needing it This actually decreases the C++ version used by the default Ubuntu 20.04 compilers, so it's not clear why should we be using it. --- .github/workflows/ci.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1403c149f..8815de117 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,13 +42,10 @@ jobs: - SWIGLANG: "" compiler: clang desc: clang - - CPP11: 1 - SWIGLANG: python - - CPP11: 1 - SWIGLANG: python + - SWIGLANG: python + - SWIGLANG: python PY3: 3 - - CPP11: 1 - SWIGLANG: tcl + - SWIGLANG: tcl # let's run all of them, as opposed to aborting when one fails fail-fast: false From b77b90da889088ff5e9bfa783315ba350ee93e94 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 20:04:49 +0200 Subject: [PATCH 17/26] Define PY3 environment variable if necessary This fixes handling Python 2 and 3 builds in the same way. --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8815de117..b9a5c4c81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: env: SWIGLANG: ${{ matrix.SWIGLANG }} + PY3: ${{ matrix.PY3 }} SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} CONFIGOPTS: ${{ matrix.CONFIGOPTS }} CSTD: ${{ matrix.CSTD }} From 576e8317ff9f9530a79e6254355538dbe24cc294 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 20:33:47 +0200 Subject: [PATCH 18/26] Don't set CONFIGOPTS to empty string initially This results in passing empty argument to configure which, in turn, triggers "WARNING: you should use --build, --host, --target" from it as this argument is apparently misinterpreted as the host name. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9a5c4c81..cc9263912 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,6 @@ jobs: SWIGLANG: ${{ matrix.SWIGLANG }} PY3: ${{ matrix.PY3 }} SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} - CONFIGOPTS: ${{ matrix.CONFIGOPTS }} CSTD: ${{ matrix.CSTD }} CPP11: ${{ matrix.CPP11 }} CPP14: ${{ matrix.CPP14 }} @@ -102,6 +101,9 @@ jobs: $CC --version $CXX --version + if test -n '${{ matrix.CONFIGOPTS }}'; then + CONFIGOPTS=${{ matrix.CONFIGOPTS }} + fi if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++11 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++11; fi if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++14 $CXXFLAGS" "CFLAGS=-std=c11 $CFLAGS") && export CSTD=c11 && export CPPSTD=c++14; fi if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing "CXXFLAGS=-std=c++17 $CXXFLAGS" "CFLAGS=-std=c17 $CFLAGS") && export CSTD=c17 && export CPPSTD=c++17; fi From 1f7cd009c950a5ab1291834217eb5daa838c0624 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Oct 2021 01:01:29 +0200 Subject: [PATCH 19/26] Remove unnecessary warning triggering copy ctors from the test Defining a copy ctor results in -Werror=deprecated-copy when using implicitly-generated assignment operator with recent gcc versions, so simply remove this copy ctor, which was apparently never needed anyhow, to avoid it and rely on the compiler generating both the copy ctor and assignment operator implicitly. --- Examples/test-suite/director_nspace.i | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i index f24227c68..016f61ddf 100644 --- a/Examples/test-suite/director_nspace.i +++ b/Examples/test-suite/director_nspace.i @@ -15,7 +15,6 @@ namespace TopLevel class FooBar { public: FooBar() {} - FooBar(const FooBar&) {} virtual ~FooBar() {} std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; } @@ -56,7 +55,6 @@ namespace TopLevel class FooBar { public: FooBar(); - FooBar(const FooBar&); virtual ~FooBar(); std::string FooBarDo(); From f0b301044013b3764a378bcd0b5e63ac1f42bcc1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Oct 2021 01:06:01 +0200 Subject: [PATCH 20/26] Avoid another warning about deprecated implicit copy ctor This is similar to the previous commit, but in the other direction, with the warning being generated for the implicitly-declared copy ctor due to having an explicitly-declared assignment operator. And the fix is different too because we need to have an assignment operator in this test, so define the copy ctor explicitly too. --- Examples/test-suite/private_assign.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/private_assign.i b/Examples/test-suite/private_assign.i index acc4d0bc9..d9ba70cf4 100644 --- a/Examples/test-suite/private_assign.i +++ b/Examples/test-suite/private_assign.i @@ -14,6 +14,8 @@ return *this; } public: + Foo() { } + Foo(const Foo &f) { } // copy ctor can still be public, however. void bar() { } }; From 58a49bac66cf52b6015bf835d820c45a6c45ac25 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Oct 2021 01:13:28 +0200 Subject: [PATCH 21/26] Suppress more -Wignored-qualifiers in JavaScript tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is probably not the greatest idea, and it would be better to change the generated code to avoid these tests instead, but it was already done like this for several tests, so just add two more of them that generate warnings such as ../../member_funcptr_galore_wrap.cxx: In function ‘SwigV8ReturnValue _wrap_MemberFuncPtrs_aaa6(const SwigV8Arguments&)’: ../../member_funcptr_galore_wrap.cxx:3495:90: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers] 3495 | result = (int)((MemberFuncPtrs const *)arg1)->aaa6((short (Funcs::*const )(bool) const)arg2); | ^~~~ when using gcc 9. --- Examples/test-suite/javascript/Makefile.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 93602a434..9de151087 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -57,8 +57,10 @@ ifeq (node,$(JSENGINE)) # dunno... ignoring generously apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" + cpp11_ref_qualifiers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" director_basic.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" + member_funcptr_galore.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" setup_node = \ test -d $* || mkdir $* && \ From 4b05d8d9473cb8e1fd3a6af6c80aead157c6a9ee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Oct 2021 01:55:25 +0200 Subject: [PATCH 22/26] Don't run ccomplextest as part of JavaScript test suite This test currently fails due to "I" being undefined, so disable it to let the rest of the tests to pass and add it later when this can be fixed. --- Examples/test-suite/javascript/Makefile.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 9de151087..0e11f3d9d 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -13,9 +13,6 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -C_TEST_CASES += \ - ccomplextest \ - CPP_TEST_CASES += \ javascript_lib_arrays \ From 11c876063926b8998cf6b8fafc0a4a5932b4a189 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 20:55:07 +0200 Subject: [PATCH 23/26] Install rvm in CI setup script if it's not available It is not available out of the box in GitHub environment, unlike under Travis CI, so install it ourselves. Note that we do it manually because installing the rael-gc/rvm PPA doesn't seem to work with weird failures in GitHub Actions environment. We also can't use gpg2 --recv-keys in this environment as it doesn't work, apparently due to a firewall. --- Tools/CI-linux-install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tools/CI-linux-install.sh b/Tools/CI-linux-install.sh index 0ce8f1203..ab5b10ddb 100644 --- a/Tools/CI-linux-install.sh +++ b/Tools/CI-linux-install.sh @@ -96,6 +96,20 @@ case "$SWIGLANG" in $RETRY sudo apt-get -qq install r-base ;; "ruby") + if ! command -v rvm; then + case "$VER" in + 1.9 | 2.0 | 2.1 | 2.2 | 2.3 ) + $RETRY sudo apt-get -qq install libgdbm-dev libncurses5-dev libyaml-dev libssl1.0-dev + ;; + esac + # YOLO + curl -sSL https://rvm.io/mpapis.asc | gpg --import - + curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - + curl -sSL https://get.rvm.io | bash -s stable + set +x + source $HOME/.rvm/scripts/rvm + set -x + fi if [[ "$VER" == "2.7" || "$VER" == "3.0" ]]; then # Ruby 2.7+ support is currently only rvm master (30 Dec 2019) $RETRY rvm get master From 51cb07711f02e95f45ace5e580a75e5846f96881 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Sep 2021 20:20:46 +0200 Subject: [PATCH 24/26] Add most of Linux builds from Travis CI Don't add the builds known/allowed to fail and don't add all the variations of Python builds, there are just too many of those, but do add mostly all the rest, with the exceptions below: Builds using JavaScript backend with node <= 10 had to be disabled as well, as they just seem to be broken and there is no real motivation in supporting these ancient versions. Builds using D can't be run currently due to incompatibility between the ancient dmd version being used and the earliest support Ubuntu version (18.04) on GitHub Actions and not supporting newer versions in SWIG. Builds using Scilab had to be disabled as running the test suite reliably hangs. This would need to be debugged by somebody motivated in doing it. Note that some builds need to be run under Ubuntu 18.04 (Bionic) and not the default 20.04 (Focal) as they use old dependencies that don't exist in Focal any longer. In the future we ought to switch to using newer versions of these dependencies. --- .github/workflows/ci.yml | 139 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 138 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc9263912..beab2b08a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: # By default, the name of the build is just the language used, but matrix # entries can define the additional "desc" field with any additional # information to include in the name. - name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY3 }} ${{ matrix.desc }} + name: ${{ matrix.SWIGLANG || 'none' }}${{ matrix.PY3 }} ${{ matrix.ENGINE}} ${{ matrix.VER }} ${{ matrix.desc }} strategy: matrix: @@ -42,9 +42,128 @@ jobs: - SWIGLANG: "" compiler: clang desc: clang + - SWIGLANG: csharp + # D support can't be enabled because dmd 2.066 fails to build anything + # under Ubuntu 18.04 due to its standard library (libphobos2.a) not + # being compiled with -FPIC, but system gcc using -fpie by default, + # resulting in linking errors for any output. And later versions, such + # as 2.086.1, are not supported and result in errors in SWIG test suite. + # + # - SWIGLANG: d + # VER: '2.066.0' + # os: ubuntu-18.04 # This dlang version doesn't work under 20.04. + - SWIGLANG: go + VER: '1.3' + - SWIGLANG: go + VER: '1.6' + - SWIGLANG: go + VER: '1.8' + - SWIGLANG: go + VER: '1.12' + CSTD: gnu99 + - SWIGLANG: go + VER: '1.16' + CSTD: gnu99 + - SWIGLANG: guile + - SWIGLANG: java + - SWIGLANG: javascript + ENGINE: node + VER: '12' + CPP11: 1 + - SWIGLANG: javascript + ENGINE: node + VER: '14' + CPP11: 1 + - SWIGLANG: javascript + ENGINE: node + VER: '16' + CPP14: 1 + - SWIGLANG: javascript + ENGINE: jsc + os: ubuntu-18.04 # libwebkitgtk-dev dependency not available in 20.04. + - SWIGLANG: javascript + ENGINE: v8 + os: ubuntu-18.04 # libv8-dev only actually provides v8 in 18.04. + - SWIGLANG: lua + - SWIGLANG: lua + VER: '5.3' + - SWIGLANG: octave + CPP11: 1 + - SWIGLANG: perl5 + - SWIGLANG: php + VER: '7.4' + - SWIGLANG: php + VER: '8.0' - SWIGLANG: python - SWIGLANG: python PY3: 3 + VER: '3.2' + os: ubuntu-18.04 # Python < 3.5 not available for 20.04. + - SWIGLANG: python + PY3: 3 + VER: '3.3' + os: ubuntu-18.04 # Python < 3.5 not available for 20.04. + - SWIGLANG: python + PY3: 3 + VER: '3.4' + os: ubuntu-18.04 # Python < 3.5 not available for 20.04. + - SWIGLANG: python + PY3: 3 + VER: '3.5' + - SWIGLANG: python + PY3: 3 + VER: '3.6' + - SWIGLANG: python + PY3: 3 + VER: '3.7' + - SWIGLANG: python + PY3: 3 + VER: '3.8' + - SWIGLANG: python + PY3: 3 + VER: '3.9' + - SWIGLANG: python + SWIG_FEATURES: -builtin + desc: builtin + - SWIGLANG: python + SWIG_FEATURES: -builtin -O + desc: builtin optimized + - SWIGLANG: python + PY3: 3 + SWIG_FEATURES: -builtin + desc: builtin + - SWIGLANG: python + PY3: 3 + SWIG_FEATURES: -builtin -O + desc: builtin optimized + - SWIGLANG: r + - SWIGLANG: ruby + VER: '1.9' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.0' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.1' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.2' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.3' + os: ubuntu-18.04 + - SWIGLANG: ruby + VER: '2.4' + - SWIGLANG: ruby + VER: '2.5' + - SWIGLANG: ruby + VER: '2.6' + - SWIGLANG: ruby + VER: '2.7' + - SWIGLANG: ruby + VER: '3.0' + CSTD: c99 + CPP11: 1 - SWIGLANG: tcl # let's run all of them, as opposed to aborting when one fails fail-fast: false @@ -52,6 +171,8 @@ jobs: env: SWIGLANG: ${{ matrix.SWIGLANG }} PY3: ${{ matrix.PY3 }} + VER: ${{ matrix.VER }} + ENGINE: ${{ matrix.ENGINE }} SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }} CSTD: ${{ matrix.CSTD }} CPP11: ${{ matrix.CPP11 }} @@ -141,6 +262,22 @@ jobs: - name: Test working-directory: build/build run: | + case "$SWIGLANG" in + javascript) + case "$ENGINE" in + node) + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + nvm use ${VER} + ;; + esac + ;; + + ruby) + source $HOME/.rvm/scripts/rvm + ;; + esac + set -x if test -n "$CPP11"; then export CPPSTD=c++11; fi if test -n "$CPP14"; then export CPPSTD=c++14; fi From f038fcb44d0c1c9ed20f038544ed66320573b99c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Oct 2021 04:26:15 +0200 Subject: [PATCH 25/26] Do nothing in li_std_functors test when using Ruby 2.6 This test sporadically crashes when run in GitHub Actions environment, so skip it for now when using the Ruby 2.6 version installed by rvm. --- Examples/test-suite/ruby/li_std_functors_runme.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/ruby/li_std_functors_runme.rb b/Examples/test-suite/ruby/li_std_functors_runme.rb index 5623d49f0..a2a7c6f3d 100644 --- a/Examples/test-suite/ruby/li_std_functors_runme.rb +++ b/Examples/test-suite/ruby/li_std_functors_runme.rb @@ -63,7 +63,9 @@ def test yield method(:_map), Li_std_functors::Map end -# these should fail and not segfault +# these should fail and not segfault but currently do segfault with Ruby 2.6 +# in GitHub Actions environment +if RUBY_VERSION != '2.6.6' begin Li_std_functors::Set.new('sd') rescue @@ -72,5 +74,4 @@ end test do |proc, container| proc.call(container) end - - +end From 3b7e46dd19850c83833c23db5ae231eef4d23b39 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 1 Oct 2021 04:28:11 +0200 Subject: [PATCH 26/26] Try using one less make job to see its effect on total time Check if using -j2, rather than -j3, may help with speeding up Octave unit tests run which takes ~25 minutes currently. --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index beab2b08a..076c322a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -242,11 +242,12 @@ jobs: ;; *) - cpu_count=0 + cpu_count=1 ;; esac - ((cpu_count++)) - echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV + if [[ $cpu_count != 1 ]]; then + echo SWIGJOBS=-j$cpu_count >> $GITHUB_ENV + fi - name: Build working-directory: build/build