|
| 1 | +name: C coverage |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run this daily at 2400 UTC |
| 6 | + - cron: '0 0 * * *' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + c-coverage: |
| 13 | + name: 'C-level coverage (using llvm-cov)' |
| 14 | + runs-on: ubuntu-20.04 |
| 15 | + env: |
| 16 | + OPENSSL_VER: 1.1.1n |
| 17 | + PYTHONSTRICTEXTENSIONBUILD: 1 |
| 18 | + steps: |
| 19 | + - name: Install Dependencies |
| 20 | + run: | |
| 21 | + sudo ./.github/workflows/posix-deps-apt.sh |
| 22 | + - name: Configure OpenSSL env vars |
| 23 | + run: | |
| 24 | + echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV |
| 25 | + echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV |
| 26 | + echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV |
| 27 | + - name: 'Restore OpenSSL build' |
| 28 | + id: cache-openssl |
| 29 | + uses: actions/cache@v3 |
| 30 | + with: |
| 31 | + path: ./multissl/openssl/${{ env.OPENSSL_VER }} |
| 32 | + key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }} |
| 33 | + - name: Install OpenSSL |
| 34 | + if: steps.cache-openssl.outputs.cache-hit != 'true' |
| 35 | + run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux |
| 36 | + - name: Add ccache to PATH |
| 37 | + run: | |
| 38 | + echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV |
| 39 | + - name: Configure ccache action |
| 40 | + uses: hendrikmuhs/ccache-action@v1 |
| 41 | + - name: Configure clang (with coverage) |
| 42 | + run: | |
| 43 | + echo "CC=/usr/lib/ccache/clang-12 -fprofile-instr-generate -fcoverage-mapping" >> $GITHUB_ENV |
| 44 | + echo "CXX=/usr/lib/ccache/clang++-12 -fprofile-instr-generate -fcoverage-mapping" >> $GITHUB_ENV |
| 45 | + - name: Configure CPython |
| 46 | + run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR |
| 47 | + - name: Build CPython |
| 48 | + run: make -j4 |
| 49 | + - name: Collect coverage data |
| 50 | + # Specify the LLVM_PROFILE_FILE using %m so multiple shared objects can write |
| 51 | + # in parallel. Set the full path to the directory so results aren't written |
| 52 | + # into temporary directories created by tests. |
| 53 | + # Using "-j 1" is important, or the Github Action runs out of memory |
| 54 | + run: LLVM_PROFILE_FILE=${PWD}/python%m.profraw xvfb-run ./python -m test -j 1 |
| 55 | + - name: Generate coverage report |
| 56 | + run: | |
| 57 | + llvm-profdata-12 merge -sparse python*.profraw -o python.profdata |
| 58 | + llvm-cov-12 show -format=html -output-dir=cpython-coverage -instr-profile=python.profdata -show-branches=count -show-regions python . |
| 59 | + - name: Publish coverage-report |
| 60 | + uses: JamesIves/github-pages-deploy-action@v4 |
| 61 | + with: |
| 62 | + folder: cpython-coverage |
| 63 | + repository-name: '' # TODO Destination |
| 64 | + token: ${{ secrets.COVERAGE_DEPLOY_TOKEN }} # TODO: Use an organization-level token |
| 65 | + single-commit: true |
0 commit comments