From cc97c3762d5d6f2a8629838c8ca41a11ef0fd7c1 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Tue, 5 Apr 2022 06:30:49 -0700 Subject: [PATCH] GitHub Actions: Build and test contrib libraries This adds basic workflows to build jsonnet and pffft, to be expanded later. PiperOrigin-RevId: 439564724 Change-Id: Ia408545f8badd70b7aeeddb7a789d0d267cd0652 --- .github/workflows/ubuntu-cmake-contrib.yml | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/ubuntu-cmake-contrib.yml diff --git a/.github/workflows/ubuntu-cmake-contrib.yml b/.github/workflows/ubuntu-cmake-contrib.yml new file mode 100644 index 0000000..a224d1f --- /dev/null +++ b/.github/workflows/ubuntu-cmake-contrib.yml @@ -0,0 +1,85 @@ +name: CMake Ubuntu Contrib + +on: [push, pull_request] + +env: + BUILD_TYPE: Release + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04] + contrib: [jsonnet, pffft] + ignore-errors: [true] + include: + - compiler: clang + compiler-version: 11 + - compiler: gcc + compiler-version: 10 + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.ignore-errors }} + + steps: + - uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + key: ${{matrix.os}}-${{matrix.compiler}}${{matrix.compiler-version}} + path: | + ${{github.workspace}}/build/_deps + !${{github.workspace}}/build/_deps/${{matrix.contrib}}-*/** + + - name: Cache dependencies (contrib) + uses: actions/cache@v3 + with: + key: ${{matrix.os}}-${{matrix.compiler}}${{matrix.compiler-version}}-${{matrix.contrib}} + path: | + ${{github.workspace}}/build/_deps/${{matrix.contrib}}-*/** + + - name: Install ninja-build tool + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Install/configure Clang compiler toolchain + if: matrix.compiler == 'clang' + run: | + sudo apt-get install -qy clang-${{matrix.compiler-version}} + echo "CXX=clang++-${{matrix.compiler-version}}" >> $GITHUB_ENV + echo "CC=clang-${{matrix.compiler-version}}" >> $GITHUB_ENV + + - name: Install/configure GCC compiler toolchain + if: matrix.compiler == 'gcc' + run: | + sudo apt-get install -qy g++-${{matrix.compiler-version}} + echo "CXX=g++-${{matrix.compiler-version}}" >> $GITHUB_ENV + echo "CC=gcc-${{matrix.compiler-version}}" >> $GITHUB_ENV + + - name: Create Build Environment + run: | + pip3 install absl-py clang + cmake -E make_directory $GITHUB_WORKSPACE/build + + - name: Configure CMake + run: | + cmake \ + -S $GITHUB_WORKSPACE/contrib/${{matrix.contrib}} \ + -B $GITHUB_WORKSPACE/build \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DSAPI_ENABLE_TEST=ON \ + -DSAPI_ENABLE_EXAMPLES=ON + + - name: Build + run: | + cmake \ + --build $GITHUB_WORKSPACE/build \ + --config $BUILD_TYPE + + - name: Test + run: | + ctest \ + --test-dir $GITHUB_WORKSPACE/build \ + -C $BUILD_TYPE \ + --output-on-failure