ci: cut GitHub Actions cost by scaling the matrices per event #1896
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| # On new commits to main: | |
| push: | |
| branches: | |
| - main | |
| # On pull requests: | |
| pull_request: | |
| branches: | |
| - main | |
| # Weekly, with the full matrix: | |
| schedule: | |
| - cron: '0 3 * * 1' | |
| workflow_dispatch: | |
| # Only keep the latest run per branch: pushing a new commit cancels the | |
| # in-flight checks for the previous one. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: true | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| # Which platforms run for this event is defined in tools/ci_matrix.json. | |
| select_matrix: | |
| name: "Select matrix" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| bazel: ${{ steps.select.outputs.bazel }} | |
| cmake: ${{ steps.select.outputs.cmake }} | |
| meson: ${{ steps.select.outputs.meson }} | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v7 | |
| - name: "Select the matrices for ${{ github.event_name }}" | |
| id: select | |
| run: ./tools/select_ci_matrix.sh >> "$GITHUB_OUTPUT" | |
| test_bazel: | |
| name: "Bazel, ${{ matrix.cxx }}, ${{ matrix.os }}" | |
| needs: select_matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.select_matrix.outputs.bazel) }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v7 | |
| - name: "Build with Bazel" | |
| env: | |
| CC: ${{ matrix.cc }} | |
| CXX: ${{ matrix.cxx }} | |
| run: bazel build ... | |
| - name: "Tests with Bazel" | |
| env: | |
| CC: ${{ matrix.cc }} | |
| CXX: ${{ matrix.cxx }} | |
| run: bazel test --test_output=all ... | |
| - name: "Bazel Smoke test" | |
| env: | |
| CC: ${{ matrix.cc }} | |
| CXX: ${{ matrix.cxx }} | |
| run: bazel build //... --enable_bzlmod --override_module=ftxui=../.. | |
| working-directory: bazel/test | |
| test_cmake: | |
| name: "CMake, ${{ matrix.compiler }}, ${{ matrix.os }}" | |
| needs: select_matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.select_matrix.outputs.cmake) }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Get number of CPU cores | |
| uses: SimenB/github-actions-cpu-cores@v3 | |
| id: cpu-cores | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v7 | |
| - name: "Setup Cpp" | |
| uses: aminya/setup-cpp@v1 | |
| with: | |
| compiler: ${{ matrix.compiler }} | |
| vcvarsall: ${{ contains(matrix.os, 'windows' )}} | |
| cmake: true | |
| ninja: true | |
| clangtidy: false | |
| cppcheck: false | |
| gcovr: "5.0" | |
| opencppcoverage: true | |
| # make sure coverage is only enabled for Debug builds, since it sets -O0 | |
| # to make sure coverage has meaningful results | |
| - name: "Configure CMake" | |
| run: > | |
| cmake -S . | |
| -B ./build | |
| -DCMAKE_BUILD_TYPE:STRING=Debug | |
| -DCMAKE_BUILD_PARALLEL_LEVEL=${{ steps.cpu-cores.outputs.count }} | |
| -DFTXUI_ENABLE_COVERAGE:BOOL=ON | |
| -DFTXUI_BUILD_DOCS:BOOL=OFF | |
| -DFTXUI_BUILD_EXAMPLES:BOOL=ON | |
| -DFTXUI_BUILD_TESTS:BOOL=ON | |
| -DFTXUI_BUILD_TESTS_FUZZER:BOOL=OFF | |
| -DFTXUI_ENABLE_INSTALL:BOOL=ON | |
| -DFTXUI_DEV_WARNINGS:BOOL=ON ; | |
| - name: "Build" | |
| run: > | |
| cmake | |
| --build ./build | |
| - name: Unix - Test | |
| if: runner.os != 'Windows' | |
| working-directory: ./build | |
| run: > | |
| ctest -C Debug --rerun-failed --output-on-failure; | |
| - name: Unix - coverage | |
| if: matrix.gcov_executable != '' | |
| working-directory: ./build | |
| run: > | |
| gcovr | |
| -j ${{env.nproc}} | |
| --delete | |
| --root ../ | |
| --exclude "../examples" | |
| --exclude ".*google.*" | |
| --exclude ".*test.*" | |
| --exclude-unreachable-branches | |
| --exclude-throw-branches | |
| --sort-uncovered | |
| --print-summary | |
| --xml-pretty | |
| --xml | |
| coverage.xml | |
| . | |
| --gcov-executable '${{ matrix.gcov_executable }}'; | |
| # OpenCppCoverage instruments every ctest child process and takes ~33 | |
| # minutes, against ~1 minute for the tests alone. Pull requests run the | |
| # tests bare; the Windows coverage report comes from the weekly full | |
| # matrix, which is the only other event scheduling a Windows job. | |
| - name: Windows - Test | |
| if: runner.os == 'Windows' && github.event_name == 'pull_request' | |
| working-directory: ./build | |
| run: > | |
| ctest -C Debug --rerun-failed --output-on-failure; | |
| - name: Windows - Test and coverage | |
| if: runner.os == 'Windows' && github.event_name != 'pull_request' | |
| working-directory: ./build | |
| run: > | |
| OpenCppCoverage.exe | |
| --export_type cobertura:coverage.xml | |
| --cover_children | |
| -- | |
| ctest -C Debug --rerun-failed --output-on-failure; | |
| - name: Publish to codecov | |
| if: runner.os != 'Windows' || github.event_name != 'pull_request' | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| flags: ${{ runner.os }} | |
| name: ${{ runner.os }}-coverage | |
| files: ./build/coverage.xml | |
| test_modules: | |
| name: "Test modules" | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| compiler: llvm | |
| # TODO add gcc / msvc | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v7 | |
| - name: "Setup Cpp" | |
| uses: aminya/setup-cpp@v1 | |
| with: | |
| compiler: ${{ matrix.compiler }} | |
| vcvarsall: ${{ contains(matrix.os, 'windows' )}} | |
| cmake: true | |
| ninja: true | |
| clangtidy: false | |
| cppcheck: false | |
| opencppcoverage: false | |
| - name: "Generate ./examples_modules" | |
| run: > | |
| ./tools/generate_examples_modules.sh | |
| - name: "Build modules" | |
| run: > | |
| mkdir build; | |
| cd build; | |
| cmake .. | |
| -DCMAKE_GENERATOR=Ninja | |
| -DFTXUI_BUILD_MODULES=ON | |
| -DFTXUI_BUILD_EXAMPLES=ON | |
| -DCMAKE_BUILD_TYPE=Debug | |
| -DFTXUI_BUILD_DOCS=OFF | |
| -DFTXUI_BUILD_TESTS=OFF | |
| -DFTXUI_BUILD_TESTS_FUZZER=OFF | |
| -DFTXUI_ENABLE_INSTALL=ON | |
| -DFTXUI_DEV_WARNINGS=ON ; | |
| cmake --build . | |
| test_umbrella_header: | |
| name: "Test umbrella header" | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| compiler: llvm | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v7 | |
| - name: "Setup Cpp" | |
| uses: aminya/setup-cpp@v1 | |
| with: | |
| compiler: ${{ matrix.compiler }} | |
| vcvarsall: ${{ contains(matrix.os, 'windows' )}} | |
| cmake: true | |
| ninja: true | |
| - name: "Generate ./examples_ftxui_hpp" | |
| run: > | |
| ./tools/generate_examples_ftxui_hpp.sh | |
| - name: "Build examples" | |
| run: > | |
| mkdir build; | |
| cd build; | |
| cmake .. | |
| -DCMAKE_GENERATOR=Ninja | |
| -DFTXUI_BUILD_EXAMPLES=ON | |
| -DCMAKE_BUILD_TYPE=Release | |
| -DFTXUI_BUILD_DOCS=OFF | |
| -DFTXUI_BUILD_TESTS=OFF | |
| -DFTXUI_BUILD_TESTS_FUZZER=OFF | |
| -DFTXUI_ENABLE_INSTALL=ON | |
| -DFTXUI_DEV_WARNINGS=ON ; | |
| cmake --build . | |
| test_meson: | |
| name: "Meson, ${{ matrix.compiler }}, ${{ matrix.os }}" | |
| needs: select_matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.select_matrix.outputs.meson) }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v7 | |
| - name: "Setup Cpp" | |
| uses: aminya/setup-cpp@v1 | |
| with: | |
| compiler: ${{ matrix.compiler }} | |
| vcvarsall: ${{ contains(matrix.os, 'windows' )}} | |
| cmake: false | |
| ninja: true | |
| - name: "Setup Python" | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: '3.x' | |
| - name: "Install Meson" | |
| run: pip install meson | |
| - name: "Configure Meson" | |
| run: meson setup build_meson -Dtests=true -Dexamples=true | |
| - name: "Build with Meson" | |
| run: ninja -C build_meson | |
| - name: "Test with Meson" | |
| run: meson test -C build_meson |