Skip to content

Commit

Permalink
CI workflow updates and clippy lint fixes (#615)
Browse files Browse the repository at this point in the history
* apply latest rust/clippy lints

* update CI workflows

* document release process
  • Loading branch information
tessi authored Jul 27, 2024
1 parent 59b57d0 commit 4b41a93
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compatibility-elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- otp: 27.0
elixir: 1.16.1
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/elixir-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
outputs:
deps-cache-key: ${{ steps.get-cache-key.outputs.key }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
Expand All @@ -31,7 +31,7 @@ jobs:
- id: get-cache-key
run: echo "key=mix-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ hashFiles('**/mix.lock') }}" >> $GITHUB_OUTPUT

- uses: actions/cache@v2
- uses: actions/cache@v4
id: cache-deps
with:
path: |
Expand All @@ -46,13 +46,13 @@ jobs:
needs: deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}

- uses: actions/cache@v2
- uses: actions/cache@v4
id: cache-deps
with:
path: |
Expand All @@ -66,7 +66,7 @@ jobs:
needs: deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
Expand All @@ -78,13 +78,13 @@ jobs:
needs: deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}

- uses: actions/cache@v2
- uses: actions/cache@v4
id: cache-deps
with:
path: |
Expand All @@ -98,13 +98,13 @@ jobs:
needs: deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}

- uses: actions/cache@v2
- uses: actions/cache@v4
id: cache-deps
with:
path: |
Expand All @@ -121,7 +121,7 @@ jobs:
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasi
- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

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

- name: Extract crate information
shell: bash
Expand Down Expand Up @@ -79,13 +79,13 @@ jobs:
cargo-args: ${{ matrix.job.cargo-args }}

- name: Artifact upload
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build-crate.outputs.file-name }}
path: ${{ steps.build-crate.outputs.file-path }}

- name: Publish archives and packages
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: |
${{ steps.build-crate.outputs.file-path }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt, clippy

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand Down
12 changes: 12 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# How to release a new version of Wasmex

1. Make sure CI is green and `CHANGELOG.md` is up to date
1. Increase the package version in `mix.exs`, `README.md` and `Cargo.toml` - best grep for the current version and replace it
1. Commit the version bump and push it
1. Tag the commit with the new version number `git tag -a v0.8.0` - copy the changelog into the tag message
1. Push the tag `git push --tags`
1. Wait for the CI to create the github release and precompied binaries
1. Edit the GitHub release with the `CHANGELOG.md` content
1. Download the precompiled binaries with `mix rustler_precompiled.download Wasmex.Native --all --ignore-unavailable --print`
1. Inspect the output and the checksum-Elixir.Wasmex.Native.exs file
1. Continue with `mix hex.publish`
5 changes: 0 additions & 5 deletions native/wasmex/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Due to a clippy bug it thinks we needlessly borrow stuff
// when defining the ExStoreLimits struct
// see: https://github.com/rust-lang/rust-clippy/issues/9778
#![allow(clippy::needless_borrow)]

use rustler::{Binary, Error, NifStruct, OwnedBinary, Resource, ResourceArc};
use std::ops::Deref;
use std::sync::Mutex;
Expand Down
8 changes: 6 additions & 2 deletions native/wasmex/src/instance.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Clippy regression in rust 1.80.0
// see: https://github.com/rust-lang/rust-clippy/issues/13170
#![allow(clippy::needless_borrows_for_generic_args)]

use crate::{
atoms,
environment::{link_imports, link_modules, CallbackTokenResource},
Expand Down Expand Up @@ -111,7 +115,7 @@ pub fn get_global_value(
)))
})?;

let value = global.get(&mut store_or_caller);
let value = global.get(store_or_caller);

match value {
Val::I32(i) => Ok(i.encode(env)),
Expand Down Expand Up @@ -177,7 +181,7 @@ pub fn set_global_value(
};

global
.set(&mut store_or_caller, val)
.set(store_or_caller, val)
.map_err(|e| rustler::Error::Term(Box::new(format!("Could not set global: {e}"))))
}

Expand Down
4 changes: 2 additions & 2 deletions native/wasmex/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ enum WasmValueType {
Ref(String),
}

impl<'a> Encoder for WasmValueType {
fn encode<'b>(&self, env: Env<'b>) -> Term<'b> {
impl Encoder for WasmValueType {
fn encode<'a>(&self, env: Env<'a>) -> Term<'a> {
match self {
Self::I32 => atoms::i32().encode(env),
Self::I64 => atoms::i64().encode(env),
Expand Down
9 changes: 2 additions & 7 deletions native/wasmex/src/store.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Due to a clippy bug it thinks we needlessly borrow stuff
// when defining the ExStoreLimits struct
// see: https://github.com/rust-lang/rust-clippy/issues/9778
#![allow(clippy::needless_borrow)]

use crate::{
caller::{get_caller, get_caller_mut},
engine::{unwrap_engine, EngineResource},
Expand Down Expand Up @@ -223,7 +218,7 @@ pub fn set_fuel(
})?);
match store_or_caller {
StoreOrCaller::Store(store) => store.set_fuel(fuel),
StoreOrCaller::Caller(token) => get_caller_mut(&token)
StoreOrCaller::Caller(token) => get_caller_mut(token)
.ok_or_else(|| {
rustler::Error::Term(Box::new(
"Caller is not valid. Only use a caller within its own function scope.",
Expand All @@ -244,7 +239,7 @@ pub fn get_fuel(
})?);
match store_or_caller {
StoreOrCaller::Store(store) => store.get_fuel(),
StoreOrCaller::Caller(token) => get_caller_mut(&token)
StoreOrCaller::Caller(token) => get_caller_mut(token)
.ok_or_else(|| {
rustler::Error::Term(Box::new(
"Caller is not valid. Only use a caller within its own function scope.",
Expand Down

0 comments on commit 4b41a93

Please sign in to comment.