Skip to content

Commit

Permalink
Setup wheel publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Sep 17, 2024
1 parent a6c079c commit ae6866b
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: f8b63c7
_commit: 1e75fde
_src_path: .
add_extension: rust
email: 3105306+timkpaine@users.noreply.github.com
Expand Down
34 changes: 30 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Build Status

on:
Expand Down Expand Up @@ -49,12 +48,26 @@ jobs:
toolchain: stable
components: clippy, rustfmt

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}

- name: Setup rust targets (MacOS)
run: rustup target add aarch64-apple-darwin
if: matrix.os == 'macos-latest'

- name: Setup rust targets (Windows)
run: |
rustup toolchain install stable-i686-pc-windows-msvc
rustup target add i686-pc-windows-msvc
if: matrix.os == 'windows-latest'

- name: Install dependencies
run: make develop

- name: Lint
run: make lint
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Checks
run: make checks
Expand All @@ -65,7 +78,6 @@ jobs:

- name: Test
run: make coverage
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Upload test results (Python)
uses: actions/upload-artifact@v4
Expand All @@ -85,6 +97,20 @@ jobs:
uses: codecov/codecov-action@v4

- name: Make dist
run: make dist
run: |
dist-build-rust
dist-build-py-sdist
dist-build-py-wheel
dist-check
if: ${{ matrix.os == 'ubuntu-latest' }}

- name: Make dist
run: |
dist-build-py-wheel
dist-check
if: ${{ matrix.os != 'ubuntu-latest' }}

- uses: actions/upload-artifact@v4
with:
name: wheels
path: dist
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ develop-rust:

develop: develop-rust develop-py ## setup project for development

.PHONY: build-py build-rust build
.PHONY: build-py build-rust build dev
build-py:
maturin build

Expand Down Expand Up @@ -41,10 +41,11 @@ lint-py: ## run python linter with ruff
python -m ruff check rust_template
python -m ruff format --check rust_template

lint-rust: ## run the rust linter
lint-rust: ## run rust linter
make -C rust lint

lint: lint-rust lint-py ## run project linters

# alias
lints: lint

Expand All @@ -57,6 +58,7 @@ fix-rust: ## fix rust formatting
make -C rust fix

fix: fix-rust fix-py ## run project autoformatters

# alias
format: fix

Expand All @@ -79,26 +81,30 @@ annotate: ## run python type annotation checks with mypy
#########
# TESTS #
#########
.PHONY: test test-py coverage-py tests

.PHONY: test-py tests-py coverage-py
test-py: ## run python tests
python -m pytest -v rust_template/tests --junitxml=junit.xml

# alias
tests-py: test-py

coverage-py: ## run python tests and collect test coverage
python -m pytest -v rust_template/tests --junitxml=junit.xml --cov=rust_template --cov-branch --cov-fail-under=50 --cov-report term-missing --cov-report xml

.PHONY: test-rust tests-rust coverage-rust
test-rust: ## run rust tests
make -C rust test

# alias
tests-rust: test-rust

coverage-rust: ## run rust tests and collect test coverage
make -C rust coverage

.PHONY: test coverage tests
test: test-py test-rust ## run all tests
coverage: coverage-py coverage-rust ## run all tests and collect test coverage

# alias
tests: test

Expand All @@ -122,10 +128,13 @@ major: ## bump a major version
########
# DIST #
########
.PHONY: dist dist-build dist-sdist dist-local-wheel publish
.PHONY: dist-build-py-wheel dist-build-py-sdist dist-build-rust dist-check dist publish

dist-build-py-wheel: # build python wheel
python -m cibuildwheel --output-dir dist

dist-build-py: # build python dists
python -m build -w -s
dist-build-py-sdist: # build python sdist
python -m build --sdist -o dist

dist-build-rust: # build rust dists
make -C rust dist
Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ develop = [
"build",
"bump-my-version",
"check-manifest",
"cibuildwheel",
"maturin>=1,<2",
"pytest",
"pytest-cov",
Expand Down Expand Up @@ -80,6 +81,26 @@ ignore = [
"rust/README.md",
]

[tool.cibuildwheel]
before-build = "rustup show"
build = "cp39-*"
test-command = "pytest -vvv rust_template/tests"
test-requires = ["pytest", "pytest-cov", "pytest-sugar", "pytest-xdist"]

[tool.cibuildwheel.linux]
before-build ="curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && rustup show"
environment = {PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"}
skip = "*i686 musllinux*"
manylinux-x86_64-image = "manylinux_2_28"

[tool.cibuildwheel.macos]
archs = "arm64"

[tool.cibuildwheel.windows]
environment = {PATH="$UserProfile\.cargo\bin;$PATH"}
archs = "AMD64"
skip = "*win32 *arm_64"

[tool.pytest.ini_options]
asyncio_mode = "strict"
testpaths = "rust_template/tests"
Expand Down

0 comments on commit ae6866b

Please sign in to comment.