From 0d490ca545edcbf3d6189971a0a404e406d6d64a Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 22 Jan 2024 11:34:02 +0800 Subject: [PATCH] github/workflow: add a github workflow for running tests before this change, contributor is required to sign on CircleCI for triggering the tests for his/her pull request, but not all contributrs register this service. after this change, contributors are able to run tests as long as the pull request is created on GitHub, Signed-off-by: Kefu Chai --- .github/workflows/tests.yaml | 88 ++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000000..253c9d7eb24 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,88 @@ +name: Test + +permissions: + contents: read + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + test: + name: "Tests (${{ matrix.compiler }}, C++${{ matrix.standard}}, ${{ matrix.mode }}, ${{ matrix.enables }})" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # only the compilers supported by setup-cpp + compiler: [clang++-18, gcc-13] + standard: [20, 23] + mode: [dev, debug, release] + include: + # in addition to the above combinations, add a combination to build with + # dpdk. but only build this combination when dpdk is enabled, so we don't + # double the size of the test matrix, and can at least test the build + # with dpdk enabled. + - compiler: clang++-18 + standard: 23 + mode: release + cooks: --cook dpdk + enables: --enable-dpdk + # in addition to the above combinations, add a combination to build with + # C++20 modules. but only build this combination with C++20 modules enabled, + # so we don't double the size of the test matrix, and can at least test the + # build with C++20 modules enabled. + - compiler: clang++-18 + standard: 23 + mode: debug + enables: --enable-cxx-modules + steps: + - uses: actions/checkout@v4 + with: + submodules: "${{ contains(matrix.cooks, 'dpdk') }}" + + - name: Install build dependencies + run: | + sudo ./install-dependencies.sh + + - name: Install ${{ matrix.compiler }} + uses: aminya/setup-cpp@master + with: + compiler: ${{ matrix.compiler }} + ccache: true + # the latest cmake and ninja are required for building C++ modules + cmake: "${{ contains(matrix.enables, 'cxx-modules') }}" + ninja: "${{ contains(matrix.enables, 'cxx-modules') }}" + + - name: Setup ccache + uses: hendrikmuhs/ccache-action@v1 + with: + key: ${{ matrix.compiler }}-${{ matrix.standard }}-${{ matrix.mode }} + + - name: Configure + run: > + ./configure.py + --ccache + --c++-standard ${{ matrix.standard }} + --compiler $CXX + --c-compiler $CC + --mode ${{ matrix.mode }} + ${{ matrix.cooks }} + ${{ matrix.enables }} ; + + - name: Build + run: cmake --build build/${{matrix.mode}} + + - name: Check Header + if: ${{ matrix.mode == 'dev' && matrix.compiler == 'clang++-18' }} + run: cmake --build build/${{ matrix.mode }} --target checkheaders + + - name: Build with C++20 modules + if: ${{ contains(matrix.enables, 'cxx-modules') }} + run: cmake --build build/${{ matrix.mode }} --target hello_cxx_module + + - name: Test + if: ${{ ! contains(matrix.enables, 'cxx-modules') }} + run: ./test.py --mode=${{ matrix.mode }}