Skip to content

Update coverage-workflow.yml #27

Update coverage-workflow.yml

Update coverage-workflow.yml #27

name: Backend Test with Coverage
on:
push:
branches: gargi-production
pull_request:
branches: gargi-production
jobs:
test:
runs-on: self-hosted
defaults:
run:
working-directory: ./backend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build test image
run: docker build -f tests/Dockerfile.test -t backend-test .
- name: Run tests with coverage
id: coverage
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'
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