Skip to content

Commit

Permalink
chore(ci): add code coverage support (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims authored Apr 3, 2024
2 parents ea6aea7 + 3b0208c commit b6ef82d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage:
precision: 2
range: "60...80"
round: down
51 changes: 41 additions & 10 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Build, Test and Publish

on:
Expand All @@ -6,15 +7,22 @@ on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Checkout code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 0

Expand All @@ -26,22 +34,44 @@ jobs:
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
**/test-requirements*.txt
- name: Install dependencies
run: |
python -m pip install -r test-requirements.txt
- name: Test
run: python -m pytest
- name: Flake8
run: pip install -r test-requirements.txt --upgrade pip

- if: matrix.python-version == '3.10'
name: Run Flake8
run: flake8 . --count --show-source --statistics

- if: matrix.python-version == '3.10'
name: Run Black
run: black . --check

- if: matrix.python-version == '3.10'
name: Run isort
run: isort . --profile black --diff --check-only

- if: matrix.python-version == '3.10'
name: Run autoflake
run: autoflake --exclude=__init__.py --remove-unused-variables --remove-all-unused-imports --quiet --check-diff --recursive .

- name: Run tests and collect coverage
run: pytest --cov-fail-under 60 --cov openfga_sdk

- if: matrix.python-version == '3.10'
name: Upload coverage to Codecov
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: openfga/python-sdk

publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [test]

permissions:
# Required for PyPI trusted publishing
id-token: write
id-token: write # Required for PyPI trusted publishing

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
Expand All @@ -56,9 +86,10 @@ jobs:
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
**/test-requirements*.txt
- name: Install dependencies
run: |
python -m pip install -r test-requirements.txt
run: pip install -r test-requirements.txt --upgrade pip

- name: Build package
run: |
Expand Down
1 change: 1 addition & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.codecov.yml
.fossa.yml
.github/CODEOWNERS
.github/ISSUE_TEMPLATE/bug_report.yaml
Expand Down
1 change: 0 additions & 1 deletion openfga_sdk/sync/open_fga_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""


from openfga_sdk.exceptions import ApiValueError, FgaValidationException
from openfga_sdk.sync.api_client import ApiClient
from openfga_sdk.sync.oauth2 import OAuth2Client
Expand Down
6 changes: 5 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
-r requirements.txt

mock >= 5.1.0, < 6
autoflake==2.3.0
black==24.2.0
flake8 >= 7.0.0, < 8
pytest-cov >= 5, < 6
griffe >= 0.41.2, < 1
isort==5.13.2
pytest-cov >= 5, < 6
pyupgrade==3.15.1

0 comments on commit b6ef82d

Please sign in to comment.