-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e73020
commit 34e6dc9
Showing
10 changed files
with
394 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
"*.github" | ||
], | ||
"_template": "https://github.com/MartinBernstorff/swift-python-cookiecutter", | ||
"add_makefile": "y", | ||
"author": "Kenneth Enevoldsen", | ||
"copyright_year": "2023", | ||
"email": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ jobs: | |
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
token: ${{ secrets.PAT }} | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
|
@@ -32,5 +33,5 @@ jobs: | |
if: ${{ github.event_name == 'push' }} | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
github_token: ${{ secrets.PAT }} | ||
branch: gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,21 @@ name: Release | |
on: | ||
push: | ||
branches: [main] | ||
workflow_run: | ||
workflows: ["tests"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
concurrency: release | ||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing using PyPI | ||
# a guide on how to set it up is available here: https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/ | ||
|
||
|
||
if: ${{ github.ref == 'refs/heads/main' }} | ||
if: ${{ github.ref == 'refs/heads/main' && github.event.workflow_run.conclusion == 'success'}} | ||
steps: | ||
# Checkout action is required for token to persist | ||
- uses: actions/checkout@v3 | ||
|
@@ -22,14 +31,20 @@ jobs: | |
token: ${{ secrets.PAT }} | ||
|
||
- name: Python Semantic Release | ||
uses: relekang/[email protected] | ||
uses: python-semantic-release/[email protected] | ||
id: release | ||
with: | ||
github_token: ${{ secrets.PAT }} | ||
|
||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: steps.release.outputs.released == 'true' | ||
# This action supports PyPI's trusted publishing implementation, which allows authentication to PyPI without a manually | ||
# configured API token or username/password combination. To perform trusted publishing with this action, your project's | ||
# publisher must already be configured on PyPI. | ||
|
||
- name: Publish package distributions to GitHub Releases | ||
uses: python-semantic-release/upload-to-gh-release@main | ||
if: steps.release.outputs.released == 'true' | ||
with: | ||
github_token: ${{ secrets.PAT }} | ||
# Remember to copy the [tool.semantic_release] section from pyproject.toml | ||
# as well | ||
# To enable pypi, | ||
# 1) Set upload_to_pypi to true in pyproject.toml and | ||
# 2) Set the pypi_token in the repo | ||
# 3) Uncomment the two lines below | ||
repository_username: __token__ | ||
repository_password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# We do not include static_type_checks as a pre-commit hook because pre-commit hooks | ||
# are installed in their own virtual environment, so static_type_checks cannot | ||
# use stubs from imports | ||
name: static_type_checks | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
static_type_checks: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
concurrency: | ||
group: "${{ github.workflow }} @ ${{ github.ref }}" | ||
cancel-in-progress: true | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.9"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache tox | ||
uses: actions/[email protected] | ||
id: cache_tox | ||
with: | ||
path: | | ||
.tox | ||
key: ${{ runner.os }}-${{ matrix.python-version }}-static-type-checks | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
id: setup_python | ||
with: | ||
python-version: ${{ matrix.python-version}} | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
pip install invoke tox | ||
- name: Run static type checker | ||
id: pyright | ||
continue-on-error: true | ||
run: | | ||
if inv static-type-checks; then | ||
echo "pyright check passed" | ||
echo "pyright_failed=0" >> $GITHUB_OUTPUT | ||
else | ||
echo "pyright check failed" | ||
echo "pyright_failed=1" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Find Comment | ||
uses: peter-evans/find-comment@v2 | ||
id: find_comment | ||
if: ${{github.event_name == 'pull_request'}} | ||
continue-on-error: true | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: "github-actions[bot]" | ||
body-includes: ✨ Looks like pyright failed ✨ | ||
|
||
- uses: mshick/add-pr-comment@v2 | ||
if: ${{ steps.pyright.outputs.pyright_failed == 1 && github.event_name == 'pull_request'}} | ||
id: add_comment | ||
with: | ||
message: | | ||
✨ Looks like pyright failed ✨ | ||
If you want to fix this, we recommend doing it locally by either: | ||
a) Enabling pyright in VSCode and going through the errors in the problems tab | ||
`VSCode settings > Python > Analysis: Type checking mode > "basic"` | ||
b) Debugging via the command line | ||
1. Installing pyright, which is included in the dev dependencies: `pip install -e ".[dev]"` | ||
2. Diagnosing the errors by running `pyright .` | ||
- uses: mshick/add-pr-comment@v2 | ||
if: ${{ steps.pyright.outputs.pyright_failed == 0 && steps.find_comment.outputs.comment-id != '' && github.event_name == 'pull_request'}} | ||
with: | ||
message-id: ${{ steps.find_comment.outputs.comment-id }} | ||
message: | | ||
🌟 pyright succeeds! 🌟 | ||
- name: Show pyright output | ||
id: fail_run | ||
if: ${{steps.pyright.outputs.pyright_failed == 1}} | ||
run: | | ||
inv static-type-checks # Rerunning pyright isn't optimal computationally, but typically takes no more than a couple of seconds, and this ensures that the errors are in the failing step |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,23 +30,34 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
|
||
- name: Cache tox | ||
uses: actions/[email protected] | ||
id: cache_tox | ||
with: | ||
path: | | ||
.tox | ||
key: ${{ runner.os }}-${{ matrix.python-version }}-tests | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
id: setup_python | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' # caching pip dependencies | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
pip install .[tests] | ||
pip install invoke tox | ||
- name: Run and write pytest | ||
shell: bash | ||
run: | | ||
python -m pytest --durations=0 -x --junitxml=pytest.xml --cov-report=term-missing --cov=src/ tests/ | ||
source .venv/bin/activate | ||
pytest --durations=0 -n 2 -x --junitxml=pytest.xml --cov-report=term-missing --cov=src/ tests/ | ||
# Specifying two sets of "--pytest-args" is required for invoke to parse it as a list | ||
inv test --pytest-args="--durations=0" --pytest-args="--junitxml=pytest.xml --cov-report=term-missing --cov=src/" | ||
- name: Test report on failures | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
id: test_report_with_annotations | ||
|
@@ -62,6 +73,6 @@ jobs: | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' && github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (success() || failure()) }} | ||
with: | ||
create-new-comment: false | ||
report-only-changed-files: true | ||
report-only-changed-files: false | ||
pytest-coverage-path: pytest-coverage.txt | ||
junitxml-path: ./pytest.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.