Skip to content

Commit

Permalink
ci: fix Codecov Job using Github ACtion
Browse files Browse the repository at this point in the history
  • Loading branch information
boromir674 committed Oct 30, 2023
1 parent 4a58b87 commit 8814e21
Showing 1 changed file with 86 additions and 19 deletions.
105 changes: 86 additions & 19 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,32 +181,59 @@ jobs:
path: ${{ env.DIST_DIR }}
if-no-files-found: error


# JOB CODECOV
codecov_coverage_host:

# 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

name: CodeCov Coverage Host
needs: [build_and_test]
runs-on: ubuntu-latest
needs: test_suite
env:
PACKAGE_DIST_VERSION: ${{ needs.test_suite.outputs.SEMVER_PIP_FORMAT }}
steps:
- uses: actions/checkout@v3
- name: Get Codecov binary
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
- name: Download Raw Coverage Data Artefacts
- name: Download Test Coverage XML File
uses: actions/download-artifact@v3
with:
name: all_coverage_raw
- name: Upload Coverage Reports to Codecov
run: |
for file in coverage*.xml; do
OS_NAME=$(echo $file | sed -E "s/coverage-(\w\+)-/\1/")
PY_VERSION=$(echo $file | sed -E "s/coverage-\w\+-(\d\.)\+/\1/")
./codecov -f $file -e "OS=$OS_NAME,PYTHON=$PY_VERSION" --flags unittests --verbose
echo "Sent to Codecov: $file !"
done
# 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

# DOCKER BUILD AND PUBLISH ON DOCKERHUB
# 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
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# file: ${{ env.CI_COVERAGE_XML }}
# # file: coverage-${{ matrix.platform }}-${{ matrix.python-version }}.xml
# flags: unittests
# fail_ci_if_error: true
# verbose: true


### JOB: DOCKER BUILD AND PUBLISH ON DOCKERHUB ###
docker_build:
runs-on: ubuntu-latest
needs: test_suite
Expand Down Expand Up @@ -433,3 +460,43 @@ jobs:
name: dependency-graphs
path: pydeps/
if-no-files-found: warn # 'error' or 'ignore' are also available, defaults to `warn`




# LEGACY

# 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

# runs-on: ubuntu-latest
# needs: test_suite
# env:
# PACKAGE_DIST_VERSION: ${{ needs.test_suite.outputs.SEMVER_PIP_FORMAT }}
# steps:
# - uses: actions/checkout@v3
# - name: Get Codecov binary
# run: |
# curl -Os https://uploader.codecov.io/latest/linux/codecov
# chmod +x codecov
# - name: Download Raw Coverage Data Artefacts
# uses: actions/download-artifact@v3
# with:
# name: all_coverage_raw
# - name: Upload Coverage Reports to Codecov
# run: |
# echo "[DEBUG]: This Dir is: $(pwd)"
# echo "[DEBUG]: Files in this Dir are: $(ls -la)"
# ./codecov -f coverage-*.xml -t ${{ secrets.CODECOV_TOKEN }} -n ${{ env.PACKAGE_DIST_VERSION }} -F ${{ github.sha }} -Z
# for file in coverage*.xml; do
# OS_NAME=$(echo $file | sed -E "s/coverage-(\w\+)-/\1/")
# PY_VERSION=$(echo $file | sed -E "s/coverage-\w\+-(\d\.)\+/\1/")
# ./codecov -f $file -e "OS=$OS_NAME,PYTHON=$PY_VERSION" --flags unittests --verbose
# echo "Sent to Codecov: $file !"
# done

0 comments on commit 8814e21

Please sign in to comment.