[#258] CodeCov Test #34
This file contains 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: CryptoLib Coverage with MC/DC | |
on: | |
push: | |
branches: | |
- 258-cyclomatic-complexity-and-mcdc-in-ci | |
paths-ignore: | |
- 'doc/coverage/*.svg' | |
pull_request: | |
branches: | |
- 258-cyclomatic-complexity-and-mcdc-in-ci | |
jobs: | |
mcdc-check: | |
runs-on: ubuntu-latest | |
container: | |
image: registry.gitlab.com/gtd-gmbh/mcdc-checker/mcdc-checker | |
steps: | |
- name: Check out the Repository | |
uses: actions/checkout@v4 | |
- name: Run MC/DC Checker | |
run: | | |
mkdir -p doc/coverage | |
mcdc_checker -a -j doc/coverage/report.json | |
- name: Upload Coverage Report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report-mcdc | |
path: doc/coverage | |
coverage: | |
runs-on: ubuntu-latest | |
container: | |
image: ivvitc/cryptolib:20240814 # Replace with your container if applicable | |
steps: | |
# Step 1: Check out the repository | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch full history for branch operations | |
# Step 2: Configure Git safe directory | |
- name: Configure Safe Directory | |
run: git config --global --add safe.directory $GITHUB_WORKSPACE | |
# Step 3: Install dependencies | |
- name: Install Dependencies | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
TZ: Etc/UTC | |
run: | | |
apt-get update | |
apt-get install -y gcc g++ gcovr lcov libcurl4-openssl-dev libmariadb-dev libmariadb-dev-compat python3 bc tzdata | |
pip install pycryptodome | |
curl -LS https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.50.tar.bz2 -o /tmp/libgpg-error-1.50.tar.bz2 | |
tar -xjf /tmp/libgpg-error-1.50.tar.bz2 -C /tmp/ | |
cd /tmp/libgpg-error-1.50 && ./configure && make install | |
curl -LS https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.0.tar.bz2 -o /tmp/libgcrypt-1.11.0.tar.bz2 | |
tar -xjf /tmp/libgcrypt-1.11.0.tar.bz2 -C /tmp/ | |
cd /tmp/libgcrypt-1.11.0 && ./configure && make install | |
ldconfig | |
# Step 4: Build and run tests with instrumentation | |
- name: Build and Run Tests with Instrumentation | |
run: | | |
export CFLAGS="-fprofile-arcs -ftest-coverage -g" | |
bash ${GITHUB_WORKSPACE}/support/scripts/build_internal.sh | |
# Step 5: Generate Coverage Report | |
- name: Generate Coverage Report | |
run: | | |
mkdir -p doc/coverage | |
gcovr --branches --xml-pretty --output doc/coverage/coverage.xml | |
gcovr --branches --html --html-details --output doc/coverage/coverage.html | |
# Step 6: Upload to Codecov | |
- name: Upload to Codecov | |
uses: codecov/codecov-action@v5 | |
env: | |
CODECOV_TOKEN: 71699f25-12a3-44a4-8a83-be777b9e577a | |
# Step 7: Commit and push coverage report (optional) | |
- name: Commit Coverage Report | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add doc/coverage/* | |
git commit -m "Update coverage reports" || echo "No changes to commit" | |
git push origin HEAD | |
# Step 8: Upload Coverage Report | |
- name: Upload Coverage Report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: doc/coverage |