diff --git a/.github/workflows/code_coverage.yaml b/.github/workflows/code_coverage.yaml new file mode 100644 index 00000000..136ed9a7 --- /dev/null +++ b/.github/workflows/code_coverage.yaml @@ -0,0 +1,54 @@ +name: Code-coverage + +on: + workflow_dispatch: + # push: + # branches: + # - main + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - id: checkout + uses: actions/checkout@v2 + + - id: dockerx + name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + + - id: build + name: Build dev docker + uses: docker/build-push-action@v2 + with: + context: . + file: ./docker/Dockerfile + push: false + load: true + tags: codiumai/pr-agent:test + cache-from: type=gha,scope=dev + cache-to: type=gha,mode=max,scope=dev + target: test + + - id: code_cov + name: Test dev docker + run: | + docker run --name test_container codiumai/pr-agent:test pytest tests/unittest --cov=pr_agent --cov-report term --cov-report xml:coverage.xml + docker cp test_container:/app/coverage.xml coverage.xml + docker rm test_container + + + - name: Validate coverage report + run: | + if [ ! -f coverage.xml ]; then + echo "Coverage report not found" + exit 1 + fi + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index a8d27cc0..d634e4b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,6 +25,7 @@ ujson==5.8.0 uvicorn==0.22.0 tenacity==8.2.3 gunicorn==22.0.0 +pytest-cov==5.0.0 # Uncomment the following lines to enable the 'similar issue' tool # pinecone-client # pinecone-datasets @ git+https://github.com/mrT23/pinecone-datasets.git@main