Skip to content

Commit

Permalink
ci: integrate master and dev branches with Codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
boromir674 committed Oct 31, 2023
1 parent 764a507 commit 7a43574
Showing 1 changed file with 50 additions and 32 deletions.
82 changes: 50 additions & 32 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
matrix: ${{fromJSON(needs.set_github_outputs.outputs.matrix)}}
outputs:
SEMVER_PIP_FORMAT: ${{ steps.parse_version.outputs.SEMVER_PIP_FORMAT }}
CODECOV_ENV: ${{ steps.pick_codecov_env.outputs.CODECOV_ENV }}
# CI_COVERAGE_XML: ${{ steps.produce_coverage_xml_file.outputs.CI_COVERAGE_XML }}
# can be used in Other Jobs as for example
# needs: [test_suite]
Expand Down Expand Up @@ -156,6 +157,17 @@ jobs:
# steps.produce_coverage_xml_file.outputs.retval
# path: coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml
if-no-files-found: error
- name: Pick codecov_main_br or codecov_dev_br Environment, if tag on master or dev branch respectively
id: pick_codecov_env
run: |
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "CODECOV_ENV=codecov_main_br" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "CODECOV_ENV=codecov_dev_br" >> $GITHUB_ENV
else
echo "CODECOV_ENV=codecov_main_br" >> $GITHUB_ENV
fi
echo "CODECOV_ENV=$CODECOV_ENV" >> $GITHUB_OUTPUT
- name: Check for compliance with Python Best Practices
shell: bash
Expand All @@ -181,46 +193,52 @@ jobs:
path: ${{ env.DIST_DIR }}
if-no-files-found: error

# ENv1: codecov_main_br
# JOB CODECOV
codecov_coverage_host:

# codecov_coverage_host:
# # Job uses Github Action: https://github.com/codecov/codecov-action
# codecov_coverage_host:
# # Job uses Github Action: https://github.com/codecov/codecov-action

# # Prerequisites for this Job
# # - add repo to white-list of 'codecov' ga app 'extension' -> https://github.com/settings/installations/
# # - "Enable Github Repository" for codecov -> https://app.codecov.io/gh/boromir674
# - Generate a TOKEN: https://app.codecov.io/gh/boromir674/neural-style-transfer/settings
# Supply to Cocecov Upload Job the TOken: recommended through CI Secrets
# # Prerequisites for this Job
# # - add repo to white-list of 'codecov' ga app 'extension' -> https://github.com/settings/installations/
# # - "Enable Github Repository" for codecov -> https://app.codecov.io/gh/boromir674
# - Generate a TOKEN: https://app.codecov.io/gh/boromir674/neural-style-transfer/settings
# Supply to Cocecov Upload Job the TOken: recommended through CI Secrets
# Only do sth on master or dev branch, since tokens have been issued for those 2 branches only atm

codecov_coverage_host:

name: CodeCov Coverage Host
needs: [test_suite]
# run only on master or dev branches
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
environment: # inherit CODECOV_TOKEN env vars from 'GA Environment'
name: ${{ needs.test_suite.outputs.CODECOV_ENV }}
steps:
- name: Download Test Coverage XML File
uses: actions/download-artifact@v3
with:
name: all_coverage_raw
# Omiting path places the coverage file(s) in current working dir
# path: dir_of_coverage_files # ie coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml
# path: coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml
if-no-files-found: error

# Now coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml is the file to upload to codecov.io

- name: Upload Test Coverage XML File to CodeCov
# OPTION 1 From https://github.com/marketplace/actions/codecov
# We already merge all Coverage data into a Single XML file
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
# let the code discover the coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml file
# otherwise this Job needs a 'needs' section to link to set_github_outputs Job
# files: ./coverage1.xml,./coverage2.xml # optional
flags: unittests # optional
# name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
- name: Download Test Coverage XML File
uses: actions/download-artifact@v3
with:
name: all_coverage_raw
# Omiting path places the coverage file(s) in current working dir
# path: dir_of_coverage_files # ie coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml
# path: coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml
if-no-files-found: error
# Now coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml is the file to upload to codecov.io

- name: Upload Test Coverage XML File to CodeCov
# OPTION 1 From https://github.com/marketplace/actions/codecov
# We already merge all Coverage data into a Single XML file
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
# let the code discover the coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml file
# otherwise this Job needs a 'needs' section to link to set_github_outputs Job
# files: ./coverage1.xml,./coverage2.xml # optional
flags: unittests # optional
# name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)

# OPTION 2 From gpt
# uses: codecov/codecov-action@v3
Expand Down

0 comments on commit 7a43574

Please sign in to comment.