Skip to content

Commit b49cefa

Browse files
committed
Simplify CI, add coverage, black, and rules
1 parent 14e5c3d commit b49cefa

File tree

8 files changed

+145
-328
lines changed

8 files changed

+145
-328
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,46 @@
11
name: CI
22

33
on:
4-
push:
5-
branches:
6-
- develop
74
pull_request:
85
branches:
96
- develop
107

118
jobs:
12-
test:
13-
runs-on: ubuntu-latest
14-
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
python-version: ["3.12"]
19-
20-
steps:
21-
- name: Checkout Repository
22-
uses: actions/checkout@v4
23-
24-
- name: Set up Python for CI - ${{ matrix.python-version }}
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version: ${{ matrix.python-version }}
28-
29-
- name: Initialize Pants
30-
uses: pantsbuild/actions/init-pants@main
31-
with:
32-
# cache0 makes it easy to bust the cache if needed
33-
# just increase the integer to start with a fresh cache
34-
gha-cache-key: cache0-py${{ matrix.python_version }}
35-
named-caches-hash: ${{ hashFiles('python-default.lock') }}
36-
pants-ci-config: pants.ci.toml
37-
38-
- name: Run tests
39-
run: |
40-
make test-py
41-
42-
- name: Upload coverage
43-
if: matrix.python-version == 3.12
44-
uses: codecov/codecov-action@v3
45-
with:
46-
token: ${{ secrets.CODECOV_TOKEN }}
47-
file: ./dist/coverage/python/coverage.xml
48-
flags: unittests
49-
name: codecov-umbrella
50-
fail_ci_if_error: true
51-
52-
53-
test-codegen:
9+
ci:
5410
runs-on: ubuntu-latest
55-
56-
strategy:
57-
fail-fast: false
58-
matrix:
59-
python-version: ["3.12"]
60-
61-
name: Codegen Java 17 / Python ${{ matrix.python-version }}
62-
6311
steps:
6412
- name: Checkout Repository
6513
uses: actions/checkout@v4
6614

67-
- name: Download Corretto 17 JDK
68-
run: |
69-
download_url="https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz"
70-
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
71-
72-
- name: Set up Corretto 17 JDK
15+
- name: Set up JDK 17
7316
uses: actions/setup-java@v4
7417
with:
75-
distribution: 'jdkfile'
76-
jdkFile: ${{ runner.temp }}/java_package.tar.gz
7718
java-version: 17
78-
architecture: x64
19+
distribution: 'corretto'
7920

80-
- name: clean and build without python
81-
run: cd codegen && ./gradlew clean build
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
8223

83-
- name: Set Up Python for CI - ${{ matrix.python-version }}
84-
uses: actions/setup-python@v5
85-
with:
86-
python-version: ${{ matrix.python-version }}
87-
88-
- name: Initialize Pants
89-
uses: pantsbuild/actions/init-pants@main
90-
with:
91-
# cache0 makes it easy to bust the cache if needed
92-
gha-cache-key: cache0-py${{ matrix.python_version }}
93-
named-caches-hash: ${{ hashFiles('python-default.lock') }}
94-
pants-ci-config: pants.ci.toml
95-
96-
- name: Install smithy-python
24+
- name: Setup workspace
9725
run: |
98-
make install-python-components
26+
make install
9927
100-
- name: clean and build without formatting/linting installed
101-
run: cd codegen && ./gradlew clean build
28+
- name: Check python packages
29+
run: |
30+
make check-py
10231
103-
- name: Install black
32+
- name: Test python packages
10433
run: |
105-
python${{ matrix.python-version }} -m pip install --upgrade black
34+
make test-py
10635
107-
- name: clean and build without linting installed
108-
run: cd codegen && ./gradlew clean build
36+
- name: Build python packages
37+
run: |
38+
make build-py
10939
110-
- name: Install mypy and other libraries necessary for typing
40+
- name: Build (and test) java packages
11141
run: |
112-
python${{ matrix.python-version }} -m pip install --upgrade mypy pytest pytest-asyncio
42+
make build-java
11343
114-
- name: clean and build with all optional tools installed
115-
run: cd codegen && ./gradlew clean build
44+
- name: Run protocol tests
45+
run: |
46+
make test-protocols

.github/workflows/lint.yml

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

.github/workflows/protocol-test.yml

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

.github/workflows/typecheck.yml

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

.pre-commit-config.yaml

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

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ test-protocols: ## Generates and runs the restJson1 protocol tests.
1818
uv run pytest codegen/protocol-test/build/smithyprojections/protocol-test/rest-json-1/python-client-codegen
1919

2020

21-
lint-py: ## Runs formatters/fixers/linters for the python packages.
22-
uv run docformatter --wrap-summaries 88 --wrap-description 88 packages -r -i || true
21+
lint-py: ## Runs linters and formatters on the python packages.
22+
uv run docformatter packages --in-place || true
2323
uv run ruff check packages --fix
2424
uv run ruff format packages
2525

2626

27-
check-py: ## Runs checkers for the python packages.
27+
check-py: ## Runs checks (formatting, lints, type-checking) on the python packages.
28+
uv run docformatter packages
2829
uv run ruff check packages
2930
uv run pyright packages
30-
uv run bandit packages -r -x tests
3131

3232

3333
test-py: ## Runs tests for the python packages.
3434
uv run pytest packages
3535

3636

37-
build-py: lint-py check-py test-py ## Builds (and lints, checks, and tests) the python packages.
37+
build-py: ## Builds the python packages.
3838
uv build --all-packages
3939

4040

pyproject.toml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ dependencies = []
88

99
[dependency-groups]
1010
dev = [
11-
"bandit>=1.8.3",
11+
"black>=25.1.0",
1212
"docformatter>=1.7.5",
1313
"pyright>=1.1.394",
1414
"pytest>=8.3.4",
1515
"pytest-asyncio>=0.25.3",
16+
"pytest-cov>=6.0.0",
1617
"ruff>=0.9.7",
1718
]
1819

@@ -35,16 +36,26 @@ typeCheckingMode = "strict"
3536

3637
[tool.pytest.ini_options]
3738
asyncio_mode = "auto" # makes pytest run async tests without having to be marked with the @pytest.mark.asyncio decorator
38-
addopts = [ "--import-mode=importlib" ]
39+
addopts = [ "--import-mode=importlib", "--cov", "--cov-report=term-missing" ]
40+
41+
[tool.docformatter]
42+
recursive = true
43+
black = true
3944

4045
[tool.ruff]
4146
target-version = "py312"
4247

4348
[tool.ruff.lint]
44-
# select = ["ASYNC", "F", "FURB", "G", "I", "LOG", "N", "Q", "T"]
45-
# candidates: C4, DTZ, EM, INP, ISC, PERF, PIE, RUF, SIM118, SIM401, SLOT, T20, UP, W
46-
# perhaps in the future: CPY, N, PYI, TC, TID
49+
# candidates: C4, DTZ, EM, INP, ISC, PERF, PIE, RUF, SIM118, SIM401, SLOT
50+
# perhaps in the future: N, PYI, TC, TID
4751
# probably not, a lot of work: DOC, D, PL, TRY
4852

53+
# TODO: I, T, UP
54+
select = [ "ASYNC", "E1", "E4", "E7", "E9", "F", "FURB", "G", "LOG", "S" ]
55+
exclude = [ "packages/smithy-core/src/smithy_core/rfc3986.py" ]
56+
57+
[tool.ruff.lint.per-file-ignores]
58+
"**/{tests}/*" = ["S"]
59+
4960
[tool.ruff.format]
5061
docstring-code-format = true

0 commit comments

Comments
 (0)