Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
114 changes: 28 additions & 86 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,115 +1,57 @@
name: CI

on:
push:
branches:
- develop
pull_request:
branches:
- develop

env:
UV_SYSTEM_PYTHON: true

jobs:
test:
ci:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.12"]

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python for CI - ${{ matrix.python-version }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Initialize Pants
uses: pantsbuild/actions/init-pants@main
with:
# cache0 makes it easy to bust the cache if needed
# just increase the integer to start with a fresh cache
gha-cache-key: cache0-py${{ matrix.python_version }}
named-caches-hash: ${{ hashFiles('python-default.lock') }}
pants-ci-config: pants.ci.toml

- name: Run tests
run: |
make test-py
- name: Upload coverage
if: matrix.python-version == 3.12
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./dist/coverage/python/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true


test-codegen:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.12"]

name: Codegen Java 17 / Python ${{ matrix.python-version }}

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Download Corretto 17 JDK
run: |
download_url="https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- name: Set up Corretto 17 JDK
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz
java-version: 17
architecture: x64
distribution: 'corretto'

- name: clean and build without python
run: cd codegen && ./gradlew clean build
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Set Up Python for CI - ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Initialize Pants
uses: pantsbuild/actions/init-pants@main
with:
# cache0 makes it easy to bust the cache if needed
gha-cache-key: cache0-py${{ matrix.python_version }}
named-caches-hash: ${{ hashFiles('python-default.lock') }}
pants-ci-config: pants.ci.toml
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install smithy-python
- name: Setup workspace
run: |
make install-python-components
export UV_PROJECT_ENVIRONMENT="${pythonLocation}"
echo "UV_PROJECT_ENVIRONMENT=$UV_PROJECT_ENVIRONMENT" >> "$GITHUB_ENV"
make install
- name: clean and build without formatting/linting installed
run: cd codegen && ./gradlew clean build
- name: Check python packages
run: |
make check-py
- name: Install black
- name: Test python packages
run: |
python${{ matrix.python-version }} -m pip install --upgrade black
make test-py
- name: clean and build without linting installed
run: cd codegen && ./gradlew clean build
- name: Build python packages
run: |
make build-py
- name: Install mypy and other libraries necessary for typing
- name: Build (and test) java packages
run: |
python${{ matrix.python-version }} -m pip install --upgrade mypy pytest pytest-asyncio
make build-java
- name: clean and build with all optional tools installed
run: cd codegen && ./gradlew clean build
- name: Run protocol tests
run: |
make test-protocols
34 changes: 0 additions & 34 deletions .github/workflows/lint.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/protocol-test.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/typecheck.yml

This file was deleted.

8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,4 @@ coverage.xml
htmlcov
*.egg-info
dist

# Pants workspace files
/.pants.d/
/dist/
/.pids
/.pants.workdir.file_lock*
pants
.venv
16 changes: 0 additions & 16 deletions .pre-commit-config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 0 additions & 2 deletions BUILD

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ To send us a pull request, please:

1. Fork the repository.
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
3. Ensure local tests pass.
4. Run `./pants fmt ::`, `./pants lint ::`, and `./pants check ::` if you've changed any python source.
3. Ensure local tests pass (`make test-py` and `make test-protocols`).
4. Run `make lint-py` if you've changed any python sources.
4. Commit to your fork using clear commit messages.
5. Send us a pull request, answering any default questions in the pull request interface.
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
Expand Down
74 changes: 22 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,43 @@
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

pants: ## Installs pants launcher binary using the get-pants script. If $CI is true, assume it's installed already (through GHA), so just copy the wrapper script.
ifeq ($(CI),true)
cp scripts/pantsw pants
else
./get-pants --bin-dir .
endif

install: ## Sets up workspace (* you should run this first! *)
uv sync --all-packages --all-extras
cd codegen && ./gradlew
@printf "\n\nWorkspace initialized, please run:\n\033[36msource .venv/bin/activate\033[0m"

install-python-components: pants ## Packages and installs the python packages.
./pants package ::
python3 -m pip install dist/*.whl --force-reinstall


install-java-components: ## Publishes java packages to maven local.
cd codegen && ./gradlew publishToMavenLocal


install-components: install-python-components install-java-components ## Installs java and python components locally.


smithy-build: ## Builds the Java code generation packages.
build-java: ## Builds the Java code generation packages.
cd codegen && ./gradlew clean build


generate-protocol-tests: ## Generates the protocol tests, rebuilding necessary Java packages.
test-protocols: ## Generates and runs the restJson1 protocol tests.
cd codegen && ./gradlew :protocol-test:build
uv run pytest codegen/protocol-test/build/smithyprojections/protocol-test/rest-json-1/python-client-codegen


run-protocol-tests: ## Runs already-generated protocol tests.
cd codegen/protocol-test/build/smithyprojections/protocol-test/rest-json-1/python-client-codegen && \
python3 -m pip install '.[tests]' && \
python3 -m pytest tests


test-protocols: install-python-components generate-protocol-tests run-protocol-tests ## Generates and runs protocol tests.


lint-py: pants ## Runs formatters/fixers/linters for the python packages.
./pants fix lint python-packages/smithy-core::
./pants fix lint python-packages/smithy-http::
./pants fix lint python-packages/smithy-aws-core::
./pants fix lint python-packages/smithy-json::
./pants fix lint python-packages/smithy-event-stream::
./pants fix lint python-packages/aws-event-stream::
lint-py: ## Runs linters and formatters on the python packages.
uv run docformatter packages --in-place || true
uv run ruff check packages --fix
uv run ruff format packages


check-py: pants ## Runs checkers for the python packages.
./pants check python-packages/smithy-core::
./pants check python-packages/smithy-http::
./pants check python-packages/smithy-aws-core::
./pants check python-packages/smithy-json::
./pants check python-packages/smithy-event-stream::
./pants check python-packages/aws-event-stream::
check-py: ## Runs checks (formatting, lints, type-checking) on the python packages.
uv run docformatter packages
uv run ruff check packages
uv run pyright packages


test-py: pants ## Runs tests for the python packages.
./pants test python-packages/smithy-core::
./pants test python-packages/smithy-http::
./pants test python-packages/smithy-aws-core::
./pants test python-packages/smithy-json::
./pants test python-packages/smithy-event-stream::
./pants test python-packages/aws-event-stream::
test-py: ## Runs tests for the python packages.
uv run pytest packages


build-py: lint-py check-py test-py ## Runs formatters/fixers/linters/checkers/tests for the python packages.
build-py: ## Builds the python packages.
uv build --all-packages


clean: ## Clean up generated code and artifacts.
rm -rf dist/
clean: ## Clean up workspace, generated code, and other artifacts.
uv run virtualenv --clear .venv
rm -r dist .pytest_cache .ruff_cache || true
cd codegen && ./gradlew clean
Loading