Skip to content

Commit 2b92533

Browse files
committed
add code qa workflows
1 parent 73ef7b5 commit 2b92533

File tree

7 files changed

+290
-0
lines changed

7 files changed

+290
-0
lines changed

.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
on:
3+
push:
4+
pull_request:
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
ruff:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.x"
16+
- uses: pypa/hatch@install
17+
- name: Run ruff linter and formatter
18+
run: hatch fmt --check
19+
mypy:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.x"
28+
- uses: pypa/hatch@install
29+
- name: Run mypy
30+
run: hatch run types:check

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [ published ]
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
release-build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.x"
16+
- name: Build release distributions
17+
run: |
18+
pip install build
19+
python -m build
20+
- name: upload windows dists
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: release-dists
24+
path: dist/
25+
pypi-publish:
26+
runs-on: ubuntu-latest
27+
needs:
28+
- release-build
29+
environment: release
30+
permissions:
31+
id-token: write
32+
steps:
33+
- name: Retrieve release distributions
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: release-dists
37+
path: dist/
38+
- name: Publish release distributions to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
on:
3+
push:
4+
pull_request:
5+
concurrency:
6+
group: test-${{ github.ref }}
7+
cancel-in-progress: true
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test:
13+
name: Test with ${{ matrix.py }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
py:
19+
- "3.13"
20+
- "3.12"
21+
- "3.11"
22+
- "3.10"
23+
- "3.9"
24+
steps:
25+
- uses: pypa/hatch@install
26+
- uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
29+
- name: Setup python for test ${{ matrix.py }}
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: ${{ matrix.py }}
33+
- name: Run test suite
34+
run: hatch test -py=${{ matrix.py }}

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ dependencies = [
3030
"astroid",
3131
]
3232

33+
[dependency-groups]
34+
dev = [
35+
"pytest",
36+
"mypy"
37+
]
38+
3339
[project.urls]
3440
Homepage = "https://github.com/djcopley/import-rewriter"
3541
Repository = "https://github.com/djcopley/import-rewriter.git"
@@ -38,6 +44,21 @@ Issues = "https://github.com/djcopley/import-rewriter/issues"
3844
[tool.hatch.version]
3945
source = "vcs"
4046

47+
[[tool.hatch.envs.hatch-test.matrix]]
48+
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
49+
50+
[tool.hatch.envs.types]
51+
template = "hatch-test"
52+
extra-dependencies = [
53+
"mypy~=1.0",
54+
]
55+
56+
[tool.hatch.envs.types.scripts]
57+
check = [
58+
"mypy {args:src/import_rewriter}",
59+
"mypy --explicit-package-bases tests"
60+
]
61+
4162
[tool.pytest.ini_options]
4263
addopts = [
4364
"--import-mode=importlib",

tests/conftest.py

Whitespace-only changes.

tests/test_rewrite.py

Whitespace-only changes.

uv.lock

Lines changed: 166 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)