Skip to content

Commit

Permalink
chore: use rust-toolchain.toml for components
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Mar 31, 2024
1 parent c464e63 commit 2a380c8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
33 changes: 15 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ jobs:
# '--target', 'x86_64-linux-android',

build_binaries:
name: 📦️ Build binaries for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
name: 📦️ Binaries for ${{ matrix.os }} (${{ matrix.target }})
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: linux
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
- os: macos
target: x86_64-apple-darwin
- os: macos-latest
- os: macos
target: aarch64-apple-darwin
- os: windows-latest
- os: windows
target: x86_64-pc-windows-msvc
- os: windows-latest
- os: windows
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v4

- name: Add target
- name: Add cross-compilation target
run: rustup update && rustup target add ${{ matrix.target }}

- name: Install aarch64 linux dependencies
Expand All @@ -69,23 +69,23 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: nanopub_${{ matrix.target }}
path: target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'Windows' && '.exe' || '' }}
path: target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'windows' && '.exe' || '' }}

- if: startsWith(github.ref, 'refs/tags/')
name: Prepare for release
run: |
mv target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'Windows' && '.exe' || '' }} nanopub_${{ matrix.target }}${{ matrix.os == 'Windows' && '.exe' || '' }}
mv target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'windows' && '.exe' || '' }} nanopub_${{ matrix.target }}${{ matrix.os == 'windows' && '.exe' || '' }}
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
nanopub_${{ matrix.target }}${{ matrix.os == 'Windows' && '.exe' || '' }}
nanopub_${{ matrix.target }}${{ matrix.os == 'windows' && '.exe' || '' }}
# Inspired by https://github.com/pydantic/pydantic-core/blob/main/.github/workflows/ci.yml
build_wheels:
name: 🐍 Build wheel for ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.interpreter || 'all' }}${{ matrix.os == 'linux' && format(' - {0}', matrix.manylinux == 'auto' && 'manylinux' || matrix.manylinux) || '' }})
name: 🐍 Wheels for ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.interpreter || 'all' }}${{ matrix.os == 'linux' && format(' - {0}', matrix.manylinux == 'auto' && 'manylinux' || matrix.manylinux) || '' }})
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -125,15 +125,13 @@ jobs:
manylinux: musllinux_1_1
target: aarch64

# macos
# all versions x86_64
# arm pypy and older pythons which can't be run on the arm hardware for PGO
# MacOS
- os: macos
target: x86_64
- os: macos
target: aarch64

# windows
# Windows
# x86_64 pypy builds are not PGO optimized, i686 not supported by pypy, aarch64 only 3.11 and up, also not PGO optimized
- os: windows
target: x86_64
Expand Down Expand Up @@ -168,8 +166,7 @@ jobs:
uses: PyO3/maturin-action@v1
env:
CFLAGS_aarch64_unknown_linux_gnu: -D__ARM_ARCH=8
# ring linux aarch64 error: https://github.com/briansmith/ring/issues/1789
# https://github.com/briansmith/ring/issues/1728
# NOTE: ring linux aarch64 error: https://github.com/briansmith/ring/issues/1728
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update && rustup component add clippy rustfmt
- run: rustup update
# - run: rustup update && rustup component add clippy rustfmt
- run: cargo fmt -- --check
- run: cargo clippy --all --all-targets --all-features

Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ repos:
entry: cargo deny check licenses
language: system
pass_filenames: false
# NOTE: better done from the commandline since we install it already with cargo
# - repo: https://github.com/EmbarkStudios/cargo-deny
# rev: 0.14.20
# hooks:
# - id: cargo-deny
# args: ["--all-features", "check", "licenses"]
ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
9 changes: 7 additions & 2 deletions lib/docs/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ nanopub-rs/
- Trusty URI code is calculated on normalized representation that includes signature
- Trusty URI code is added in place of all the occurrences of blank spaces in the URIs, leading to the final trusty nanopub

### Notes about maintenance and stability

Cross-compiling to many targets brings some complexity to the build process, especially that the nanopub lib packs a lot of features: processing RDF, RSA signing and key generation, querying a HTTP server, getting current datetime access.

This means we need to make sure the dependencies we use works for all targets.

### ☑️ To do

- [ ] Add possibility to build the nanopub from scratch for JS and python
Expand Down Expand Up @@ -73,8 +79,7 @@ pre-commit install

# Install rust dev tools
rustup update
rustup component add rustfmt clippy
cargo install wasm-pack cargo-tarpaulin cargo-deny cargo-make git-cliff
cargo install wasm-pack cargo-tarpaulin cargo-deny git-cliff
```

### 📥️ Clone the repository
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "stable"
# components = [ "rustfmt", "clippy" ]
# targets = [ "wasm32-unknown-unknown" ]
components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ]
# profile = "minimal"
2 changes: 1 addition & 1 deletion scripts/install-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source .venv/bin/activate
pip install maturin pre-commit

rustup update
rustup component add rustfmt clippy
# rustup component add rustfmt clippy

cargo install wasm-pack cargo-tarpaulin cargo-deny cargo-make git-cliff

Expand Down

0 comments on commit 2a380c8

Please sign in to comment.