swig/.github/workflows/ci.yml
Vadim Zeitlin dbb85de9cd 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.
2021-09-30 17:39:23 +02:00

128 lines
4.6 KiB
YAML

name: CI
on:
push:
branches: master
paths-ignore:
- 'CHANGES*'
- 'Doc/**'
pull_request:
branches: master
paths-ignore:
- 'CHANGES*'
- 'Doc/**'
jobs:
build:
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:
# other variables to optionally set
# CC, GCC (used as suffix)
# CPP11, CPP14, CPP17
# CONFIGOPTS
# SWIGLANG
# PY3,VER
# SWIG_FEATURES
include:
- CPP11: 1
SWIGLANG: ""
- CPP11: 1
SWIGLANG: python
- CPP11: 1
SWIGLANG: python
PY3: 3
- CPP11: 1
SWIGLANG: tcl
# let's run all of them, as opposed to aborting when one fails
fail-fast: false
env:
SWIGLANG: ${{ matrix.SWIGLANG }}
SWIG_FEATURES: ${{ matrix.SWIG_FEATURES }}
CONFIGOPTS: ${{ matrix.CONFIGOPTS }}
CC: ${{ matrix.CC }}
CSTD: ${{ matrix.CSTD }}
CPP11: ${{ matrix.CPP11 }}
CPP14: ${{ matrix.CPP14 }}
CPP17: ${{ matrix.CPP17 }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install CCache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.os || 'ubuntu-20.04' }}-${{ matrix.CC || 'gcc' }}${{ matrix.GCC }}
- name: Configure
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
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
if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi
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
working-directory: build/build
run: |
set -x
make $SWIGJOBS
./swig -version && ./swig -pcreversion
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 install && swig -version && ccache-swig -V; fi
- name: Test
working-directory: build/build
run: |
set -x
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
# 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 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
- name: Clean
working-directory: build/build
run: |
set -x
make check-maintainer-clean && ../../configure $CONFIGOPTS