ci:Python script for executable logic #276
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: Code Coverage | |
on: [workflow_call, pull_request, push ] | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write | |
env: | |
BUILD_TYPE: Debug | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache CMake files | |
id: cache-build | |
uses: actions/cache@v3 | |
with: | |
path: cmake-build-unit-tests | |
key: ${{ runner.os }}-cmake-build-unit-tests-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.cmake', '**/*.txt', '**/*.c', '**/*.s') }} | |
- name: sccache cache backup from cache | |
uses: actions/cache@v3 | |
with: | |
path: sccache_backup | |
key: ${{ runner.os }}-sccache-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.cmake', '**/*.txt', '**/*.c', '**/*.s') }} | |
restore-keys: | | |
${{ runner.os }}-sccache- | |
- name: Create Docker volume if not exists | |
run: | | |
if ! docker volume inspect sccache_cache_volume >/dev/null 2>&1; then | |
docker volume create sccache_cache_volume | |
fi | |
- name: Build the docker image | |
run: | | |
docker build -f docker/Dockerfile.dev -t dev . | |
- name: Copy restored sccache backup into Docker volume | |
run: | | |
mkdir -p sccache_backup | |
docker run --rm \ | |
-v sccache_cache_volume:/to_volume \ | |
-v "$PWD/sccache_backup:/from_host" \ | |
busybox \ | |
sh -c "cp -a /from_host/. /to_volume/" || true | |
- name: Run the unit-test-build.py inside the docker container | |
run: | | |
docker run --rm \ | |
-v "$PWD:/home/jenkins" \ | |
-v "sccache_cache_volume:/home/jenkins/.cache/sccache" \ | |
-w /home/jenkins \ | |
-e SCCACHE_DIR=/home/jenkins/.cache/sccache \ | |
--user $(id -u):4996 \ | |
dev python3 .ci/code_coverage.py | |
- name: Zip code_coverage and coverage_badges | |
run: | | |
mv cmake-build-unit-tests/coverage code_coverage | |
zip -r code_coverage.zip code_coverage | |
mkdir coverage_badges | |
mv line_coverage_badge.svg coverage_badges/ | |
mv function_coverage_badge.svg coverage_badges/ | |
zip -r coverage_badges.zip coverage_badges | |
- name: Upload code coverage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code_coverage | |
path: code_coverage.zip | |
- name: Upload Coverage Badge | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_badges | |
path: coverage_badges.zip | |
- name: Copy updated sccache out of Docker volume | |
run: | | |
mkdir -p sccache_backup | |
docker run --rm \ | |
-v sccache_cache_volume:/from_volume \ | |
-v "$PWD/sccache_backup:/to_host" \ | |
busybox \ | |
sh -c "cp -a /from_volume/. /to_host/" |