Skip to content

Commit 7e54658

Browse files
authored
chore: refactor for typing, proper version checks, and more (#283)
* fix: typing and broader version checks * mypy * coverage * py.typed * tox and samples * limit 3.7 support
1 parent 2080c69 commit 7e54658

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+817
-1640
lines changed

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/actions/gitleaks/action.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,91 @@
11
name: Python
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: "0 8 * * *"
410

5-
env:
6-
GO_VERSION: 1.18
11+
concurrency:
12+
group: check-${{ github.ref }}
13+
cancel-in-progress: true
714

815
permissions:
916
contents: read
1017
pull-requests: write
1118

1219
jobs:
1320
build:
14-
runs-on: ubuntu-latest
21+
name: test with ${{ matrix.py }} on ${{ matrix.os }}
22+
runs-on: ${{ matrix.os }}
1523
strategy:
24+
fail-fast: false
1625
matrix:
17-
python-version: ["3.7", "3.8", "3.9", "3.10"]
26+
py:
27+
- "3.11"
28+
- "3.10"
29+
- "3.9"
30+
- "3.8"
31+
- "3.7"
32+
os:
33+
- ubuntu-latest
34+
- macos-latest
35+
- windows-latest
1836
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v3
21-
- name: Poetry
22-
uses: descope/.github/.github/actions/python/poetry/setup@main
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
- name: Setup python for test ${{ matrix.py }}
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: ${{ matrix.py }}
44+
- name: Install tox
45+
run: python -m pip install tox-gh>=1.2 poetry
46+
- name: Setup test suite
47+
run: tox -vv --notest
48+
- name: Run test suite
49+
run: tox --skip-pkg-install
50+
env:
51+
COVERAGE_FILE: ".coverage.${{ matrix.py }}"
52+
53+
- name: Store coverage file
54+
uses: actions/upload-artifact@v3
2355
with:
24-
python-version: ${{ matrix.python-version }}
56+
name: coverage
57+
path: .coverage.${{ matrix.py }}
2558

26-
- name: Run tests
27-
run: |
28-
poetry run pytest --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=descope tests/ --cov-report=xml:/tmp/cov.xml
59+
coverage:
60+
name: Coverage
61+
runs-on: ubuntu-latest
62+
needs: build
63+
permissions:
64+
pull-requests: write
65+
contents: write
66+
steps:
67+
- uses: actions/checkout@v4
2968

30-
- name: Post Pytest coverage comment
31-
if: ${{ github.event_name == 'pull_request' }}
32-
id: coverageComment
33-
uses: MishaKav/pytest-coverage-comment@main
69+
- uses: actions/download-artifact@v3
70+
id: download
3471
with:
35-
pytest-xml-coverage-path: /tmp/cov.xml
36-
create-new-comment: false
37-
38-
- name: Coverage
39-
if: ${{ github.event_name == 'pull_request' }}
40-
run: |
41-
echo "Coverage Percantage - ${{ steps.coverageComment.outputs.coverage }}"
42-
echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}"
43-
echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}"
44-
echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}"
45-
echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}"
46-
echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}"
47-
echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}"
48-
echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}"
49-
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
50-
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"
51-
52-
- name: Gitleaks
53-
uses: ./.github/actions/gitleaks
72+
name: "coverage"
73+
74+
- name: Coverage comment
75+
id: coverage_comment
76+
uses: py-cov-action/python-coverage-comment-action@v3
77+
with:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
MERGE_COVERAGE_FILES: true
80+
81+
gitleaks:
82+
name: gitleaks
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v3
5486
with:
55-
go_version: ${{ env.GO_VERSION }}
87+
fetch-depth: 0
88+
- uses: gitleaks/gitleaks-action@v2
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}

.github/workflows/python-publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup
1919
uses: descope/.github/.github/actions/python/poetry/setup@main
2020
with:
21-
python-version: "3.8"
21+
python-version: "3.11"
2222
- name: Autobump version
2323
run: |
2424
poetry version $(git describe --tags --abbrev=0)

.pre-commit-config.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ repos:
4141
files: pyproject.toml
4242
- id: poetry-check
4343
files: pyproject.toml
44+
- repo: https://github.com/pre-commit/pre-commit
45+
rev: v3.3.3
46+
hooks:
47+
- id: validate_manifest
48+
- repo: https://github.com/tox-dev/tox-ini-fmt
49+
rev: 1.3.1
50+
hooks:
51+
- id: tox-ini-fmt
52+
args: ["-p", "type"]
53+
- repo: https://github.com/gitleaks/gitleaks
54+
rev: v8.16.1
55+
hooks:
56+
- id: gitleaks
4457
- repo: local
4558
hooks:
4659
- id: print_statement
@@ -56,7 +69,10 @@ repos:
5669
language: system
5770
files: ^(.*requirements.*\.txt|setup\.cfg|setup\.py|pyproject\.toml|liccheck\.ini)$
5871
pass_filenames: false
59-
- repo: https://github.com/pre-commit/pre-commit
60-
rev: v3.3.3
61-
hooks:
62-
- id: validate_manifest
72+
- id: tox
73+
name: Run tests with tox
74+
description: Run tox to check that all tests pass
75+
entry: poetry run tox -p
76+
language: system
77+
files: ^(.*\.py)$
78+
pass_filenames: false

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"python.testing.pytestEnabled": true,
2+
"python.testing.pytestEnabled": true,
33
"python.testing.pytestArgs": [
44
"tests"
55
],
6+
"mypy.runUsingActiveInterpreter": true,
67
}

0 commit comments

Comments
 (0)