Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 81 additions & 81 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
name: Github Actions CI
on:
push:
branches: [ "main" ]
pull_request:
jobs:
build:
# Containers must run in Linux based operating systems
runs-on: ubuntu-20.04
name: Build and test
env:
MIX_ENV: test
strategy:
matrix:
otp: ['26.2']
elixir: ['1.15.7']
services:
postgres:
image: postgres:13-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bitcrowd_ecto_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
version-type: 'strict'
- run: mix local.hex --force
- run: mix local.rebar --force
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: v1-mix-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: v1-mix-${{ runner.os }}
- name: Restore build cache
uses: actions/cache@v3
with:
path: _build
key: v1-build-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: v1-build-${{ runner.os }}
- name: Install dependencies
run: mix do deps.get, compile
- name: Restore plts cache
uses: actions/cache@v3
with:
path: _plts
key: v1-plt-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: v1-plt-${{ runner.os }}
- name: Linter
run: mix lint
- name: Init DB
run: mix do ecto.create, ecto.migrate
- name: Run tests
run: mix test
name: Github Actions CI

on:
push:
branches: ["main"]
pull_request:

jobs:
build:
# Containers must run in Linux based operating systems
runs-on: ubuntu-24.04
name: Build and test
env:
MIX_ENV: test

strategy:
matrix:
otp: ["28.3"]
elixir: ["1.19.4"]

services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: bitcrowd_ecto_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
version-type: "strict"

- run: mix local.hex --force
- run: mix local.rebar --force

- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: v1-mix-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: v1-mix-${{ runner.os }}

- name: Restore build cache
uses: actions/cache@v3
with:
path: _build
key: v1-build-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: v1-build-${{ runner.os }}

- name: Install dependencies
run: mix do deps.get, compile

- name: Restore plts cache
uses: actions/cache@v3
with:
path: _plts
key: v1-plt-${{ runner.os }}-${{ hashFiles('**/mix.lock') }}
restore-keys: v1-plt-${{ runner.os }}

- name: Linter
run: mix lint

- name: Init DB
run: mix do ecto.create, ecto.migrate

- name: Run tests
run: mix test
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.15.7
erlang 26.2
elixir 1.19.4
erlang 28.3
7 changes: 4 additions & 3 deletions lib/bitcrowd_ecto/changeset.ex
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ defmodule BitcrowdEcto.Changeset do
{:parameterized, Ecto.Embedded, _} ->
:embeds

{:parameterized, {Ecto.Embedded, _}} ->
:embeds

# Simplification, can be extended as needed.
_other ->
:scalars
Expand All @@ -527,9 +530,7 @@ defmodule BitcrowdEcto.Changeset do
end

defp cast_scalars(schema_struct, params, scalars, required) do
# Don't be confused, `--` is right-associative.
# https://hexdocs.pm/elixir/1.15.7/operators.html#operator-precedence-and-associativity
required = scalars -- scalars -- required
required = scalars -- (scalars -- required)

schema_struct
|> Ecto.Changeset.cast(params, scalars)
Expand Down
12 changes: 8 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule BitcrowdEcto.MixProject do
deps: deps(),
dialyzer: dialyzer(),
elixirc_paths: elixirc_paths(Mix.env()),
preferred_cli_env: [lint: :test],
cli: cli(),

# hex.pm
package: package(),
Expand All @@ -29,6 +29,10 @@ defmodule BitcrowdEcto.MixProject do
]
end

def cli do
[preferred_envs: [lint: :test]]
end

defp package do
[
maintainers: ["@bitcrowd"],
Expand Down Expand Up @@ -76,16 +80,16 @@ defmodule BitcrowdEcto.MixProject do

defp deps do
[
{:ecto, "~> 3.6"},
{:ecto_sql, "~> 3.6"},
{:ecto, "~> 3.13"},
{:ecto_sql, "~> 3.13"},
{:ex_money, "~> 5.12", optional: true},
{:ex_money_sql, "~> 1.7", only: [:dev, :test]},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:ex_doc, "> 0.0.0", only: [:dev], runtime: false},
{:ex_machina, "~> 2.7", only: [:dev, :test]},
{:junit_formatter, "~> 3.3", only: [:test]},
{:postgrex, "> 0.0.0", only: [:dev, :test]},
{:postgrex, "> 0.19.0", only: [:dev, :test]},
{:tzdata, "> 0.0.0", only: [:dev, :test]},
# NOTE: https://github.com/kipcole9/money/issues/142
{:jason, "> 0.0.0", optional: true}
Expand Down
Loading
Loading