Skip to content

Unit test coverage #723

Unit test coverage

Unit test coverage #723

Workflow file for this run

name: Unit test coverage
on:
workflow_dispatch:
inputs:
python_version:
required: true
type: string
ref:
required: false
type: string
base:
required: true
type: string
check_run_id:
required: false
type: string
artifact_urls:
required: true
type: string
pr_id:
required: true
type: id
pr_repo:
required: false
type: string
env:
COMMIT: ${{ inputs.ref || github.event.ref }}
PEM: ${{ secrets.BOT_PEM }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_CHECK_RUN_ID: ${{ inputs.check_run_id }}
PR_ID: ${{ inputs.pr_id }}
PR_REPO: ${{ inputs.pr_repo || github.repository }}
jobs:
CoverageChecker:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.COMMIT }}
repository: ${{ env.PR_REPO }}
submodules: true
- name: Set up Python ${{ inputs.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_version }}
- name: "Setup"
id: token
run: |
pip install jwt requests
python ci_tools/setup_check_run.py coverage
shell: bash
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install defusedxml
python -m pip install coverage
shell: bash
- name: Collect coverage information
run: |
python ci_tools/fetch_artifacts.py ${{ inputs.artifact_urls }}
echo -e "[paths]\nsource =\n $(pwd)/pyccel\n */site-packages/pyccel\n[xml]\noutput = cobertura.xml" > .coveragerc
coverage combine
coverage xml
shell: bash
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@master
continue-on-error: True
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: cobertura.xml
- name: Collect diff information
run: |
git fetch
git checkout ${{ inputs.base }} # Make sure there is a local copy in case of a branch
git checkout ${{ env.COMMIT }}
git diff ${{ inputs.base }}..HEAD --no-indent-heuristic --unified=0 --output=pull_diff.txt --no-color
shell: bash
- name: Check coverage
id: coverage
run: |
python ci_tools/check_new_coverage.py pull_diff.txt cobertura.xml $GITHUB_STEP_SUMMARY
shell: bash