From bc788dd51c4dc8e008da52f1242e2a51b498de67 Mon Sep 17 00:00:00 2001 From: Ashwin Vaidya Date: Fri, 12 Aug 2022 15:29:44 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=96=EF=B8=8F=20Add=20coverage=20(#499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add coverage report upload to pre_merge * Use python uploader * Explicitly pass commit hash * Get ref from expression * Fix typo * Debug * Revert * Debug * Debug * Debug * Debug * Use variable for commit id * Add coverage badge * Add comments --- .github/workflows/pre_merge.yml | 18 +++++++++++++----- README.md | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pre_merge.yml b/.github/workflows/pre_merge.yml index 6b841de460..636a2723bf 100644 --- a/.github/workflows/pre_merge.yml +++ b/.github/workflows/pre_merge.yml @@ -25,8 +25,16 @@ jobs: export ANOMALIB_DATASET_PATH=/media/data1/datasets/ export CUDA_VISIBLE_DEVICES=3 tox -e pre_merge - - name: Upload coverage result - uses: actions/upload-artifact@v2 - with: - name: coverage - path: .tox/coverage.xml + - name: Upload coverage report + run: | + # If the workflow is triggered from PR then it gets the commit id from the PR. + # else it uses the commit id of the latest commit. This is because the commit + # of the checked-out branch/commit does not exist in the tree as it is grafted. + if [[ ${{ github.event.pull_request.head.sha }} ]] + then + COMMIT_ID=${{ github.event.pull_request.head.sha }} + else + COMMIT_ID=${{ github.sha }} + fi + pip install codacy-coverage + python-codacy-coverage -r .tox/coverage.xml -t ${{ secrets.CODACY }} -c $COMMIT_ID diff --git a/README.md b/README.md index 114b72095c..eda6c630c8 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ [![black](https://img.shields.io/badge/code%20style-black-000000.svg)]() [![Nightly-Regression Test](https://github.com/openvinotoolkit/anomalib/actions/workflows/nightly.yml/badge.svg)](https://github.com/openvinotoolkit/anomalib/actions/workflows/nightly.yml) [![Pre-Merge Checks](https://github.com/openvinotoolkit/anomalib/actions/workflows/pre_merge.yml/badge.svg)](https://github.com/openvinotoolkit/anomalib/actions/workflows/pre_merge.yml) +[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/684927c1c76c4c5e94bb53480812fbbb)](https://www.codacy.com/gh/openvinotoolkit/anomalib/dashboard?utm_source=github.com&utm_medium=referral&utm_content=openvinotoolkit/anomalib&utm_campaign=Badge_Coverage) [![Docs](https://github.com/openvinotoolkit/anomalib/actions/workflows/docs.yml/badge.svg)](https://github.com/openvinotoolkit/anomalib/actions/workflows/docs.yml) [![Downloads](https://static.pepy.tech/personalized-badge/anomalib?period=total&units=international_system&left_color=grey&right_color=green&left_text=PyPI%20Downloads)](https://pepy.tech/project/anomalib)