From bc136bc36e9bb656a8771e7fcda8dfab078da6f4 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer Date: Thu, 18 Jul 2024 17:30:11 +0200 Subject: [PATCH] ci: switch to coverallsapp/github-action --- .github/workflows/ci.yml | 48 ++++----------------- .github/workflows/reports.yml | 78 ----------------------------------- README.md | 2 +- pyproject.toml | 6 +-- 4 files changed, 9 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/reports.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd893bc0..cee96e1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,6 @@ concurrency: cancel-in-progress: true env: - PYTHONUNBUFFERED: 1 FORCE_COLOR: 1 # colored output by pytest etc. permissions: {} # Set permissions at the job level. @@ -31,9 +30,7 @@ jobs: extra_args: --all-files --color=always tests: - runs-on: ubuntu-22.04 - permissions: - contents: write + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Set up Python 3.11 @@ -41,41 +38,10 @@ jobs: with: python-version: '3.11' cache: pip - - name: Install python dependencies - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install --upgrade hatch + - run: | + python -m pip install --upgrade pip + python -m pip install hatch - name: Run test suite with coverage - run: hatch run cov-ci - - name: Upload test results - if: always() - uses: actions/upload-artifact@v4 - with: - name: test-results - retention-days: 1 - path: pytest-junit.xml - - name: Upload coverage results - if: always() - uses: actions/upload-artifact@v4 - with: - name: coverage-results - retention-days: 1 - path: pytest-cobertura.xml - - run: rm ./reports/coverage/.gitignore - - name: Generate coverage badge - if: github.ref == 'refs/heads/master' - run: hatch run cov-badge - - name: Deploy reports to GitHub Pages - if: github.ref == 'refs/heads/master' - uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0 - with: - folder: ./reports - - event_file: - runs-on: ubuntu-22.04 - steps: - - uses: actions/upload-artifact@v4 - with: - name: event-file - retention-days: 1 - path: ${{ github.event_path }} + run: hatch run cov --cov-report=xml + - name: Upload coverage data to coveralls.io + uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # v2.3.0 diff --git a/.github/workflows/reports.yml b/.github/workflows/reports.yml deleted file mode 100644 index 2a84c196..00000000 --- a/.github/workflows/reports.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Reports - -on: - workflow_run: - workflows: [CI] - types: - - completed -permissions: {} - -jobs: - # Ref: https://github.com/EnricoMi/publish-unit-test-result-action#support-fork-repositories-and-dependabot-branches - test-results: - runs-on: ubuntu-22.04 - if: github.event.workflow_run.conclusion != 'skipped' - permissions: - checks: write - # required to create pull request comments - pull-requests: write - # required by download step to access artifacts API - actions: read - steps: - - name: Download and Extract Artifacts - uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe # v3.1.4 - with: - run_id: ${{ github.event.workflow_run.id }} - path: artifacts - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@30eadd5010312f995f0d3b3cff7fe2984f69409e # v2.16.1 - with: - comment_title: ':clipboard: Pytest Results' - commit: ${{ github.event.workflow_run.head_sha }} - event_file: artifacts/event-file/event.json - event_name: ${{ github.event.workflow_run.event }} - files: artifacts/test-results/pytest-junit.xml - - coverage-results: - runs-on: ubuntu-22.04 - if: github.event.workflow_run.conclusion != 'skipped' - permissions: - # required to create pull request comments - pull-requests: write - # required by download step to access artifacts API - actions: read - steps: - - name: Download and Extract Artifacts - uses: dawidd6/action-download-artifact@09f2f74827fd3a8607589e5ad7f9398816f540fe # v3.1.4 - with: - run_id: ${{ github.event.workflow_run.id }} - path: artifacts - # Ref: https://github.com/irongut/CodeCoverageSummary#usage - - name: Generate Code Coverage Report - uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 - with: - filename: artifacts/coverage-results/pytest-cobertura.xml - badge: true - format: markdown - hide_complexity: true - output: both - - name: Add header to code coverage report - run: | - sed -i '1s/^/## :clipboard: Code Coverage\n/' code-coverage-results.md - - name: Write to Job Summary - run: | - cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY - - name: Get Pull Request number - run: | - echo "number=$(jq .pull_request.number artifacts/event-file/event.json)" >> $GITHUB_OUTPUT - id: get-pr-number - # Ref: https://github.com/marocchino/sticky-pull-request-comment#inputs - - name: Add Code Coverage PR Comment - if: ${{ steps.get-pr-number.outputs.number }} != null - uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0 - with: - recreate: true - number: ${{ steps.get-pr-number.outputs.number }} - path: code-coverage-results.md - - # TODO: Coverage badge diff --git a/README.md b/README.md index 6cccb572..bcfcd191 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Developers: [Robert Huber](mailto:rhuber@marum.de), [Anusuriya Devaraju](mailto: Thanks to [Heinz-Alexander Fuetterer](https://github.com/afuetterer) for his contributions and his help in cleaning up the code. [![CI](https://github.com/pangaea-data-publisher/fuji/actions/workflows/ci.yml/badge.svg)](https://github.com/pangaea-data-publisher/fuji/actions/workflows/ci.yml) -[![Coverage](https://pangaea-data-publisher.github.io/fuji/coverage/coveragebadge.svg)](https://pangaea-data-publisher.github.io/fuji/coverage/) +[![Coverage](https://coveralls.io/repos/github/pangaea-data-publisher/fuji/badge.svg?branch=master)](https://coveralls.io/github/pangaea-data-publisher/fuji?branch=master) [![Publish Docker image](https://github.com/pangaea-data-publisher/fuji/actions/workflows/publish-docker.yml/badge.svg)](https://github.com/pangaea-data-publisher/fuji/actions/workflows/publish-docker.yml) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11084909.svg)](https://doi.org/10.5281/zenodo.11084909) diff --git a/pyproject.toml b/pyproject.toml index e6d4c031..ff8f5b8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,8 +65,7 @@ version = "3.2.0" [project.optional-dependencies] dev = [ - "fuji[lint]", - "fuji[testing]" + "fuji[lint,testing]" ] docs = [ "myst-parser~=3.0", @@ -81,7 +80,6 @@ report = [ "jupyter~=1.0" ] testing = [ - "genbadge[coverage]~=1.1", "pytest~=8.0", "pytest-cov~=5.0", "pytest-randomly~=3.15", @@ -125,8 +123,6 @@ features = [ [tool.hatch.envs.default.scripts] cov = "pytest --cov {args}" -cov-badge = "genbadge coverage --input-file=pytest-cobertura.xml --output-file=./reports/coverage/coveragebadge.svg" -cov-ci = "pytest --cov --junitxml=pytest-junit.xml --cov-report=xml:pytest-cobertura.xml --cov-report=html:./reports/coverage/ {args}" lint = "pre-commit run --all-files --color=always {args}" test = "pytest {args}"