Skip to content

Commit

Permalink
ci changes (#2)
Browse files Browse the repository at this point in the history
* ci changes

* things build...

* python build magic

* update publish flow

* update minor version

* remove version

* correct versions

* asdf

* fix cargo
  • Loading branch information
codekansas authored Nov 23, 2024
1 parent dd791cd commit bd4f3e9
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 1,004 deletions.
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[target.aarch64-apple-darwin]

rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
106 changes: 74 additions & 32 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,76 @@ concurrency:
cancel-in-progress: true

jobs:
build-rust:
name: Build and publish Rust package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Build and publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --package krec-rs
build-wheels:
needs: build-rust
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
name: Build Python wheels (${{ matrix.os }})
name: Build and publish Python package (${{ matrix.os }})
timeout-minutes: 10
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.10"

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cibuildwheel
shell: bash

- name: Build wheels
- name: Build package
env:
CIBW_SKIP: "pp* *-musllinux*" # Skip PyPy and musllinux builds
CIBW_BEFORE_BUILD: "pip install maturin"
CIBW_BUILD_BACKEND: "maturin"
CIBW_BEFORE_ALL_LINUX: |
yum install -y libudev-devel pkgconfig
CIBW_BEFORE_ALL_MACOS: |
brew install openssl pkg-config
CIBW_BEFORE_BUILD: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
pip install setuptools-rust
CIBW_ENVIRONMENT: |
PATH="/usr/local/bin:$HOME/.cargo/bin:$PATH"
CARGO_NET_GIT_FETCH_WITH_CLI=true
run: |
cd python
cibuildwheel --output-dir ../dist
cibuildwheel --output-dir dist
- name: Upload wheel artifacts
uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.os }}
path: dist/*.whl
path: |
dist/*.whl
build-source-dist:
needs: build-rust
name: Build Python source distribution
name: Build and publish Python package (source distribution)
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.10"

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install dependencies
run: |
Expand Down Expand Up @@ -123,3 +124,44 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: final_dist/

publish-rust:
name: Build and publish Rust package
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev pkg-config
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry
restore-keys: |
${{ runner.os }}-cargo-registry
- name: Cache Cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index
restore-keys: |
${{ runner.os }}-cargo-index
- name: Publish K-Rec package to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish -p krec
19 changes: 13 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ jobs:
with:
python-version: "3.11"

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev pkg-config
- name: Install protoc
uses: arduino/setup-protoc@v3

- name: Restore cache
id: restore-cache
uses: actions/cache/restore@v3
Expand All @@ -44,16 +52,15 @@ jobs:
- name: Install package
run: |
pip install --upgrade --upgrade-strategy eager --extra-index-url https://download.pytorch.org/whl/cpu -e '.[dev]'
pip install --upgrade --upgrade-strategy eager -e '.'
- name: Run static checks
- name: Check Rust lint
run: |
mkdir -p .mypy_cache
make static-checks
cargo fmt --check
- name: Run unit tests
- name: Run Rust tests
run: |
make test
cargo test
- name: Save cache
uses: actions/cache/save@v3
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ build/
dist/
*.so
out*/
*.pyi

# Rust
Cargo.lock
target/
Loading

0 comments on commit bd4f3e9

Please sign in to comment.