-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Diff code coverage of different branchs using codecov app (#2310)
Signed-off-by: huaweil <[email protected]> Signed-off-by: Bettina Heim <[email protected]> Co-authored-by: Bettina Heim <[email protected]>
- Loading branch information
1 parent
a9e2324
commit 1ca93a3
Showing
5 changed files
with
315 additions
and
85 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: 70% | ||
threshold: 1% | ||
ignore: | ||
- "tpls" | ||
fixes: | ||
- "/workspaces/cuda-quantum::" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
platform: | ||
type: string | ||
required: false | ||
default: linux/amd64 | ||
devdeps_image: | ||
required: false | ||
type: string | ||
devdeps_cache: | ||
required: true | ||
type: string | ||
devdeps_archive: | ||
required: true | ||
type: string | ||
export_environment: | ||
required: false | ||
type: boolean | ||
secrets: | ||
CODECOV_TOKEN: | ||
required: false | ||
|
||
name: Show Code Coverage Diff | ||
|
||
jobs: | ||
gen_code_coverage: | ||
runs-on: ${{ (contains(inputs.platform, 'arm') && 'linux-arm64-cpu8') || 'linux-amd64-cpu8' }} | ||
permissions: | ||
contents: read | ||
packages: read | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore environment | ||
id: restore_devdeps | ||
if: inputs.devdeps_image == '' | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ${{ inputs.devdeps_archive }} | ||
key: ${{ inputs.devdeps_cache }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Log in to GitHub CR | ||
if: inputs.devdeps_image != '' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Set up context for buildx | ||
run: | | ||
docker context create builder_context | ||
- name: Set up buildx runner | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
endpoint: builder_context | ||
|
||
- name: Build CUDA Quantum | ||
id: cudaq_build | ||
run: | | ||
if ${{ steps.restore_devdeps.outcome != 'skipped' }}; then | ||
load_output=`docker load --input "${{ inputs.devdeps_archive }}"` | ||
base_image=`echo "$load_output" | grep -o 'Loaded image: \S*:\S*' | head -1 | cut -d ' ' -f 3` | ||
elif ${{ inputs.devdeps_image != '' }}; then | ||
base_image=${{ inputs.devdeps_image }} | ||
else | ||
echo "::error file=generate_cc.yml::Missing configuration for development dependencies. Either specify the image (i.e. provide devdeps_image) or cache (i.e. provide devdeps_cache and devdeps_archive) that should be used for the build." | ||
exit 1 | ||
fi | ||
DOCKER_BUILDKIT=1 docker build --platform ${{ inputs.platform }} \ | ||
-t cuda-quantum-cc:local -f docker/build/cudaq.dev.Dockerfile . \ | ||
--build-arg base_image=$base_image | ||
devdeps_tag=`echo $base_image | rev | cut -d ":" -f 1 | rev` | ||
echo "devdeps_tag=$devdeps_tag" >> $GITHUB_OUTPUT | ||
- name: Create Shared Dir | ||
run: | | ||
mkdir -p ${{ github.workspace }}/shared | ||
- name: Test CUDA Quantum And Generate CC | ||
uses: ./.github/actions/run-in-docker | ||
with: | ||
image: cuda-quantum-cc:local | ||
shell: bash | ||
volume: ${{ github.workspace }}/shared:/shared | ||
run: | | ||
cd $CUDAQ_REPO_ROOT | ||
bash scripts/generate_cc.sh -v -c -p | ||
if [ ! $? -eq 0 ]; then | ||
echo "generate_cc status = " $? | ||
else | ||
chmod -R 777 ./build/ccoverage | ||
chmod -R 777 ./build/pycoverage | ||
cp ./build/ccoverage/coverage.txt /shared | ||
cp ./build/pycoverage/coverage.xml /shared | ||
fi | ||
- name: Upload C/C++ & Python Coverage To Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
fail_ci_if_error: false | ||
files: ${{ github.workspace }}/shared/coverage.txt,${{ github.workspace }}/shared/coverage.xml | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
verbose: true | ||
|
||
- name: Delete Shared Dir | ||
run: | | ||
rm -r ${{ github.workspace }}/shared | ||
- name: Save environment | ||
id: env_save | ||
if: inputs.export_environment | ||
run: | | ||
output_directory=/tmp | ||
filename=${{ steps.cudaq_build.outputs.devdeps_tag }}_cc_build | ||
docker run --name cuda-quantum-cc cuda-quantum-cc:local | ||
docker export cuda-quantum-cc > $output_directory/$filename.tar | ||
docker rm -f cuda-quantum-cc | ||
echo "filename=$filename" >> $GITHUB_OUTPUT | ||
echo "output_directory=$output_directory" >> $GITHUB_OUTPUT | ||
- name: Upload environment | ||
uses: actions/upload-artifact@v4 | ||
if: inputs.export_environment | ||
with: | ||
name: ${{ steps.env_save.outputs.filename }} | ||
path: ${{ steps.env_save.outputs.output_directory }}/${{ steps.env_save.outputs.filename }}.tar | ||
retention-days: 1 |
Oops, something went wrong.