Skip to content

Commit 4868954

Browse files
authored
Feat: support serialization for erlang terms (#2)
* Feat: ADR for hybrid storage * Chore: ignore the priv folder * Chore: remove target folder from GIT * Chore: remove priv/native folder from GIT * Feat: implement support for arbitrary Erlang Term values * Chore: remove checksum from GIT history * Chore: add couple bash scripts for clean compile / tests * Chore: remove old stuff from readmes * Chore: group release binaries by target platform * Chore: pull latest release from main - trigger * Chore: try building release on PR branch * Chore: try new release pipeline to support MUSL * Feat: try rustler configs by example of https://github.com/leandrocp/mdex * chore * Feat: add .cargo/config.toml * Feat: add support for rust in single pipeline * Chore: adjust formatting * Chore: fix rust formatting * Chore: fix clippy warning * Chore: add more checks to bin/test.sh * Chore: add windows + apple x86 * Feat: add script to generate checksum file + ignore it for GIT
1 parent d38a1c0 commit 4868954

File tree

303 files changed

+819
-3221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

303 files changed

+819
-3221
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- feat/support_for_erlang_terms
89

910
jobs:
1011
mix_test:
@@ -51,4 +52,10 @@ jobs:
5152
- run: mix compile --warnings-as-errors
5253
if: ${{ matrix.lint }}
5354

54-
- run: mix test
55+
- run: mix test
56+
57+
- name: run rustfmt
58+
run: cargo fmt --manifest-path=native/trie_hard_native/Cargo.toml --all -- --check
59+
60+
- name: run clippy
61+
run: cargo clippy --manifest-path=native/trie_hard_native/Cargo.toml -- -Dwarnings

.github/workflows/release.yml

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,111 @@
1-
name: Build precompiled NIFs
1+
# https://github.com/elixir-explorer/explorer/blob/main/.github/workflows/release.yml
2+
# https://github.com/Takashiidobe/rust-build-binary-github-actions/blob/master/.github/workflows/release.yml
23

3-
permissions:
4-
id-token: write
5-
attestations: write
6-
contents: write
4+
name: Precomp NIFs
75

86
on:
97
push:
108
branches:
11-
- main
129
- master
10+
- feat/support_for_erlang_terms
1311
paths:
14-
# Just run on main branch if "native" path changed.
1512
- "native/**"
16-
# Also run if this file changes.
1713
- ".github/workflows/release.yml"
1814
tags:
19-
# Tags will always run.
2015
- "*"
2116
pull_request:
2217
paths:
23-
# In PRs we only run if this file changes.
2418
- ".github/workflows/release.yml"
2519
workflow_dispatch:
2620

2721
jobs:
2822
build_release:
29-
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
23+
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }} | ${{ matrix.job.variant || 'default' }})
3024
runs-on: ${{ matrix.job.os }}
25+
26+
permissions:
27+
contents: write
28+
id-token: write
29+
attestations: write
30+
3131
strategy:
3232
fail-fast: false
3333
matrix:
3434
nif: ["2.15", "2.16"]
3535
job:
36-
- { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04 , use-cross: true }
37-
- { target: aarch64-unknown-linux-musl , os: ubuntu-22.04 , use-cross: true }
38-
- { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04 }
39-
- { target: x86_64-unknown-linux-musl , os: ubuntu-22.04 , use-cross: true }
40-
- { target: aarch64-apple-darwin , os: macos-13 }
41-
- { target: x86_64-apple-darwin , os: macos-13 }
42-
- { target: x86_64-pc-windows-msvc , os: windows-2022 }
36+
- { target: aarch64-apple-darwin, os: macos-13 }
37+
- { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true }
38+
- { target: aarch64-unknown-linux-musl, os: ubuntu-22.04, use-cross: true }
39+
# - { target: arm-unknown-linux-gnueabihf, os: ubuntu-22.04, use-cross: true }
40+
# - { target: riscv64gc-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true }
41+
- { target: x86_64-apple-darwin, os: macos-13 }
42+
- { target: x86_64-pc-windows-gnu, os: windows-2022, rustflags: "-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" }
43+
- { target: x86_64-pc-windows-gnu, os: windows-2022, variant: "legacy_cpu" }
44+
# - { target: x86_64-pc-windows-msvc, os: windows-2022, rustflags: "-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" }
45+
# - { target: x86_64-pc-windows-msvc, os: windows-2022, variant: "legacy_cpu" }
46+
# - { target: x86_64-unknown-freebsd, os: ubuntu-22.04, use-cross: true, rustflags: "-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" }
47+
# - { target: x86_64-unknown-freebsd, os: ubuntu-22.04, use-cross: true, variant: "legacy_cpu" }
48+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, rustflags: "-C target-feature=+fxsr,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" }
49+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, variant: "legacy_cpu" }
50+
- { target: x86_64-unknown-linux-musl, os: ubuntu-22.04, use-cross: true }
4351

4452
steps:
45-
- name: Checkout source code
46-
uses: actions/checkout@v4
53+
- name: Checkout source code
54+
uses: actions/checkout@v5
4755

48-
- name: Extract project version
49-
shell: bash
50-
run: |
51-
# Get the version from mix.exs
52-
VERSION=$(grep '@version' mix.exs | head -n 1 | sed 's/.*@version "\(.*\)".*/\1/')
53-
echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV
56+
- name: Extract crate information
57+
shell: bash
58+
run: |
59+
# Get the project version from mix.exs
60+
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
5461
55-
- name: Install Elixir and Erlang
56-
uses: erlef/setup-beam@v1
57-
with:
58-
version-type: strict
59-
otp-version: 26.2
60-
elixir-version: 1.18.4
62+
- name: Maybe add Rust flags for compilation
63+
shell: bash
64+
run: |
65+
echo "RUSTFLAGS=${{ matrix.job.rustflags }}" >> $GITHUB_ENV
66+
if: ${{ matrix.job.rustflags }}
6167

62-
- name: Install Rust toolchain
63-
uses: dtolnay/rust-toolchain@stable
64-
with:
65-
target: ${{ matrix.job.target }}
68+
- name: Add target
69+
shell: bash
70+
run: |
71+
rustup target add ${{ matrix.job.target }}
6672
67-
- name: Cache Rust dependencies
68-
uses: Swatinem/rust-cache@v2
69-
with:
70-
workspaces: native/trie_hard_native
71-
key: ${{ matrix.job.target }}-${{ matrix.nif }}
73+
- uses: Swatinem/rust-cache@v2
74+
with:
75+
prefix-key: v0-precomp
76+
shared-key: ${{ matrix.job.target }}-${{ matrix.nif }}
77+
workspaces: |
78+
native/trie_hard_native
7279
73-
- name: Cache Mix dependencies
74-
uses: actions/cache@v4
75-
with:
76-
path: |
77-
deps
78-
_build
79-
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
80-
restore-keys: |
81-
${{ runner.os }}-mix-
80+
- name: Build the project
81+
id: build-crate
82+
uses: philss/rustler-precompiled-action@v1.1.4
83+
with:
84+
project-name: trie_hard_native
85+
project-version: ${{ env.PROJECT_VERSION }}
86+
target: ${{ matrix.job.target }}
87+
nif-version: ${{ matrix.nif }}
88+
use-cross: ${{ matrix.job.use-cross }}
89+
cross-version: ${{ matrix.job.cross-version || 'from-source' }}
90+
project-dir: "native/trie_hard_native"
91+
cargo-args: ${{ matrix.job.cargo-args }}
92+
variant: ${{ matrix.job.variant }}
8293

83-
- name: Install dependencies
84-
run: mix deps.get
8594

86-
- name: Build the project
87-
id: build-crate
88-
uses: philss/rustler-precompiled-action@v1.1.4
89-
with:
90-
project-name: trie_hard_native
91-
project-version: ${{ env.PROJECT_VERSION }}
92-
target: ${{ matrix.job.target }}
93-
nif-version: ${{ matrix.nif }}
94-
use-cross: ${{ matrix.job.use-cross }}
95-
project-dir: "native/trie_hard_native"
95+
- name: Artifact attestation
96+
uses: actions/attest-build-provenance@v3
97+
with:
98+
subject-path: ${{ steps.build-crate.outputs.file-path }}
9699

97-
- name: Artifact upload
98-
uses: actions/upload-artifact@v4
99-
with:
100-
name: ${{ steps.build-crate.outputs.file-name }}
101-
path: ${{ steps.build-crate.outputs.file-path }}
100+
- name: Artifact upload
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: ${{ steps.build-crate.outputs.file-name }}
104+
path: ${{ steps.build-crate.outputs.file-path }}
102105

103-
- name: Publish archives and packages
104-
uses: softprops/action-gh-release@v2
105-
with:
106-
files: |
107-
${{ steps.build-crate.outputs.file-path }}
108-
if: startsWith(github.ref, 'refs/tags/')
106+
- name: Publish archives and packages
107+
uses: softprops/action-gh-release@v2
108+
with:
109+
files: |
110+
${{ steps.build-crate.outputs.file-path }}
111+
if: startsWith(github.ref, 'refs/tags/')

.github/workflows/rust-ci.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ trie_again-*.tar
2525
# Rust binary artifacts
2626
/target/
2727
native/**/target/
28+
priv/
29+
30+
# The checksum files for precompiled NIFs
31+
checksum-*.exs

0 commit comments

Comments
 (0)