Skip to content

Commit

Permalink
Split out codecov workflow GHA
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Nov 13, 2024
1 parent b62778e commit d1b84ed
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 49 deletions.
71 changes: 22 additions & 49 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
pull_request_target:
pull_request:

env:
python-version: '3.11'
Expand Down Expand Up @@ -42,17 +42,20 @@ jobs:
run: |
flake8 $(git ls-files '*.py')
python-tests:
console-python-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py-project:
- ./TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link
- ./TrafficCapture/dockerSolution/src/main/docker/migrationConsole/cluster_tools
- lib/console_link
- cluster_tools
- console_api
env:
WORKING_DIR: ./TrafficCapture/dockerSolution/src/main/docker/migrationConsole/${{ matrix.py-project }}
defaults:
run:
working-directory: ${{ matrix.py-project }}
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -63,39 +66,12 @@ jobs:
pipenv install --deploy --dev
pipenv run test
pipenv run coverage xml
- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage.xml
flags: python-test
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

console-api-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./TrafficCapture/dockerSolution/src/main/docker/migrationConsole/console_api
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
- run: |
python3 -m pip install --upgrade pipenv
pipenv install --deploy --dev
pipenv run coverage run --source='.' manage.py test console_api
pipenv run coverage xml
- name: Upload Coverage
uses: codecov/codecov-action@v4
- name: Upload Coverage Reports
uses: actions/upload-artifact@v4
with:
fail_ci_if_error: true
files: ./coverage.xml
flags: python-test
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

if-no-files-found: error
name: coverage-reports-python-tests-${{ matrix.py-project }} | replace: '/' with '_'
path: ${{ env.WORKING_DIR }}/coverage.xml

gradle-tests:
runs-on: ubuntu-latest
Expand All @@ -122,19 +98,16 @@ jobs:
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
name: test-reports-gradle-tests
path: |
**/build/reports/tests/
**/reports/jacoco/mergedReport/
- name: Upload Coverage
uses: codecov/codecov-action@v4
- name: Upload Coverage Reports
uses: actions/upload-artifact@v4
with:
disable_search: true
fail_ci_if_error: true
files: ${{ github.workspace }}/build/reports/jacoco/mergedReport/jacocoMergedReport.xml
flags: gradle-test
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
if-no-files-found: error
name: coverage-reports-gradle-tests
path: /**/jacocoMergedReport.xml


python-e2e-tests:
Expand Down Expand Up @@ -238,13 +211,13 @@ jobs:

all-ci-checks-pass:
needs:
- style-check
- node-tests
- console-python-tests
- gradle-tests
- link-checker
- node-tests
- python-e2e-tests
- python-lint
- python-tests
- style-check
if: always()
runs-on: ubuntu-latest
steps:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/codecov-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Codecov Publish

on:
workflow_run:
workflows: ["CI"]
types:
- completed

jobs:
publish-codecov:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Download Coverage Artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-reports-*
path: ./coverage-reports

- name: Upload Coverage
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage-reports/**/*.*
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ moto = {version = "*", extras = ["sts"]}

[requires]
python_version = "3.11"

[scripts]
test = "coverage run --source='.' manage.py test console_api"
coverage = "coverage"

0 comments on commit d1b84ed

Please sign in to comment.