-
Notifications
You must be signed in to change notification settings - Fork 2
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
fcaca78
commit 8778915
Showing
6 changed files
with
71 additions
and
211 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 |
---|---|---|
|
@@ -9,55 +9,27 @@ on: | |
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
permissions: | ||
pull-requests: write | ||
build: | ||
concurrency: | ||
group: "${{ github.workflow }} @ ${{ github.ref }}" | ||
cancel-in-progress: true | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
token: ${{ secrets.PAT }} | ||
- name: Checkout (GitHub) | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install pre-commit | ||
run: pip install pre-commit | ||
|
||
- name: Run pre-commit | ||
id: pre_commit | ||
continue-on-error: true | ||
run: | | ||
if pre-commit run --color always --all-files; then | ||
echo "Pre-commit check passed" | ||
echo "pre_commit_failed=0" >> $GITHUB_OUTPUT | ||
else | ||
echo "Pre-commit check failed" | ||
echo "pre_commit_failed=1" >> $GITHUB_OUTPUT | ||
exit 1 | ||
fi | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Have this step before commit in case the PR is from a fork. In this case, we want the | ||
# add-pr-comment to fail, because it makes it means that the contributer is directed here, | ||
# and are given the informative error message, instead of directed to a "could not commit error message". | ||
- uses: mshick/add-pr-comment@v2 | ||
if: ${{ steps.pre_commit.outputs.pre_commit_failed == 1 && github.event_name == 'pull_request' }} | ||
id: add_comment | ||
- name: Pre-build dev container image | ||
uses: devcontainers/[email protected] | ||
with: | ||
message: | | ||
Looks like some formatting rules failed. You can: | ||
🏎️ Fix locally by running `inv pr` | ||
We also recommend setting up the `ruff` and `black` extensions to auto-format on save in your chosen editor. | ||
- name: Fail workflow | ||
if: ${{ steps.pre_commit.outputs.pre_commit_failed == 1 && github.event_name == 'pull_request' }} | ||
run: exit 1 | ||
imageName: ghcr.io/MartinBernstorff/personal-mnemonic-medium/ | ||
cacheFrom: ghcr.io/MartinBernstorff/personal-mnemonic-medium/ | ||
push: never | ||
runCmd: | ||
make lint |
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,95 +3,28 @@ | |
# 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 | ||
build: | ||
concurrency: | ||
group: "${{ github.workflow }} @ ${{ github.ref }}" | ||
cancel-in-progress: true | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.9"] | ||
runs-on: ubuntu-latest | ||
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: Checkout (GitHub) | ||
uses: actions/checkout@v3 | ||
|
||
- name: Find Comment | ||
uses: peter-evans/find-comment@v2 | ||
id: find_comment | ||
if: ${{github.event_name == 'pull_request'}} | ||
continue-on-error: true | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: "github-actions[bot]" | ||
body-includes: ✨ Looks like pyright failed ✨ | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: mshick/add-pr-comment@v2 | ||
if: ${{ steps.pyright.outputs.pyright_failed == 1 && github.event_name == 'pull_request'}} | ||
id: add_comment | ||
- name: Pre-build dev container image | ||
uses: devcontainers/[email protected] | ||
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 | ||
imageName: ghcr.io/MartinBernstorff/personal-mnemonic-medium/ | ||
cacheFrom: ghcr.io/MartinBernstorff/personal-mnemonic-medium/ | ||
push: never | ||
runCmd: | ||
make type-check |
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 |
---|---|---|
|
@@ -9,67 +9,29 @@ on: | |
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
pytest: | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: read | ||
issues: read | ||
checks: write | ||
pull-requests: write | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] #, macos-latest, windows-latest] | ||
python-version: ["3.9"] # , "3.10"] | ||
|
||
# This allows a subsequently queued workflow run to interrupt previous runs | ||
jobs: | ||
build: | ||
concurrency: | ||
group: "${{ github.workflow }}-${{ matrix.python-version}}-${{ matrix.os }} @ ${{ github.ref }}" | ||
group: "${{ github.workflow }} @ ${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
runs-on: ubuntu-latest | ||
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 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
pip install invoke tox | ||
- name: Run and write pytest | ||
shell: bash | ||
run: | | ||
# 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: Checkout (GitHub) | ||
uses: actions/checkout@v3 | ||
|
||
- name: Test report on failures | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
id: test_report_with_annotations | ||
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' && github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (success() || failure()) }} # Do not run for dependabot, run whether tests failed or succeeded | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
comment_mode: "failures" | ||
files: | | ||
pytest.xml | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Pytest coverage comment | ||
id: coverage-comment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' && github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (success() || failure()) }} | ||
- name: Pre-build dev container image | ||
uses: devcontainers/[email protected] | ||
with: | ||
create-new-comment: false | ||
report-only-changed-files: false | ||
pytest-coverage-path: pytest-coverage.txt | ||
junitxml-path: ./pytest.xml | ||
imageName: ghcr.io/MartinBernstorff/personal-mnemonic-medium/ | ||
cacheFrom: ghcr.io/MartinBernstorff/personal-mnemonic-medium/ | ||
push: never | ||
runCmd: | ||
make test |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
lint: | ||
pre-commit run --all-files | ||
|
||
test: | ||
pytest -n auto -rfE --failed-first --disable-warnings -q | ||
|
||
type-check: | ||
pyright . | ||
|
||
pr: | ||
make lint & make test & make type-check | ||
git push | ||
gh pr create | ||
gh pr merge --auto --merge |
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