From cf028964f3714a51ad0c758d29f8ba8e47335f74 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 2 Sep 2021 09:36:25 +0530 Subject: [PATCH 1/4] CI: Use codecov coverage reporting Why? - Coveralls had login issues and we were not able to view files to find the actual uncovered lines - Codecov has better reporting (status checks & commit diff coverage, ), UX (better folder/file navigation, faster page loads), and has more features. - Codecov will not require additional step of coverage wrap-up for parallel builds (it manages it internally somehow). --- .github/workflows/server-mariadb-tests.yml | 50 +++------------------- frappe/coverage.py | 3 +- 2 files changed, 7 insertions(+), 46 deletions(-) diff --git a/.github/workflows/server-mariadb-tests.yml b/.github/workflows/server-mariadb-tests.yml index fb6e56037c..8fcd9017d0 100644 --- a/.github/workflows/server-mariadb-tests.yml +++ b/.github/workflows/server-mariadb-tests.yml @@ -120,49 +120,9 @@ jobs: CI_BUILD_ID: ${{ github.run_id }} ORCHESTRATOR_URL: http://test-orchestrator.frappe.io - - name: Upload Coverage Data - if: ${{ steps.check-build.outputs.build == 'strawberry' }} - id: upload-coverage-data - run: | - cp ~/frappe-bench/sites/.coverage ${GITHUB_WORKSPACE} - cd ${GITHUB_WORKSPACE} - pip3 install coverage==5.5 - pip3 install coveralls==3.0.1 - coveralls - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - COVERALLS_FLAG_NAME: run-${{ matrix.container }} - COVERALLS_SERVICE_NAME: ${{ github.event_name == 'pull_request' && 'github' || 'github-actions' }} - COVERALLS_PARALLEL: true - - - run: echo ${{ steps.check-build.outputs.build }} > guess-the-fruit.txt - - uses: actions/upload-artifact@v1 + - uses: codecov/codecov-action@v2 with: - name: fruit - path: guess-the-fruit.txt - - coveralls: - name: Coverage Wrap Up - needs: test - container: python:3-slim - runs-on: ubuntu-18.04 - steps: - - uses: actions/download-artifact@v1 - with: - name: fruit - - run: echo "WILDCARD=$(cat fruit/guess-the-fruit.txt)" >> $GITHUB_ENV - - - name: Clone - if: ${{ env.WILDCARD == 'strawberry' }} - uses: actions/checkout@v2 - - - name: Coveralls Finished - if: ${{ env.WILDCARD == 'strawberry' }} - run: | - cd ${GITHUB_WORKSPACE} - pip3 install coverage==5.5 - pip3 install coveralls==3.0.1 - coveralls --finish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: MariaDB + fail_ci_if_error: true + files: /home/runner/frappe-bench/sites/coverage.xml + verbose: true diff --git a/frappe/coverage.py b/frappe/coverage.py index 33f945be40..1969cae141 100644 --- a/frappe/coverage.py +++ b/frappe/coverage.py @@ -58,4 +58,5 @@ class CodeCoverage(): def __exit__(self, exc_type, exc_value, traceback): if self.with_coverage: self.coverage.stop() - self.coverage.save() \ No newline at end of file + self.coverage.save() + self.coverage.xml_report() \ No newline at end of file From ba73d99377473dc83391b741c0666eccc02a3179 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 2 Sep 2021 09:36:57 +0530 Subject: [PATCH 2/4] ci: Enable code coverage for postgres build as well --- .github/workflows/server-postgres-tests.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/server-postgres-tests.yml b/.github/workflows/server-postgres-tests.yml index 1539e8c2d5..aef0e50c5a 100644 --- a/.github/workflows/server-postgres-tests.yml +++ b/.github/workflows/server-postgres-tests.yml @@ -116,7 +116,14 @@ jobs: - name: Run Tests if: ${{ steps.check-build.outputs.build == 'strawberry' }} - run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --use-orchestrator + run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --use-orchestrator --with-coverage env: CI_BUILD_ID: ${{ github.run_id }} ORCHESTRATOR_URL: http://test-orchestrator.frappe.io + + - uses: codecov/codecov-action@v2 + with: + name: Postgres + fail_ci_if_error: true + files: /home/runner/frappe-bench/sites/coverage.xml + verbose: true From cbd94bd33dbcf72f5fcd525b6bb6edacca133248 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 2 Sep 2021 10:53:53 +0530 Subject: [PATCH 3/4] ci: Set name for coverage data upload --- .github/workflows/server-mariadb-tests.yml | 3 ++- .github/workflows/server-postgres-tests.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/server-mariadb-tests.yml b/.github/workflows/server-mariadb-tests.yml index 8fcd9017d0..57a7fa304d 100644 --- a/.github/workflows/server-mariadb-tests.yml +++ b/.github/workflows/server-mariadb-tests.yml @@ -120,7 +120,8 @@ jobs: CI_BUILD_ID: ${{ github.run_id }} ORCHESTRATOR_URL: http://test-orchestrator.frappe.io - - uses: codecov/codecov-action@v2 + - name: Upload coverage data + uses: codecov/codecov-action@v2 with: name: MariaDB fail_ci_if_error: true diff --git a/.github/workflows/server-postgres-tests.yml b/.github/workflows/server-postgres-tests.yml index aef0e50c5a..fe33a9c917 100644 --- a/.github/workflows/server-postgres-tests.yml +++ b/.github/workflows/server-postgres-tests.yml @@ -121,7 +121,8 @@ jobs: CI_BUILD_ID: ${{ github.run_id }} ORCHESTRATOR_URL: http://test-orchestrator.frappe.io - - uses: codecov/codecov-action@v2 + - name: Upload coverage data + uses: codecov/codecov-action@v2 with: name: Postgres fail_ci_if_error: true From 329919d43d467ed426494d477da07594c100a943 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 2 Sep 2021 11:37:40 +0530 Subject: [PATCH 4/4] chore: Add codecov config file --- codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000000..00e85225f4 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,5 @@ +codecov: + require_ci_to_pass: yes +comment: + layout: "diff, flags, files" + require_changes: true \ No newline at end of file