Skip to content

Commit

Permalink
Improve CI workflows, add support for aarch64-unknown-linux-musl prec…
Browse files Browse the repository at this point in the history
…ompiled binaries (#386)

* document hex publish instructions

* fix errors in rust CI actions

It seems actions-rs/toolchain#221 will not be solved anytime soon. So we switch to `dtolnay/toolchain@v1` to setup Rust in CI.

* Add support for prebuild binaries for aarch64-unknown-linux-musl

* update Rust release toolchain and Cross dep

* update elixir required version in mix.exs and update to v0.8.1-dev

* prepare changelog

* fix uses of ::set-output in CI as they are deprecated

see https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

* use correct name for dtolnay/rust-toolchain@stablex

* pipe outputs to $GITHUB_OUTPUT

* add target-feature=-crt-static rustflag for aarch64-unknown-linux-musl

* bash is Fun

* revert .gitignore changes
  • Loading branch information
tessi authored Jan 3, 2023
1 parent e592d23 commit 1df863f
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compatibility-elixir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/elixir-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
default: true

- id: get-cache-key
run: echo "::set-output name=key::mix-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}"
run: echo "key=mix-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}" >> $GITHUB_OUTPUT

- uses: actions/cache@v2
id: cache-deps
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
_build
key: ${{ needs.deps.outputs.deps-cache-key }}

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
# cranelift-codegen panics at 'error when identifying target: "no supported isa found for arch `arm`"'
# - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-apple-darwin , os: macos-11 }
- { target: x86_64-apple-darwin , os: macos-11 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
Expand Down Expand Up @@ -64,7 +65,7 @@ jobs:
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' ../../mix.exs | head -n1)" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.job.target }}
Expand All @@ -86,8 +87,8 @@ jobs:
if: ${{ matrix.job.use-cross }}
with:
binary: "cross"
version: "v0.2.1"
download_url: "https://github.com/rust-embedded/cross/releases/download/${version}/cross-${version}-x86_64-unknown-linux-gnu.tar.gz"
version: "v0.2.2"
download_url: "https://github.com/cross-rs/cross/releases/download/${version}/cross-x86_64-unknown-linux-gnu.tar.gz"
tarball_binary_path: "${binary}"
smoke_test: "${binary} --version"

Expand Down Expand Up @@ -145,8 +146,8 @@ jobs:
LIB_FINAL_PATH="${NIF_DIRECTORY}/${LIB_FINAL_NAME}.tar.gz"
# Let subsequent steps know where to find the lib
echo ::set-output name=LIB_FINAL_PATH::${LIB_FINAL_PATH}
echo ::set-output name=LIB_FINAL_NAME::${LIB_FINAL_NAME}.tar.gz
echo "LIB_FINAL_PATH=${{ LIB_FINAL_PATH }}" >> $GITHUB_OUTPUT
echo "LIB_FINAL_NAME=${{ LIB_FINAL_NAME }}.tar.gz" >> $GITHUB_OUTPUT
- name: "Artifact upload"
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
Expand Down
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ Types of changes
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [unreleased changes]
## [0.8.1] - unreleased

### Added

* Added precompiled binary for `aarch64-unknown-linux-musl`

### Changed

* `mix.exs` now also requires at least Elixir 1.12

please add changes here
## [0.8.0] - 2023-01-03

This release brings some changes to our API because of the change of the underlying WASM engine to [wasmtime](https://wasmtime.dev/).
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,25 @@ In addition to tests, we expect the formatters and linters (`cargo fmt`, `cargo

Your contributions will be licenced under the same license as this project.

### Release

To release this package, make sure CI is green, increase the package version, and:

```
git tag -a v0.8.0 # change version accordingly, copy changelog into tag message
git push --tags
mix rustler_precompiled.download Wasmex.Native --all --ignore-unavailable --print
```

Inspect it's output carefully, but ignore NIF version `2.14` and `arm-unknown-linux-gnueabihf` arch errors because we don't build for them.
Now inspect the checksum-Elixir.Wasmex.Native.exs file - it should include all prebuilt binaries in their checksums

Then continue with

```
mix hex.publish
```

## License

The entire project is under the MIT License. Please read [the`LICENSE` file](https://github.com/tessi/wasmex/blob/master/LICENSE).
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
defmodule Wasmex.MixProject do
use Mix.Project

@version "0.8.0"
@version "0.8.1-dev"

def project do
[
app: :wasmex,
version: @version,
elixir: "~> 1.10",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
name: "wasmex",
description: description(),
Expand Down
17 changes: 8 additions & 9 deletions native/wasmex/.cargo/config
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
[target.x86_64-apple-darwin]
[target.'cfg(target_os = "macos")']
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

# See https://github.com/rust-lang/rust/issues/59302
[target.x86_64-unknown-linux-musl]
rustflags = [
"-C", "target-feature=-crt-static"
]

[target.aarch64-unknown-linux-musl]
rustflags = [
"-C", "target-feature=-crt-static"
]

# Provides a small build size, but takes more time to build.
[profile.release]
lto = true
4 changes: 4 additions & 0 deletions native/wasmex/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build.env]
passthrough = [
"RUSTLER_NIF_VERSION"
]

0 comments on commit 1df863f

Please sign in to comment.