Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(typeannotation): GitHub action to check files changed in a PR #15

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/mypy-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Type annotation (PR)

on:
pull_request:
paths:
- 'datasalad/**.py'
- '!**/tests/**.py'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
# run on a "fresh" python, but see mypy flag to check for the oldest supported version
python-version: 3.12
architecture: x64
- name: Checkout
uses: actions/checkout@v4
- name: Install mypy
run: python -m pip install mypy # you can pin your preferred version
- name: Get Python changed files
id: changed-py-files
uses: tj-actions/changed-files@v44
with:
files: |
*.py
**/*.py
- name: Type check changed files
if: steps.changed-py-files.outputs.any_changed == 'true'
run: |
# get any type stubs that mypy thinks it needs
mypy --install-types --non-interactive --follow-imports skip ${{ steps.changed-py-files.outputs.all_changed_files }}
# run mypy on the modified files only, and do not even follow imports.
# this results is a fairly superficial test, but given the overall
# state of annotations, we strive to become more correct incrementally
# with focused error reports, rather than barfing a huge complaint
# that is unrelated to the changeset someone has been working on.
# run on the oldest supported Python version
mypy --python-version 3.8 --follow-imports skip --pretty --show-error-context ${{ steps.changed-py-files.outputs.all_changed_files }}
29 changes: 29 additions & 0 deletions .github/workflows/mypy-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Type annotation (project)

on:
push:
paths:
- 'datasalad/**.py'
- '!**/tests/**.py'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
# run on a "fresh" python, but see mypy flag to check for the oldest supported version
python-version: 3.12
architecture: x64
- name: Checkout
uses: actions/checkout@v4
- name: Install mypy
run: python -m pip install mypy # you can pin your preferred version
- name: Type check changed files
run: |
# get any type stubs that mypy thinks it needs
mypy --install-types --non-interactive --follow-imports skip datasalad
# run mypy on the full project.
# run on the oldest supported Python version
mypy --python-version 3.8 --pretty --show-error-context datasalad
2 changes: 1 addition & 1 deletion datasalad/dummy.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def not_covered():
def not_covered() -> None:
pass
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ schema_pattern = "(?s)(ci|doc|feat|fix|perf|rf|style|test|chore|revert|bump)(\\(
"^fix" = "PATCH"

[tool.commitizen.customize.change_type_map]
"BREAKING CHANGE" = "🪓 Breaking changes"
doc = "📝 Documentation"
feat = "💫 New features"
fix = "🐛 Bug Fixes"
test = "🛡 Tests"
rf = "🏠 Refactorings"
perf = "🚀 Performance improvements"
"BREAKING CHANGE" = "Breaking changes"
doc = "Documentation"
feat = "New features"
fix = "Bug Fixes"
test = "Tests"
rf = "Refactorings"
perf = "Performance improvements"