Skip to content

Commit c3eb571

Browse files
committed
Update Nebulex
1 parent cb87a42 commit c3eb571

File tree

11 files changed

+92
-74
lines changed

11 files changed

+92
-74
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- main
1010

1111
jobs:
12-
nebulex_test:
12+
test:
1313
name: >-
1414
Nebulex.Adapters.Local Test (Elixir ${{ matrix.elixir }} /
1515
OTP ${{ matrix.otp }} /
@@ -19,29 +19,26 @@ jobs:
1919
strategy:
2020
matrix:
2121
include:
22-
- elixir: 1.17.x
22+
- elixir: 1.18.x
2323
otp: 27.x
2424
os: 'ubuntu-latest'
25-
style: true
25+
lint: true
2626
coverage: true
2727
sobelow: true
2828
dialyzer: true
29-
doctor: true
3029
- elixir: 1.17.x
31-
otp: 26.x
32-
os: 'ubuntu-latest'
33-
- elixir: 1.16.x
34-
otp: 26.x
30+
otp: 27.x
3531
os: 'ubuntu-latest'
36-
- elixir: 1.15.x
32+
- elixir: 1.17.x
3733
otp: 25.x
3834
os: 'ubuntu-latest'
3935
- elixir: 1.14.x
40-
otp: 23.x
41-
os: 'ubuntu-20.04'
36+
otp: 24.x
37+
os: 'ubuntu-latest'
4238

4339
env:
4440
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
41+
CODECOV_TOKEN: '${{ secrets.CODECOV_TOKEN }}'
4542
MIX_ENV: test
4643
NEBULEX_PATH: nebulex
4744

@@ -85,23 +82,42 @@ jobs:
8582
mix deps.get
8683
if: ${{ steps.mix-cache.outputs.cache-hit != 'true' }}
8784

88-
- name: Compile code
85+
- name: Compile deps
86+
run: mix deps.compile
87+
88+
- name: Check unused dependencies
89+
run: mix deps.unlock --check-unused
90+
if: ${{ matrix.lint }}
91+
92+
- name: Compile lint
8993
run: mix compile --warnings-as-errors
94+
if: ${{ matrix.lint }}
9095

9196
- name: Run style and code consistency checks
9297
run: |
9398
mix format --check-formatted
9499
mix credo --strict
95-
if: ${{ matrix.style }}
100+
if: ${{ matrix.lint }}
96101

97102
- name: Run tests
98103
run: mix test --trace
99104
if: ${{ !matrix.coverage }}
100105

101106
- name: Run tests with coverage
102-
run: mix coveralls.github
107+
run: mix coveralls.json
103108
if: ${{ matrix.coverage }}
104109

110+
- name: Upload coverage reports to Codecov
111+
uses: codecov/codecov-action@v5
112+
with:
113+
fail_ci_if_error: true
114+
flags: unittests-elixir-${{ matrix.elixir }}-otp-${{ matrix.otp }}
115+
if: ${{ matrix.coverage }}
116+
117+
- name: Run sobelow
118+
run: mix sobelow --skip --exit Low
119+
if: ${{ matrix.sobelow }}
120+
105121
- name: Restore PLT Cache
106122
uses: actions/cache@v3
107123
id: plt-cache

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
elixir 1.17.0-otp-27
2-
erlang 27.0
1+
elixir 1.18.2-otp-27
2+
erlang 27.2.1

LICENSE renamed to LICENSE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
MIT License
1+
# MIT License
22

3-
Copyright (c) 2023 Carlos Andres Bolaños R.A.
3+
Copyright (c) 2024 Carlos Andres Bolaños R.A.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# Nebulex Local
22
> A generational local cache adapter for [Nebulex][Nebulex].
33
4-
[Nebulex]: https://github.com/cabol/nebulex
4+
[Nebulex]: http://github.com/cabol/nebulex
55

6-
![CI](https://github.com/nebulex-project/nebulex_local/workflows/CI/badge.svg)
7-
[![Coverage Status](https://coveralls.io/repos/github/nebulex-project/nebulex_local/badge.svg?branch=main)](https://coveralls.io/github/nebulex-project/nebulex_local?branch=main)
8-
[![Hex Version](https://img.shields.io/hexpm/v/nebulex_local.svg)](https://hex.pm/packages/nebulex_local)
9-
[![Docs](https://img.shields.io/badge/docs-hexpm-blue.svg)](https://hexdocs.pm/nebulex_local)
10-
11-
See the [online documentation][online_docs] for more information.
12-
13-
[online_docs]: https://hexdocs.pm/nebulex_local/
6+
![CI](http://github.com/elixir-nebulex/nebulex_local/workflows/CI/badge.svg)
7+
[![Codecov](http://codecov.io/gh/elixir-nebulex/nebulex_local/graph/badge.svg)](http://codecov.io/gh/elixir-nebulex/nebulex_local/graph/badge.svg)
8+
[![Hex Version](http://img.shields.io/hexpm/v/nebulex_local.svg)](http://hex.pm/packages/nebulex_local)
9+
[![Documentation](http://img.shields.io/badge/Documentation-ff69b4)](http://hexdocs.pm/nebulex_local)
1410

1511
## Installation
1612

@@ -19,7 +15,7 @@ Add `:nebulex_local` to your list of dependencies in `mix.exs`:
1915
```elixir
2016
def deps do
2117
[
22-
{:nebulex_local, "~> 3.0"}
18+
{:nebulex_local, "~> 3.0.0-rc.1"}
2319
]
2420
end
2521
```
@@ -65,11 +61,13 @@ end
6561

6662
See the [online documentation][online_docs] for more information.
6763

64+
[online_docs]: http://hexdocs.pm/nebulex_local/
65+
6866
## Testing
6967

70-
Since `Nebulex.Adapters.Local` uses the support modules and shared tests
71-
from `Nebulex` and by default its test folder is not included in the Hex
72-
dependency, the following steps are required for running the tests.
68+
Since this adapter uses support modules and shared tests from `Nebulex`,
69+
but the test folder is not included in the Hex dependency, the following
70+
steps are required to run the tests.
7371

7472
First of all, make sure you set the environment variable `NEBULEX_PATH`
7573
to `nebulex`:
@@ -114,7 +112,7 @@ the directory [benchmarks](./benchmarks).
114112
To run a benchmark test you have to run:
115113

116114
```
117-
$ MIX_ENV=test mix run benchmarks/{BENCH_TEST_FILE}
115+
$ MIX_ENV=test mix run benchmarks/BENCH_TEST_FILE
118116
```
119117

120118
Where `BENCH_TEST_FILE` can be any of:
@@ -132,23 +130,23 @@ $ MIX_ENV=test mix run benchmarks/local_with_shards_bench.exs
132130
```
133131

134132
Additionally, you can also run performance tests using `:basho_bench`.
135-
See [nebulex_bench example](https://github.com/cabol/nebulex_examples/tree/master/nebulex_bench)
133+
See [nebulex_bench example](http://github.com/elixir-nebulex/nebulex_examples/tree/master/nebulex_bench)
136134
for more information.
137135

138136
## Contributing
139137

140138
Contributions to Nebulex are very welcome and appreciated!
141139

142-
Use the [issue tracker](https://github.com/nebulex-project/nebulex_local/issues)
140+
Use the [issue tracker](https://github.com/elixir-nebulex/nebulex_local/issues)
143141
for bug reports or feature requests. Open a
144-
[pull request](https://github.com/nebulex-project/nebulex_local/pulls)
142+
[pull request](https://github.com/elixir-nebulex/nebulex_local/pulls)
145143
when you are ready to contribute.
146144

147145
When submitting a pull request you should not update the
148146
[CHANGELOG.md](CHANGELOG.md), and also make sure you test your changes
149147
thoroughly, include unit tests alongside new or changed code.
150148

151-
Before to submit a PR it is highly recommended to run `mix check` and ensure
149+
Before to submit a PR it is highly recommended to run `mix test.ci` and ensure
152150
all checks run successfully.
153151

154152
## Copyright and License

lib/nebulex/adapters/local.ex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ defmodule Nebulex.Adapters.Local do
237237
# Inherit default info implementation
238238
use Nebulex.Adapters.Common.Info
239239

240+
# Inherit default observable implementation
241+
use Nebulex.Adapter.Observable
242+
240243
import Nebulex.Utils
241244
import Record
242245

@@ -344,7 +347,6 @@ defmodule Nebulex.Adapters.Local do
344347

345348
# Build adapter metadata
346349
adapter_meta = %{
347-
cache: cache,
348350
name: opts[:name] || cache,
349351
telemetry: telemetry,
350352
telemetry_prefix: telemetry_prefix,
@@ -648,6 +650,7 @@ defmodule Nebulex.Adapters.Local do
648650
|> list_gen()
649651
|> Enum.reduce([], &(backend.select(&1, in_match_spec(chunk, select)) ++ &2))
650652
end)
653+
|> Stream.flat_map(& &1)
651654
|> wrap_ok()
652655
end
653656

@@ -680,7 +683,7 @@ defmodule Nebulex.Adapters.Local do
680683
{[], {result, generations}}
681684

682685
{{elements, cont}, [_ | _] = generations} ->
683-
{[elements], {backend.select(cont), generations}}
686+
{elements, {backend.select(cont), generations}}
684687
end,
685688
& &1
686689
)
@@ -728,7 +731,7 @@ defmodule Nebulex.Adapters.Local do
728731
quote do
729732
case unquote(backend).unquote(fun)(unquote(tab), unquote(key)) do
730733
[] ->
731-
wrap_error(Nebulex.KeyError, key: unquote(key), cache: unquote(name))
734+
wrap_error Nebulex.KeyError, key: unquote(key), cache: unquote(name)
732735

733736
[entry(exp: :infinity) = entry] ->
734737
{:ok, entry}
@@ -769,7 +772,7 @@ defmodule Nebulex.Adapters.Local do
769772
if Time.now() >= exp do
770773
true = backend.delete(tab, key)
771774

772-
wrap_error(Nebulex.KeyError, key: key, cache: name, reason: :expired)
775+
wrap_error Nebulex.KeyError, key: key, cache: name, reason: :expired
773776
else
774777
{:ok, entry}
775778
end

mix.exs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
defmodule NebulexAdaptersLocal.MixProject do
22
use Mix.Project
33

4-
@source_url "https://github.com/nebulex-project/nebulex_local"
5-
@version "3.0.0-dev"
6-
# @nbx_vsn "3.0.0"
4+
@source_url "https://github.com/elixir-nebulex/nebulex_local"
5+
@version "3.0.0-rc.1"
6+
@nbx_tag "3.0.0-rc.1"
7+
@nbx_vsn "3.0.0-rc.1"
78

89
def project do
910
[
@@ -14,13 +15,14 @@ defmodule NebulexAdaptersLocal.MixProject do
1415
deps: deps(),
1516

1617
# Testing
17-
test_coverage: [tool: ExCoveralls],
18+
test_coverage: [tool: ExCoveralls, export: "test-coverage"],
1819
preferred_cli_env: [
19-
check: :test,
2020
coveralls: :test,
2121
"coveralls.detail": :test,
2222
"coveralls.post": :test,
23-
"coveralls.html": :test
23+
"coveralls.html": :test,
24+
"coveralls.json": :test,
25+
"test.ci": :test
2426
],
2527

2628
# Dialyzer
@@ -60,25 +62,25 @@ defmodule NebulexAdaptersLocal.MixProject do
6062
{:benchee_html, "~> 1.0", only: [:dev, :test]},
6163

6264
# Docs
63-
{:ex_doc, "~> 0.32", only: [:dev, :test], runtime: false}
65+
{:ex_doc, "~> 0.36", only: [:dev, :test], runtime: false}
6466
]
6567
end
6668

6769
defp nebulex_dep do
6870
if path = System.get_env("NEBULEX_PATH") do
6971
{:nebulex, path: path}
7072
else
71-
{:nebulex, github: "cabol/nebulex", branch: "v3.0.0-dev"}
73+
{:nebulex, "~> #{@nbx_vsn}"}
7274
end
7375
end
7476

7577
defp aliases do
7678
[
7779
"nbx.setup": [
7880
"cmd rm -rf nebulex",
79-
"cmd git clone --depth 1 --branch v3.0.0-dev https://github.com/cabol/nebulex"
81+
"cmd git clone --depth 1 --branch v#{@nbx_tag} https://github.com/elixir-nebulex/nebulex"
8082
],
81-
check: [
83+
"test.ci": [
8284
"compile --warnings-as-errors",
8385
"format --check-formatted",
8486
"credo --strict",
@@ -92,12 +94,10 @@ defmodule NebulexAdaptersLocal.MixProject do
9294
defp package do
9395
[
9496
name: :nebulex_local,
95-
maintainers: [
96-
"Carlos Bolanos",
97-
"Felipe Ripoll"
98-
],
97+
maintainers: ["Carlos Bolanos"],
9998
licenses: ["MIT"],
100-
links: %{"GitHub" => @source_url}
99+
links: %{"GitHub" => @source_url},
100+
files: ~w(lib .formatter.exs mix.exs README* CHANGELOG* LICENSE*)
101101
]
102102
end
103103

0 commit comments

Comments
 (0)