Skip to content

Commit

Permalink
chore(ci): add code coverage support
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Apr 2, 2024
1 parent ea6aea7 commit 45f5061
Show file tree
Hide file tree
Showing 3 changed files with 48 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
53 changes: 42 additions & 11 deletions .github/workflows/main.yaml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,72 @@ on:
pull_request:
workflow_dispatch:

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

jobs:
test:
name: Test and Build Python SDK for OpenFGA
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

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
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
3 changes: 2 additions & 1 deletion .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.codecov.yml
.fossa.yml
.github/CODEOWNERS
.github/ISSUE_TEMPLATE/bug_report.yaml
.github/ISSUE_TEMPLATE/config.yaml
.github/ISSUE_TEMPLATE/feature_request.yaml
.github/dependabot.yaml
.github/workflows/main.yaml
.github/workflows/main.yml
.github/workflows/semgrep.yaml
.gitignore
.snyk
Expand Down

0 comments on commit 45f5061

Please sign in to comment.