From 5b973b687ce10f59e3e2662f1b9ed823c598a88a Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:13:41 +0000 Subject: [PATCH 01/12] build NIFs version 2.17 good for OTP 26>= --- native/exstatic/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/exstatic/Cargo.toml b/native/exstatic/Cargo.toml index f6d5815..0331d74 100644 --- a/native/exstatic/Cargo.toml +++ b/native/exstatic/Cargo.toml @@ -10,5 +10,5 @@ path = "src/lib.rs" crate-type = ["cdylib"] [dependencies] -rustler = "0.35.1" +rustler = { version = "0.35.1", default-features = false, features = ["nif_version_2_17"] } statrs = "0.18.0" From 971dae94b80a54ac80a023f0e5e75f37deece315 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:17:26 +0000 Subject: [PATCH 02/12] rustler precompiled --- lib/exstatic/native.ex | 10 +++++++++- mix.exs | 8 ++++++-- mix.lock | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/exstatic/native.ex b/lib/exstatic/native.ex index 9bcd5a3..718c253 100644 --- a/lib/exstatic/native.ex +++ b/lib/exstatic/native.ex @@ -1,6 +1,14 @@ defmodule Exstatic.Native do @moduledoc false - use Rustler, otp_app: :exstatic, crate: "exstatic" + version = Mix.Project.config()[:version] + + use RustlerPrecompiled, + otp_app: :exstatic, + crate: "exstatic", + base_url: "https://github.com/intellection/exstatic/releases/download/v#{version}", + force_build: System.get_env("EXSTATIC_BUILD") == "true", + nif_versions: ["2.17"], + version: version @spec normal_pdf(float(), float(), float()) :: float() def normal_pdf(_mean, _std_dev, _x), do: :erlang.nif_error(:nif_not_loaded) diff --git a/mix.exs b/mix.exs index 5ee458f..b0bf288 100644 --- a/mix.exs +++ b/mix.exs @@ -61,7 +61,8 @@ defmodule Exstatic.MixProject do [ name: "exstatic", organization: "zappi", - files: ~w(lib .formatter.exs mix.exs README*), + # files: ~w(lib mix.exs README.md native/exstatic/src native/exstatic/Cargo.toml priv), + files: ~w(lib mix.exs README.md checksum-*.exs), licenses: ["MIT"], links: %{"GitHub" => @source_url} ] @@ -70,7 +71,10 @@ defmodule Exstatic.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:rustler, "~> 0.35.1", runtime: false}, + # {:rustler, "~> 0.35.1", runtime: false}, + {:rustler_precompiled, "~> 0.8"}, + # Required if you build the NIFs yourself + {:rustler, ">= 0.0.0", optional: true}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}, {:ex_doc, "~> 0.34", only: :dev, runtime: false}, diff --git a/mix.lock b/mix.lock index ff0a6bb..5c996c6 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,6 @@ %{ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, + "castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"}, "credo": {:hex, :credo, "1.7.11", "d3e805f7ddf6c9c854fd36f089649d7cf6ba74c42bc3795d587814e3c9847102", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "56826b4306843253a66e47ae45e98e7d284ee1f95d53d1612bb483f88a8cf219"}, "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, "earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"}, @@ -19,6 +20,7 @@ "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"}, "req": {:hex, :req, "0.5.8", "50d8d65279d6e343a5e46980ac2a70e97136182950833a1968b371e753f6a662", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "d7fc5898a566477e174f26887821a3c5082b243885520ee4b45555f5d53f40ef"}, "rustler": {:hex, :rustler, "0.35.1", "ec81961ef9ee833d721dafb4449cab29b16b969a3063a842bb9e3ea912f6b938", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "3713b2e70e68ec2bfa8291dfd9cb811fe64a770f254cd9c331f8b34fa7989115"}, + "rustler_precompiled": {:hex, :rustler_precompiled, "0.8.2", "5f25cbe220a8fac3e7ad62e6f950fcdca5a5a5f8501835d2823e8c74bf4268d5", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "63d1bd5f8e23096d1ff851839923162096364bac8656a4a3c00d1fff8e83ee0a"}, "sobelow": {:hex, :sobelow, "0.13.0", "218afe9075904793f5c64b8837cc356e493d88fddde126a463839351870b8d1e", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cd6e9026b85fc35d7529da14f95e85a078d9dd1907a9097b3ba6ac7ebbe34a0d"}, "telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"}, "toml": {:hex, :toml, "0.7.0", "fbcd773caa937d0c7a02c301a1feea25612720ac3fa1ccb8bfd9d30d822911de", [:mix], [], "hexpm", "0690246a2478c1defd100b0c9b89b4ea280a22be9a7b313a8a058a2408a2fa70"}, From 2d34d1a1a97de44746470e1afcc8333fee8844cb Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:49:10 +0000 Subject: [PATCH 03/12] elixir ci workflow --- .github/workflows/ci.yml | 87 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 93 -------------------------------------- 2 files changed, 87 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ce11b33 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,87 @@ +name: CI +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +env: + EXSTATIC_BUILD: true + MIX_ENV: test + +jobs: + test: + strategy: + matrix: + include: + - otp_version: "27.2" + elixir_version: "1.18" + os: ubuntu-latest + + runs-on: ${{ matrix.os }} + name: Test on Elixir ${{ matrix.elixir_version }} / OTP ${{ matrix.otp_version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Elixir and Erlang + uses: erlef/setup-beam@v1 + with: + otp-version: ${{ matrix.otp_version }} + elixir-version: ${{ matrix.elixir_version }} + + - name: Cache Mix dependencies + uses: actions/cache@v4 + id: cache-deps + with: + path: | + deps + _build + _build/test + key: mix-${{ runner.os }}-${{ matrix.elixir_version }}-${{ matrix.otp_version }}-${{ hashFiles('mix.lock') }} + restore-keys: | + mix-${{ runner.os }}-${{ matrix.elixir_version }}-${{ matrix.otp_version }}- + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: native/exstatic + + - name: Install dependencies + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + run: mix deps.get + + - name: Compile + run: mix compile --warnings-as-errors + + - name: Check for unused packages + run: mix deps.unlock --check-unused + + - name: Check code formatting + run: mix format --check-formatted + + - name: Run Credo (Code Linter) + run: mix credo --strict + + - name: Run Dialyzer (Static Analysis) + run: mix dialyzer + + - name: Check for abandoned dependencies + run: mix hex.audit + + - name: Check for outdated dependencies + run: mix hex.outdated --within-requirements || true + + - name: Run tests + run: mix test + + - name: Run tests with coverage + run: mix test --cover --export-coverage default + + - name: Check test coverage + run: mix test.coverage + + - name: Scan for security vulnerabilities + run: mix sobelow --exit --threshold medium diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index cbe4714..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Test -on: - push: - branches: [main] - pull_request: - branches: [main] -jobs: - test: - name: Test (Elixir ${{ matrix.elixir }} | OTP ${{ matrix.otp }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - elixir: 1.18.x - otp: 27 - os: ubuntu-22.04 - env: - MIX_ENV: test - steps: - - name: Setup Elixir - uses: erlef/setup-beam@v1 - with: - elixir-version: ${{ matrix.elixir }} - otp-version: ${{ matrix.otp }} - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Cache dependencies - uses: actions/cache@v4 - id: cache-deps - with: - path: | - deps - _build - key: | - mix-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }} - restore-keys: | - mix-${{ runner.os }}-${{ matrix.elixir }}-${{ matrix.otp }}- - - name: Install dependencies - env: - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} - run: mix deps.get - - - name: Compile - run: mix compile --warnings-as-errors - - - name: Check for unused packages - run: mix deps.unlock --check-unused - - - run: mix format --check-formatted - - - run: mix credo --strict - - - run: mix dialyzer - - - name: Check for abandonded packages - run: mix hex.audit - - - name: Check outdated dependencies - run: mix hex.outdated --within-requirements || true - - - name: Check for vulnerable packages - run: mix hex.audit - - - name: Run tests - run: mix test - - - name: Run tests (with coverage) - run: mix test --cover --export-coverage default - - - name: Check coverage - run: mix test.coverage - - - name: Scan for security vulnerabilities - run: mix sobelow --exit --threshold medium - - publish: - name: Publish - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - uses: erlef/setup-beam@v1 - with: - elixir-version: 1.18 - otp-version: 27.2 - - name: Fetch dependencies - run: mix deps.get - - name: Publish package - env: - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} - run: mix hex.publish --organization ${{ vars.HEX_ORG }} --dry-run --replace --yes From 025ce2737d24bc4a207a737fc0aceae56311f9b2 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 16:49:38 +0000 Subject: [PATCH 04/12] release workflow builds and uploads precompiled NIFs --- .github/workflows/release.yml | 96 +++++++++++++++++++++++++++++------ 1 file changed, 80 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 69e0a1e..0a0792c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,20 +1,84 @@ -name: Release +name: Build Precompiled NIFs + on: - release: - types: [published] + push: + branches: + - main + paths: + - "native/**" + - ".github/workflows/release.yml" + tags: + - "*" + pull_request: + paths: + - ".github/workflows/release.yml" + workflow_dispatch: + jobs: - publish: - name: Publish - runs-on: ubuntu-22.04 + build_release: + name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) + runs-on: ${{ matrix.job.os }} + + permissions: + contents: write + id-token: write + attestations: write + + strategy: + fail-fast: false + matrix: + nif: ["2.16"] # Only build for OTP 26 and 27 + job: + - { target: aarch64-apple-darwin, os: macos-13 } + - { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true } + - { target: x86_64-apple-darwin, os: macos-13 } + - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 } + steps: - - uses: actions/checkout@v4 - - uses: erlef/setup-beam@v1 + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Extract project version + shell: bash + run: | + echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV + + - name: Add Rust target + shell: bash + run: rustup target add ${{ matrix.job.target }} + + - uses: Swatinem/rust-cache@v2 with: - elixir-version: 1.18 - otp-version: 27.2 - - name: Fetch dependencies - run: mix deps.get - - name: Publish package - env: - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} - run: mix hex.publish --organization ${{ vars.HEX_ORG }} --replace --yes + prefix-key: v0-precomp + shared-key: ${{ matrix.job.target }}-${{ matrix.nif }} + workspaces: | + native/exstatic + + - name: Build the project + id: build-crate + uses: philss/rustler-precompiled-action@v1.1.4 + with: + project-name: exstatic + project-version: ${{ env.PROJECT_VERSION }} + target: ${{ matrix.job.target }} + nif-version: ${{ matrix.nif }} + use-cross: ${{ matrix.job.use-cross }} + project-dir: "native/exstatic" + + - name: Artifact attestation (security verification) + uses: actions/attest-build-provenance@v1 + with: + subject-path: ${{ steps.build-crate.outputs.file-path }} + + - name: Upload NIF artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.build-crate.outputs.file-name }} + path: ${{ steps.build-crate.outputs.file-path }} + + - name: Publish to GitHub Releases + uses: softprops/action-gh-release@v2 + with: + files: | + ${{ steps.build-crate.outputs.file-path }} + if: startsWith(github.ref, 'refs/tags/') From 3fb8274c5c85ed3c424f487913decabe59ab6e78 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:08:13 +0000 Subject: [PATCH 05/12] nif version 2.16 --- lib/exstatic/native.ex | 2 +- native/exstatic/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/exstatic/native.ex b/lib/exstatic/native.ex index 718c253..968a2d6 100644 --- a/lib/exstatic/native.ex +++ b/lib/exstatic/native.ex @@ -7,7 +7,7 @@ defmodule Exstatic.Native do crate: "exstatic", base_url: "https://github.com/intellection/exstatic/releases/download/v#{version}", force_build: System.get_env("EXSTATIC_BUILD") == "true", - nif_versions: ["2.17"], + nif_versions: ["2.16"], version: version @spec normal_pdf(float(), float(), float()) :: float() diff --git a/native/exstatic/Cargo.toml b/native/exstatic/Cargo.toml index 0331d74..7a99f66 100644 --- a/native/exstatic/Cargo.toml +++ b/native/exstatic/Cargo.toml @@ -10,5 +10,5 @@ path = "src/lib.rs" crate-type = ["cdylib"] [dependencies] -rustler = { version = "0.35.1", default-features = false, features = ["nif_version_2_17"] } +rustler = { version = "0.35.1", default-features = false, features = ["nif_version_2_16"] } statrs = "0.18.0" From aaf5a5b0b3462eea01398c78cb8d8ddc10029f5a Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:10:32 +0000 Subject: [PATCH 06/12] install rust tool chain and cross --- .github/workflows/release.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a0792c..6c40241 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,19 +34,28 @@ jobs: - { target: x86_64-apple-darwin, os: macos-13 } - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 } + env: + EXSTATIC_BUILD: true # Ensure RustlerPrecompiled forces a build + steps: - name: Checkout source code uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: ${{ matrix.job.target }} + + - name: Install Cross for cross-compilation (if needed) + if: ${{ matrix.job.use-cross }} + run: cargo install cross --git https://github.com/cross-rs/cross + - name: Extract project version shell: bash run: | echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV - - name: Add Rust target - shell: bash - run: rustup target add ${{ matrix.job.target }} - - uses: Swatinem/rust-cache@v2 with: prefix-key: v0-precomp From 227dabf20c4daae55a8a328c5e784e87b79907f3 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:15:27 +0000 Subject: [PATCH 07/12] add `platform` key to build target steps --- .github/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c40241..8280fdc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,10 +29,10 @@ jobs: matrix: nif: ["2.16"] # Only build for OTP 26 and 27 job: - - { target: aarch64-apple-darwin, os: macos-13 } - - { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true } - - { target: x86_64-apple-darwin, os: macos-13 } - - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 } + - { target: aarch64-apple-darwin, os: macos-13, platform: "macOS (ARM64)" } + - { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true, platform: "Linux (ARM64)" } + - { target: x86_64-apple-darwin, os: macos-13, platform: "macOS (x86_64)" } + - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, platform: "Linux (x86_64)" } env: EXSTATIC_BUILD: true # Ensure RustlerPrecompiled forces a build @@ -47,7 +47,7 @@ jobs: toolchain: stable targets: ${{ matrix.job.target }} - - name: Install Cross for cross-compilation (if needed) + - name: Install Cross for cross-compilation (needed for linux ARM64 target) if: ${{ matrix.job.use-cross }} run: cargo install cross --git https://github.com/cross-rs/cross From 8ebcec4e44747eee1c611018259b5a593eaaf527 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:16:42 +0000 Subject: [PATCH 08/12] redundant security step --- .github/workflows/release.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8280fdc..70f68e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,11 +74,6 @@ jobs: use-cross: ${{ matrix.job.use-cross }} project-dir: "native/exstatic" - - name: Artifact attestation (security verification) - uses: actions/attest-build-provenance@v1 - with: - subject-path: ${{ steps.build-crate.outputs.file-path }} - - name: Upload NIF artifact uses: actions/upload-artifact@v4 with: From fe10b95617b2dc1469b0dd1a5f2a4d57d031de3f Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:33:53 +0000 Subject: [PATCH 09/12] old --- mix.exs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index b0bf288..2dddeff 100644 --- a/mix.exs +++ b/mix.exs @@ -61,7 +61,6 @@ defmodule Exstatic.MixProject do [ name: "exstatic", organization: "zappi", - # files: ~w(lib mix.exs README.md native/exstatic/src native/exstatic/Cargo.toml priv), files: ~w(lib mix.exs README.md checksum-*.exs), licenses: ["MIT"], links: %{"GitHub" => @source_url} @@ -71,9 +70,8 @@ defmodule Exstatic.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - # {:rustler, "~> 0.35.1", runtime: false}, {:rustler_precompiled, "~> 0.8"}, - # Required if you build the NIFs yourself + # Rustler is required if you build the NIFs yourself {:rustler, ">= 0.0.0", optional: true}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}, From ada41cb8e7199fa8d8b6169b0e89d38754a70283 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:12:09 +0000 Subject: [PATCH 10/12] you can go too --- mix.exs | 1 - 1 file changed, 1 deletion(-) diff --git a/mix.exs b/mix.exs index 2dddeff..1a9aa8b 100644 --- a/mix.exs +++ b/mix.exs @@ -71,7 +71,6 @@ defmodule Exstatic.MixProject do defp deps do [ {:rustler_precompiled, "~> 0.8"}, - # Rustler is required if you build the NIFs yourself {:rustler, ">= 0.0.0", optional: true}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}, From 065ce075be12a62c854bed343d5f205f11576083 Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:18:42 +0000 Subject: [PATCH 11/12] better naming --- .github/workflows/release.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70f68e6..71042d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Build Precompiled NIFs +name: Compile & Upload NIFs on: push: @@ -15,14 +15,13 @@ on: workflow_dispatch: jobs: - build_release: - name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) + compile_nifs: + name: Compile & Upload NIFs / ${{ matrix.job.platform }} (NIF ${{ matrix.nif }}) runs-on: ${{ matrix.job.os }} permissions: contents: write id-token: write - attestations: write strategy: fail-fast: false @@ -47,7 +46,7 @@ jobs: toolchain: stable targets: ${{ matrix.job.target }} - - name: Install Cross for cross-compilation (needed for linux ARM64 target) + - name: Install Cross for cross-compilation if: ${{ matrix.job.use-cross }} run: cargo install cross --git https://github.com/cross-rs/cross @@ -63,7 +62,7 @@ jobs: workspaces: | native/exstatic - - name: Build the project + - name: Compile the NIFs id: build-crate uses: philss/rustler-precompiled-action@v1.1.4 with: @@ -74,13 +73,13 @@ jobs: use-cross: ${{ matrix.job.use-cross }} project-dir: "native/exstatic" - - name: Upload NIF artifact + - name: Upload compiled NIF artifact uses: actions/upload-artifact@v4 with: name: ${{ steps.build-crate.outputs.file-name }} path: ${{ steps.build-crate.outputs.file-path }} - - name: Publish to GitHub Releases + - name: Publish NIFs to GitHub Releases uses: softprops/action-gh-release@v2 with: files: | From 050a33d072db7b78c6d9269161347f111ad1c27c Mon Sep 17 00:00:00 2001 From: Brook <71849503+Primebrook@users.noreply.github.com> Date: Fri, 7 Feb 2025 18:20:52 +0000 Subject: [PATCH 12/12] even better naming --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71042d6..317c4ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ on: jobs: compile_nifs: - name: Compile & Upload NIFs / ${{ matrix.job.platform }} (NIF ${{ matrix.nif }}) + name: ${{ matrix.job.platform }} (NIF ${{ matrix.nif }}) runs-on: ${{ matrix.job.os }} permissions: @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - nif: ["2.16"] # Only build for OTP 26 and 27 + nif: ["2.16"] job: - { target: aarch64-apple-darwin, os: macos-13, platform: "macOS (ARM64)" } - { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true, platform: "Linux (ARM64)" }