Skip to content

Commit 5609788

Browse files
authored
Merge branch 'master' into feature/inline
2 parents 50d1528 + d8aa66d commit 5609788

File tree

95 files changed

+1869
-799
lines changed

Some content is hidden

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

95 files changed

+1869
-799
lines changed

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.56.1"

.github/workflows/main.yml

Lines changed: 68 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,24 @@ on:
1010
- cron: '0 0 * * 3'
1111

1212
jobs:
13-
clippy:
14-
name: Clippy
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: actions/checkout@v1
18-
- uses: actions-rs/toolchain@v1
19-
with:
20-
toolchain: stable
21-
components: clippy
22-
override: true
23-
- uses: actions-rs/clippy-check@v1
24-
with:
25-
token: ${{ secrets.GITHUB_TOKEN }}
26-
args: --all-targets --all-features -- -D warnings
27-
28-
clippy-windows:
29-
name: Clippy-Windows
30-
runs-on: windows-latest
31-
steps:
32-
- uses: actions/checkout@v1
33-
- name: Install Erlang/Elixir
34-
run: choco install elixir
35-
- name: Extend PATH
36-
run: echo "C:\\ProgramData\\chocolatey\\lib\\Elixir\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
37-
- name: Build API
38-
working-directory: rustler_sys
39-
run: |
40-
cargo build
41-
- uses: actions-rs/toolchain@v1
42-
with:
43-
toolchain: stable
44-
components: clippy
45-
override: true
46-
- uses: actions-rs/clippy-check@v1
47-
with:
48-
token: ${{ secrets.GITHUB_TOKEN }}
49-
args: --all-targets --all-features -- -D warnings
50-
5113
format:
5214
name: Format
5315
runs-on: ubuntu-latest
5416
steps:
55-
- uses: actions/checkout@v1
56-
- uses: actions-rs/toolchain@v1
17+
- uses: actions/checkout@v3
18+
19+
- uses: dtolnay/rust-toolchain@stable
5720
with:
58-
toolchain: stable
59-
components: rustfmt
60-
override: true
21+
components: rustfmt
6122

6223
- name: Install Erlang/Elixir
6324
uses: erlef/setup-beam@v1
6425
with:
65-
otp-version: "25.0.0"
66-
elixir-version: "1.13.4"
26+
otp-version: "25"
27+
elixir-version: "1.14"
6728

6829
- name: Check cargo fmt
69-
uses: actions-rs/cargo@v1
70-
with:
71-
command: fmt
72-
args: --all -- --check
30+
run: cargo fmt --all -- --check
7331

7432
- name: Check mix format (rustler_mix)
7533
working-directory: rustler_mix
@@ -79,123 +37,97 @@ jobs:
7937
working-directory: rustler_tests
8038
run: mix format --check-formatted
8139

82-
rustler_mix_test:
83-
runs-on: ubuntu-latest
40+
build:
41+
name: Build ${{matrix.os}} ${{matrix.toolchain}}
42+
runs-on: ${{matrix.os}}-latest
43+
strategy:
44+
matrix:
45+
os: [ubuntu, windows, macos]
46+
toolchain: [stable, nightly]
8447
steps:
85-
- uses: actions/checkout@v1
48+
- uses: actions/checkout@v3
8649

87-
- name: Install Rust stable toolchain
88-
uses: actions-rs/toolchain@v1
50+
- uses: dtolnay/rust-toolchain@stable
8951
with:
90-
toolchain: stable
91-
override: true
52+
toolchain: ${{matrix.toolchain}}
9253

93-
- name: Install Erlang/Elixir
94-
uses: erlef/setup-beam@v1
54+
- uses: Swatinem/rust-cache@v2
9555
with:
96-
otp-version: "24.1.7"
97-
elixir-version: 1.13
56+
cache-on-failure: true
57+
shared-key: rustler
9858

99-
- name: Test rustler_mix
100-
working-directory: rustler_mix
101-
run: ./test.sh
59+
- run: cargo build
10260

103-
test_windows:
104-
name: Windows
105-
runs-on: windows-latest
61+
clippy:
62+
name: Clippy ${{matrix.os}}
63+
runs-on: ${{matrix.os}}-latest
64+
needs: [build]
65+
strategy:
66+
matrix:
67+
os: [ubuntu, windows, macos]
10668
steps:
107-
- name: Checkout sources
108-
uses: actions/checkout@v1
109-
110-
- name: Install Erlang/Elixir
111-
run: choco install elixir
69+
- uses: actions/checkout@v3
11270

113-
- name: Install Rust stable toolchain
114-
uses: actions-rs/toolchain@v1
71+
- uses: dtolnay/rust-toolchain@stable
11572
with:
116-
toolchain: stable
117-
override: true
73+
components: clippy
11874

119-
- name: Extend PATH
120-
run: echo "C:\\ProgramData\\chocolatey\\lib\\Elixir\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
75+
- uses: Swatinem/rust-cache@v2
76+
with:
77+
shared-key: rustler
78+
save-if: false
12179

122-
- name: Hex
123-
run: mix local.hex --force
124-
125-
- name: Test rustler_mix
126-
working-directory: rustler_mix
127-
run: |
128-
mix deps.get
129-
mix test
130-
131-
- name: Test rustler_tests
132-
working-directory: rustler_tests
133-
run: |
134-
mix deps.get
135-
mix test
80+
- run: cargo clippy --all-targets --all-features -- -D warnings
13681

13782
test:
138-
name: OTP ${{matrix.pair.erlang}} / Elixir ${{matrix.pair.elixir}} / Rust ${{matrix.rust}}
139-
runs-on: ubuntu-latest
83+
name: OTP ${{matrix.pair.erlang}} / Elixir ${{matrix.pair.elixir}} / Rust ${{matrix.rust}} / OS ${{matrix.os}}
84+
needs: [build]
14085
strategy:
14186
matrix:
14287
pair:
143-
- { erlang: "25.0.0", elixir: "1.13.4" }
144-
- { erlang: "24.3.4", elixir: "1.13.0" }
145-
- { erlang: "24.3.4", elixir: "1.12.3" }
146-
- { erlang: "24.3.4", elixir: "1.11.4" }
147-
- { erlang: "23.3.4.14", elixir: "1.11.4" }
88+
- { erlang: "26", elixir: "1.14", latest: true }
89+
- { erlang: "25", elixir: "1.14" }
90+
- { erlang: "24", elixir: "1.13" }
14891
rust:
14992
- stable
150-
- beta
15193
- nightly
94+
os:
95+
- macos
96+
- windows
97+
- ubuntu
98+
exclude:
99+
# TODO Remove this once setup-beam is fixed to work around OTP26's
100+
# regression
101+
- os: windows
102+
pair: { erlang: "26", elixir: "1.14", latest: true }
103+
runs-on: ${{matrix.os}}-latest
104+
152105
steps:
153106
- name: Checkout sources
154-
uses: actions/checkout@v1
107+
uses: actions/checkout@v3
155108

156109
- name: Install Erlang/Elixir
157110
uses: erlef/setup-beam@v1
158111
with:
159112
otp-version: ${{matrix.pair.erlang}}
160113
elixir-version: ${{matrix.pair.elixir}}
114+
if: "!startsWith(matrix.os, 'macos')"
161115

162-
- name: Install Rust ${{matrix.rust}} toolchain
163-
uses: actions-rs/toolchain@v1
164-
with:
165-
toolchain: ${{matrix.rust}}
166-
override: true
167-
168-
- run: cargo test
169-
170-
- name: Test rustler_mix
171-
working-directory: rustler_mix
172-
run: |
173-
mix deps.get
174-
mix test
175-
176-
- name: Test rustler_tests
177-
working-directory: rustler_tests
178-
run: |
179-
mix deps.get
180-
mix test
181-
182-
test_macos:
183-
name: macos-11 test
184-
runs-on: macos-11
185-
steps:
186-
- name: Checkout sources
187-
uses: actions/checkout@v1
188-
189-
- name: Install Erlang/Elixir
116+
- name: Install Erlang/Elixir with Brew
190117
run: |
191118
brew install elixir
192119
mix local.hex --force
120+
if: "startsWith(matrix.os, 'macos')"
193121

194122
- name: Install Rust ${{matrix.rust}} toolchain
195-
uses: actions-rs/toolchain@v1
123+
uses: dtolnay/rust-toolchain@master
124+
with:
125+
toolchain: ${{matrix.rust}}
126+
127+
- uses: Swatinem/rust-cache@v2
196128
with:
197-
toolchain: stable
198-
override: true
129+
shared-key: rustler
130+
save-if: false
199131

200132
- run: cargo test
201133

@@ -210,3 +142,8 @@ jobs:
210142
run: |
211143
mix deps.get
212144
mix test
145+
146+
- name: Test mix project with example created from template
147+
working-directory: rustler_mix
148+
run: ./test.sh
149+
if: "startsWith(matrix.os, 'ubuntu') && matrix.pair.latest"

CHANGELOG.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,98 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
See [`UPGRADE.md`](./UPGRADE.md) for additional help when upgrading to newer versions.
99

10+
## [unreleased]
11+
12+
## Added
13+
14+
* `ErlOption<T>` to provide an ergonomic option type for Erlang (#507, thanks @tatsuya6502)
15+
16+
### Changed
17+
18+
* Use Cargo features to define the NIF version level (#537), deprecating
19+
`RUSTLER_NIF_VERSION`
20+
21+
## [0.28.0] - 2023-04-24
22+
23+
### Added
24+
25+
* Support OTP 26 (#526, thanks @philss)
26+
* Support tuples in NIF macro (#520, #527, thanks @denumerate and @philss)
27+
* Supportfor `load_data_fun` to compute `load_data` at runtime (#413, thanks @kaaboaye)
28+
29+
### Changed
30+
31+
* Enhanced NIF macro error messages for invalid attributes (#525, thanks @philss)
32+
33+
## [0.27.0] - 2023-01-17
34+
35+
### BREAKING
36+
37+
* `MIX_ENV` is no longer considered for determining the build profile. Now, the
38+
profile defaults to `:release`. Use the `:mode` option to pick another
39+
profile explicitly. (#496)
40+
41+
### Added
42+
43+
* `ResourceArc::make_binary` for safe use of `enif_make_resource_binary` (#487)
44+
* `OwnedBinary` is now `Sync` (#493)
45+
* Specified MSRV to be 1.56.1.
46+
47+
### Fixed
48+
49+
* Documentation for `load` (#501, thanks @ishitatsuyuki)
50+
51+
### Changed
52+
53+
* Edition 2021 for the rustler mix template (#512, thanks @ayrat555)
54+
55+
## [0.26.0] - 2022-09-02
56+
57+
### Highlight
58+
59+
#### TaggedEnum
60+
61+
We added `TaggedEnum`, which is a generalized enum type (#440, thanks to @SeokminHong!). Example:
62+
63+
```rust
64+
#[derive(NifTaggedEnum)]
65+
pub enum TaggedEnum1 {
66+
Named { x: i32, y: i32 },
67+
String1(String),
68+
String2(String),
69+
Untagged,
70+
}
71+
```
72+
73+
On the Elixir side, the variants are represented as two-tuples `{tag::atom(),
74+
inner::term()} | atom()`, where the `inner` term is
75+
76+
* a map for the variant `Named` in the example above
77+
* a binary for the `String1` and `String2` variants
78+
79+
The `Untagged` variant is represented as the atom `:untagged` in Elixir.
80+
81+
### Added
82+
83+
* Added `Clone` and `Copy` for `TermType` (#476, thanks @dvic)
84+
* Added `Env.whereis_pid()` (#456, thanks @Qqwy)
85+
86+
### Improved
87+
88+
* Use `&[impl Encoder]` for keys and values in `map_from_arrays()` to improve ergonomics (#453, thanks @SeokminHong)
89+
* Improved encode/decode performance of TaggedEnum considerably (#482, thanks @cleaton)
90+
* Test on OTP 25 (#455)
91+
92+
### Fixed
93+
94+
* Lifetime handling in `rustler_codegen` (#483, thanks @turion @SeokminHong and @neosimsim)
95+
* Support multiple variants with same field names in TaggedEnum (#482, thanks @cleaton)
96+
* Support .toml file extension for cargo config (#468, thanks @joshuataylor for the report in #467)
97+
* Disambiguate `encode`/`decode` in generated code (#466, thanks @SeokminHong)
98+
* Migrate CI to `erlef/setup-beam` (#457, thanks @SeokminHong)
99+
* Documentation of the `schedule` flag for `nif` macro (#444)
100+
* Improve documentation (#429, thanks @turion)
101+
10102
## [0.25.0] - 2022-04-11
11103

12104
### Added

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ members = [
88
"rustler_tests/native/rustler_test",
99
"rustler_tests/native/rustler_bigint_test",
1010
"rustler_tests/native/deprecated_macros",
11+
"rustler_tests/native/dynamic_load",
12+
"rustler_tests/native/rustler_compile_tests",
13+
"rustler_benchmarks/native/benchmark",
1114
]

0 commit comments

Comments
 (0)