Skip to content

Commit

Permalink
Update coverage-workflow.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Garima Ketan Chauhan authored and GitHub Enterprise committed Apr 2, 2025
1 parent 5756eef commit 5cca847
Showing 1 changed file with 17 additions and 38 deletions.
55 changes: 17 additions & 38 deletions .github/workflows/coverage-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,31 @@
name: Backend Test with Coverage
name: Backend Test Coverage

on:
push:
branches: gargi-production
pull_request:
branches: gargi-production
on: [push, pull_request]

jobs:
test:
runs-on: self-hosted
defaults:
run:
working-directory: ./backend
working-directory: ./secfit/backend

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- uses: actions/checkout@v4

- name: Build test image
run: docker build -f tests/Dockerfile.test -t backend-test .

- name: Run tests with coverage
id: coverage

- name: Run tests
run: |
docker run --name test-container backend-test
docker cp test-container:/app/coverage.xml . || echo "No coverage.xml found"
docker cp test-container:/app/htmlcov ./htmlcov || echo "No htmlcov found"
docker rm test-container
- name: Upload coverage report (XML)
if: always() && steps.coverage.outcome == 'success'
docker run --name test-runner backend-test
docker cp test-runner:/app/coverage.xml .
docker cp test-runner:/app/htmlcov/ .
docker rm test-runner
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage-xml
path: backend/coverage.xml

- name: Upload HTML coverage report
if: always() && steps.coverage.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: backend/htmlcov/

- name: Upload to Codecov
if: always() && steps.coverage.outcome == 'success'
uses: codecov/codecov-action@v3
with:
file: backend/coverage.xml
name: coverage-report
path: |
secfit/backend/coverage.xml
secfit/backend/htmlcov/

0 comments on commit 5cca847

Please sign in to comment.