Skip to content

Commit

Permalink
Merge pull request #11 from maxohq/master
Browse files Browse the repository at this point in the history
Feat: add __json_serde_alias__() function for alias inspection + configure Github actions CI
  • Loading branch information
bbalser authored Jul 3, 2024
2 parents 88a7bd1 + 4cee6a5 commit 50964c4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
'on':
push: {}
pull_request: {}
jobs:
mix-test:
name: Mix Test
runs-on: ubuntu-latest
env:
MIX_ENV: test
ELIXIR_ENV: test
steps:
- uses: actions/checkout@v3
- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: >-
${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ env.cache-name }}-${{
hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ env.cache-name }}-
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: >-
${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ env.cache-name }}-${{
hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.MIX_ENV }}-${{ env.cache-name }}-
${{ runner.os }}-mix-${{ env.MIX_ENV }}-
${{ runner.os }}-mix
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: 1.16.0
otp-version: 26.1.2
- name: Install dependencies
run: mix deps.get
- name: Run Elixir tests
run: mix test
4 changes: 4 additions & 0 deletions lib/json_serde.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ defmodule JsonSerde do
def __json_serde_construct__() do
unquote(construct)
end

def __json_serde_alias__() do
unquote(alias)
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions test/structs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ defmodule JsonSerde.StructTests do
defstruct [:name, :age, :birthdate]
end

test "struct has meta-info about alias config" do
assert SimpleStruct.__json_serde_alias__() == "simple"
end

test "test with decimal" do
input = %{amount: Decimal.new(1)}

Expand Down

0 comments on commit 50964c4

Please sign in to comment.