Skip to content

Commit

Permalink
feat(rust): Added PYO3 rust bindings and updated CI/CD.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Rust is required.
  • Loading branch information
aaronmussig committed Sep 26, 2022
1 parent 9040d00 commit 7d28848
Show file tree
Hide file tree
Showing 24 changed files with 3,171 additions and 2,263 deletions.
5 changes: 5 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
184 changes: 184 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: Version, build, publish

on:
push:
branches:
- main

jobs:

semantic_release_next_version:
name: Next version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: 16
- run: npm install
- run: npx semantic-release --dry-run
id: semantic_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
with:
name: semantic-release
path: |
magna/__init__.py
CHANGELOG.md
retention-days: 1
outputs:
version: ${{ steps.semantic_release.outputs.version }}

docs_build:
name: Build docs
runs-on: ubuntu-latest
needs: ['semantic_release_next_version']
steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: semantic-release
- name: Install package requirements
run: |
python -m pip install --upgrade pip
python -m pip install .
- name: Install Sphinx requirements
working-directory: docs
run: python -m pip install -r requirements.txt
- name: Build documentation
working-directory: docs
run: |
make html
touch build/html/.nojekyll
- uses: actions/upload-artifact@v3
with:
name: docs_build
path: docs/build/html/
retention-days: 1

# Update the GitHub pages branch
docs_deploy:
name: Deploy docs
runs-on: ubuntu-latest
needs: ['docs_build']
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- uses: actions/download-artifact@v3
with:
name: docs_build
- name: Upload documentation
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add --all
git diff-index --quiet HEAD || git commit -m "docs update" -a
git push
test_rust:
name: Build Rust
needs: semantic_release_next_version
if: needs.semantic_release_next_version.outputs.version != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features

build_python_wheels:
name: Python ${{ matrix.pyver }}@${{ matrix.os }}.whl
needs: semantic_release_next_version
if: needs.semantic_release_next_version.outputs.version != ''
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
pyver: [cp38, cp39, cp310, cp311]

steps:
- uses: actions/checkout@v3
- uses: pypa/cibuildwheel@v2.10.0
env:
CIBW_BUILD: ${{matrix.pyver}}-*
- uses: actions/upload-artifact@v3
with:
name: pypi
path: wheelhouse/*.whl
retention-days: 1

build_python_dist:
name: Python build *.tar.gz
runs-on: ubuntu-latest
needs: semantic_release_next_version
if: needs.semantic_release_next_version.outputs.version != ''
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
name: pypi
path: dist/*.tar.gz
retention-days: 1

test_python_dist:
name: Python test *.tar.gz
runs-on: ubuntu-latest
needs: build_python_dist
steps:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/download-artifact@v3
with:
name: pypi
path: dist
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python -m pip install dist/*.tar.gz
- run: python -m unittest discover ./test

semantic_release_publish:
name: Publish to GitHub
needs: [test_rust, test_python_dist, build_python_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: 16
- run: npm install
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

upload_pypi:
name: Publish to PyPI
needs: [test_rust, test_python_dist, build_python_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: pypi
path: dist

- uses: pypa/gh-action-pypi-publish@v1.5
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
25 changes: 0 additions & 25 deletions .github/workflows/pypi-publish.yml

This file was deleted.

88 changes: 0 additions & 88 deletions .github/workflows/semantic-release.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,8 @@ node_modules/

# Local script for running docs
docs.sh


# Added by cargo

/target
9 changes: 2 additions & 7 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"tagFormat": "v${version}",
"branches": [
"main",
{
"name": "develop",
"channel": "prerelease",
"prerelease": "prerelease"
}
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
Expand All @@ -20,7 +15,7 @@
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogFile": "CHANGELOG.md"
}
],
[
Expand Down

0 comments on commit 7d28848

Please sign in to comment.