|
| 1 | +name: Daily Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + # TODO: Remove this. This is for testing |
| 7 | + schedule: |
| 8 | + - cron: '0 6 * * *' # run at 6 AM UTC |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + pre-commit: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + fetch-depth: 2 |
| 18 | + - uses: actions/setup-python@v3 |
| 19 | + - name: Install dependencies |
| 20 | + run: | |
| 21 | + python -m pip install pre-commit |
| 22 | + python -m pip freeze --local |
| 23 | + - uses: actions/cache@v3 |
| 24 | + with: |
| 25 | + path: ~/.cache/pre-commit |
| 26 | + key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} |
| 27 | + - name: Run pre-commit checks |
| 28 | + run: pre-commit run --show-diff-on-failure --color=always --from-ref HEAD^ --to-ref HEAD |
| 29 | + shell: bash |
| 30 | + build: |
| 31 | + # The CMake configure and build commands are platform agnostic and should work equally |
| 32 | + # well on Windows or Mac. You can convert this to a matrix build if you need |
| 33 | + # cross-platform coverage. |
| 34 | + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 35 | + runs-on: ubuntu-latest |
| 36 | + strategy: |
| 37 | + matrix: |
| 38 | + include: |
| 39 | + - container: "ubuntu-dev:20" |
| 40 | + build-type: Debug |
| 41 | + compiler: {cxx: g++, c: gcc} |
| 42 | + cxx_flags: "-fprofile-arcs -ftest-coverage" |
| 43 | + timeout-minutes: 30 |
| 44 | + container: |
| 45 | + image: ghcr.io/romange/${{ matrix.container }} |
| 46 | + credentials: |
| 47 | + username: ${{ github.repository_owner }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v3 |
| 52 | + with: |
| 53 | + submodules: true |
| 54 | + - name: Install dependencies |
| 55 | + run: | |
| 56 | + uname -a |
| 57 | + cmake --version |
| 58 | + mkdir -p ${{github.workspace}}/build |
| 59 | + apt update && apt install -y lcov pip |
| 60 | + - name: Cache build deps |
| 61 | + id: cache-deps |
| 62 | + uses: actions/cache@v3 |
| 63 | + with: |
| 64 | + path: | |
| 65 | + ~/.ccache |
| 66 | + ${{github.workspace}}/build/_deps |
| 67 | + key: ${{ runner.os }}-deps-${{ github.base_ref }}-${{ github.sha }} |
| 68 | + restore-keys: | |
| 69 | + ${{ runner.os }}-deps-${{ github.base_ref }}- |
| 70 | +
|
| 71 | + - name: Configure CMake |
| 72 | + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. |
| 73 | + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type |
| 74 | + run: | |
| 75 | + pip install -r tests/dragonfly/requirements.txt |
| 76 | + cmake -B ${{github.workspace}}/build \ |
| 77 | + -DCMAKE_BUILD_TYPE=${{matrix.build-type}} \ |
| 78 | + -GNinja \ |
| 79 | + -DCMAKE_C_COMPILER="${{matrix.compiler.c}}" \ |
| 80 | + -DCMAKE_CXX_COMPILER="${{matrix.compiler.cxx}}" \ |
| 81 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 82 | + -DCMAKE_CXX_FLAGS="${{matrix.cxx_flags}}" \ |
| 83 | + -L |
| 84 | + cd ${{github.workspace}}/build && pwd |
| 85 | + du -hcs _deps/ |
| 86 | + - name: Build & Test |
| 87 | + id: cov_gen |
| 88 | + run: | |
| 89 | + # TODO: run epoll as well. |
| 90 | + cd ${{github.workspace}}/build |
| 91 | + ninja io_test |
| 92 | + ccache --show-stats |
| 93 | + ./io_test |
| 94 | + # ninja test |
| 95 | +
|
| 96 | + ls -l ${GITHUB_WORKSPACE}/ |
| 97 | + cd ${GITHUB_WORKSPACE}/tests |
| 98 | + export DRAGONFLY_PATH="${{github.workspace}}/build/dragonfly" |
| 99 | + # pytest dragonfly -k flushall |
| 100 | +
|
| 101 | + cd ${{github.workspace}}/build |
| 102 | + lcov -c -d . -o main_coverage.info |
| 103 | + lcov --remove main_coverage.info -o main_coverage.info '/usr/*' '*/_deps/*' '*/third_party/*' |
| 104 | + genhtml main_coverage.info --ignore-errors source --output-directory out -p ${{github.workspace}} |
| 105 | + tar -czf cov.tar.gz out |
| 106 | + ls -lh cov.tar.gz |
| 107 | + export covFile=`realpath cov.tar.gz` |
| 108 | +
|
| 109 | + echo "cov=$covFile" >> $GITHUB_OUTPUT |
| 110 | +
|
| 111 | + - name: Upload coverage |
| 112 | + uses: actions/upload-artifact@v3 |
| 113 | + with: |
| 114 | + name: coverage-report |
| 115 | + path: ${{ steps.cov_gen.outputs.cov }} |
| 116 | + if-no-files-found: error |
0 commit comments