diff --git a/.github/workflows/compatibility-elixir.yaml b/.github/workflows/compatibility-elixir.yml similarity index 80% rename from .github/workflows/compatibility-elixir.yaml rename to .github/workflows/compatibility-elixir.yml index 0d69b4f4..8ed50b5a 100644 --- a/.github/workflows/compatibility-elixir.yaml +++ b/.github/workflows/compatibility-elixir.yml @@ -17,14 +17,10 @@ jobs: strategy: fail-fast: false matrix: - otp: [24.3, 25.2, 26.0] - elixir: [1.12.3, 1.13.4, 1.14.4] + otp: [24.3, 25.2, 26.1] + elixir: [1.13.4, 1.14.5, 1.15.6] exclude: - - otp: 25.2 - elixir: 1.12.3 - - otp: 26.0 - elixir: 1.12.3 - - otp: 26.0 + - otp: 26.1 elixir: 1.13.4 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/elixir-ci.yaml b/.github/workflows/elixir-ci.yml similarity index 98% rename from .github/workflows/elixir-ci.yaml rename to .github/workflows/elixir-ci.yml index 9bde4d25..5e415911 100644 --- a/.github/workflows/elixir-ci.yaml +++ b/.github/workflows/elixir-ci.yml @@ -7,8 +7,8 @@ on: - main env: - ELIXIR_VERSION: 1.14.4 - OTP_VERSION: 26.0 + ELIXIR_VERSION: 1.15.6 + OTP_VERSION: 26.1 MIX_ENV: test WASMEX_BUILD: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 024248c1..00000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,164 +0,0 @@ -name: Build precompiled NIFs - -env: - NIF_DIRECTORY: "native/wasmex" - -on: - push: - branches: - # Always run on main branch. - - main - tags: - # Tags will always run. - - '*' - pull_request: - paths: - # Run if "native" path changed. - - 'native/**' - -defaults: - run: - shell: bash - # Sets the working dir for "run" scripts. - # Note that this won't change the directory for actions (tasks with "uses"). - working-directory: "./native/wasmex" - -jobs: - build_release: - name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) - runs-on: ${{ matrix.job.os }} - strategy: - fail-fast: false - matrix: - nif: - # see: https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_nif.h - - "2.15" # OTP 22, OTP 23 - - "2.16" # OTP 24, OTP 25 - - "2.17" # OTP 26 - job: - # 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: riscv64gc-unknown-linux-gnu , 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 } - - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true } - - { target: x86_64-pc-windows-gnu , os: windows-2019 } - - { target: x86_64-pc-windows-msvc , os: windows-2019 } - - env: - RUSTLER_NIF_VERSION: ${{ matrix.nif }} - steps: - - name: Checkout source code - uses: actions/checkout@v3 - - - name: Install prerequisites - run: | - case ${{ matrix.job.target }} in - arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; - aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; - esac - - - name: Extract crate information - run: | - echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV - # Get the project version from mix.exs - echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' ../../mix.exs | head -n1)" >> $GITHUB_ENV - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - target: ${{ matrix.job.target }} - - - name: Show version information (Rust, cargo, GCC) - run: | - gcc --version || true - rustup -V - rustup toolchain list - rustup default - cargo -V - rustc -V - rustc --print=cfg - - - name: Download cross from GitHub releases - uses: giantswarm/install-binary-action@v1.0.0 - if: ${{ matrix.job.use-cross }} - with: - binary: "cross" - 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" - - - name: Build - run: | - if [ "${{ matrix.job.use-cross }}" == "true" ]; then - cross build --release --target=${{ matrix.job.target }} - else - cargo build --release --target=${{ matrix.job.target }} - fi - - - name: Rename lib to the final name - id: rename - run: | - LIB_PREFIX="lib" - case ${{ matrix.job.target }} in - *-pc-windows-*) LIB_PREFIX="" ;; - esac; - - # Figure out suffix of lib - # See: https://doc.rust-lang.org/reference/linkage.html - LIB_SUFFIX=".so" - case ${{ matrix.job.target }} in - *-apple-darwin) LIB_SUFFIX=".dylib" ;; - *-pc-windows-*) LIB_SUFFIX=".dll" ;; - esac; - - CICD_INTERMEDIATES_DIR=$(mktemp -d) - - # Setup paths - LIB_DIR="${CICD_INTERMEDIATES_DIR}/released-lib" - mkdir -p "${LIB_DIR}" - LIB_NAME="${LIB_PREFIX}${{ env.PROJECT_NAME }}${LIB_SUFFIX}" - LIB_PATH="${LIB_DIR}/${LIB_NAME}" - - # Copy the release build lib to the result location - cp "target/${{ matrix.job.target }}/release/${LIB_NAME}" "${LIB_DIR}" - - # Final paths - # In the end we use ".so" for MacOS in the final build - # See: https://www.erlang.org/doc/man/erlang.html#load_nif-2 - LIB_FINAL_SUFFIX="${LIB_SUFFIX}" - case ${{ matrix.job.target }} in - *-apple-darwin) LIB_FINAL_SUFFIX=".so" ;; - esac; - - LIB_FINAL_NAME="${LIB_PREFIX}${PROJECT_NAME}-v${PROJECT_VERSION}-nif-${RUSTLER_NIF_VERSION}-${{ matrix.job.target }}${LIB_FINAL_SUFFIX}" - - # Copy lib to final name on this directory - cp "${LIB_PATH}" "${LIB_FINAL_NAME}" - - tar -cvzf "${LIB_FINAL_NAME}.tar.gz" "${LIB_FINAL_NAME}" - - # Passes the path relative to the root of the project. - LIB_FINAL_PATH="${NIF_DIRECTORY}/${LIB_FINAL_NAME}.tar.gz" - - # Let subsequent steps know where to find the lib - 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@v3 - with: - name: ${{ steps.rename.outputs.LIB_FINAL_NAME }} - path: ${{ steps.rename.outputs.LIB_FINAL_PATH }} - - - name: Publish archives and packages - uses: softprops/action-gh-release@v1 - with: - files: | - ${{ steps.rename.outputs.LIB_FINAL_PATH }} - if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..6ab6994a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +name: Precompile NIFs + +on: + push: + branches: + # Always run on main branch. + - main + tags: + # Tags will always run. + - '*' + pull_request: + paths: + - ".github/workflows/release.yml" + workflow_dispatch: + +jobs: + build_release: + name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) + runs-on: ${{ matrix.job.os }} + permissions: + contents: write + strategy: + fail-fast: false + matrix: + # we list the oldest OTP version that supports all features needed, have a look at the + # erlang docs for the OTP version to see which NIF version is in which OTP release + # https://github.com/erlang/otp/blob/master/erts/emulator/beam/erl_nif.h + # - "2.15" # OTP 22, OTP 23 + # - "2.16" # OTP 24, OTP 25 + # - "2.17" # OTP 26 + nif: ["2.15"] + job: + # 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 } + - { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, use-cross: true } + - { target: riscv64gc-unknown-linux-gnu, os: ubuntu-20.04, use-cross: true, cargo-args: "--no-default-features"} + - { target: x86_64-pc-windows-gnu, os: windows-2022 } + - { target: x86_64-pc-windows-msvc, os: windows-2022 } + - { target: x86_64-unknown-freebsd, os: ubuntu-22.04, use-cross: true, cross-version: v0.2.5 } + + steps: + - name: Checkout source code + uses: actions/checkout@v3 + + - name: Extract crate information + shell: bash + run: | + # Get the project version from mix.exs + echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV + + - name: Add target + shell: bash + run: | + rustup target add ${{ matrix.job.target }} + + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: v0-precomp + shared-key: ${{ matrix.job.target }}-${{ matrix.nif }} + workspaces: | + native/wasmex + + - name: Build the project + id: build-crate + uses: philss/rustler-precompiled-action@52c1b8dd1ed8c7fcd90ca71b177aabbd3b29b95b + with: + project-name: wasmex + project-version: ${{ env.PROJECT_VERSION }} + target: ${{ matrix.job.target }} + nif-version: ${{ matrix.nif }} + use-cross: ${{ matrix.job.use-cross }} + cross-version: ${{ matrix.job.cross-version || 'v0.2.4' }} + project-dir: "native/wasmex" + cargo-args: ${{ matrix.job.cargo-args }} + + - name: Artifact upload + uses: actions/upload-artifact@v3 + 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 + with: + files: | + ${{ steps.build-crate.outputs.file-path }} + if: startsWith(github.ref, 'refs/tags/') \ No newline at end of file diff --git a/.github/workflows/rust-ci.yaml b/.github/workflows/rust-ci.yml similarity index 96% rename from .github/workflows/rust-ci.yaml rename to .github/workflows/rust-ci.yml index 6de430a8..d09a8faf 100644 --- a/.github/workflows/rust-ci.yaml +++ b/.github/workflows/rust-ci.yml @@ -2,6 +2,8 @@ name: Rust CI on: pull_request: + paths: + - "native/wasmex/**" push: branches: - main diff --git a/.tool-versions b/.tool-versions index 029db040..86253ace 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 25.3.2 -elixir 1.14.5 +erlang 26.1 +elixir 1.15.6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 81b0e392..3b8c7172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,15 @@ Types of changes put your changes here -### Changes +### Added + +* official support for Elixir 1.15 (though it did work before, but now we test on CI) + +### Removed + +* official support for Elixir 1.12 + +### Changed * Dependency updates (most notably wasmtime and rustler) diff --git a/README.md b/README.md index 8d579ad3..90212410 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ License - - CI + + CI

diff --git a/native/wasmex/Cargo.toml b/native/wasmex/Cargo.toml index d07971b5..89c5c26e 100644 --- a/native/wasmex/Cargo.toml +++ b/native/wasmex/Cargo.toml @@ -15,7 +15,7 @@ path = "src/lib.rs" crate-type = ["dylib"] [dependencies] -rustler = "0.29.1" +rustler = { version = "0.29", default-features = false, features = ["derive", "nif_version_2_15"] } once_cell = "1.18.0" rand = "0.8.5" wasmtime = "12.0.2" diff --git a/native/wasmex/Cross.toml b/native/wasmex/Cross.toml deleted file mode 100644 index 8ba543cb..00000000 --- a/native/wasmex/Cross.toml +++ /dev/null @@ -1,4 +0,0 @@ -[build.env] -passthrough = [ - "RUSTLER_NIF_VERSION" -]