Skip to content

Commit

Permalink
Migrate CI to kostrykin/report-test-coverage-action (#9)
Browse files Browse the repository at this point in the history
* Update tests.yml

* Update tests.yml

* Update tests.yml
  • Loading branch information
kostrykin authored Jul 13, 2024
1 parent 035ddc2 commit 8cfa6a3
Showing 1 changed file with 23 additions and 57 deletions.
80 changes: 23 additions & 57 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Tests

on:
push:
branches: [ "*" ]
workflow_dispatch:
pull_request:
branches: [ "*" ]
push:
branches: ['master']

permissions:
contents: read
issues: write
pull-requests: write

jobs:


run_tests:

runs-on: ubuntu-latest
Expand All @@ -22,64 +23,29 @@ jobs:
- "3.10"

steps:
-
uses: actions/checkout@v4
-
name: Set up Python ${{ matrix.python-version }}

- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
-
name: Install dependencies

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install coverage
-
name: Test with unittest/coverage
run: |
cd tournaments
coverage run --source='.' manage.py test
python -m coverage json --omit "*/tests.py,*/migrations/*.py,manage.py"
-
name: Upload coverage results
uses: actions/upload-artifact@v4
if: strategy.job-index == 0
with:
name: coverage
path: tournaments/coverage.json


update_coverage_badge_data:

runs-on: ubuntu-latest
needs: ['run_tests']
if: github.ref == 'refs/heads/master'
steps:
-
name: Download coverage results
uses: actions/download-artifact@v4
with:
name: coverage
-
name: Install jq
run: |
sudo apt install jq
-
name: Fetch coverage
id: coverage
shell: bash
run: |
echo "value=$(jq -r '[.totals.percent_covered_display][0]' coverage.json)" >> $GITHUB_OUTPUT
-
name: Create badge
uses: schneegans/dynamic-badges-action@v1.6.0
- name: Run tests
uses: kostrykin/report-test-coverage-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: bb85310a74d6b05330d230443007b878
filename: tournaments.json
label: Coverage
message: ${{ steps.coverage.outputs.value }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ steps.coverage.outputs.value }}
report: ${{ strategy.job-index == 0 }}
gist-id: bb85310a74d6b05330d230443007b878
github-auth: ${{ secrets.GITHUB_TOKEN }}
gist-auth: ${{ secrets.GIST_SECRET }}
gist-filename: tournaments.json
working-directory: tournaments
run: |
coverage run --source='.' manage.py test
python -m coverage json --omit "*/tests.py,*/migrations/*.py,manage.py"

0 comments on commit 8cfa6a3

Please sign in to comment.