diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9a7f95b --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/lib/json_serde.ex b/lib/json_serde.ex index bff9029..5f59e51 100644 --- a/lib/json_serde.ex +++ b/lib/json_serde.ex @@ -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 diff --git a/test/structs_test.exs b/test/structs_test.exs index fe103a8..78af2a0 100644 --- a/test/structs_test.exs +++ b/test/structs_test.exs @@ -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)}