Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosestito authored Sep 30, 2022
1 parent b920f2e commit 1a1cd12
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 7 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-20.04
env:
MIX_ENV: test
strategy:
fail-fast: false
matrix:
include:
- pair:
elixir: "1.10"
otp: 21
- pair:
elixir: "1.14"
otp: 25.1
lint: lint
steps:
- uses: actions/checkout@v2

- uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.pair.otp}}
elixir-version: ${{matrix.pair.elixir}}

- uses: actions/cache@v2
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{matrix.pair.elixir}}-${{matrix.pair.otp}}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
- run: mix deps.get
- run: mix format --check-formatted
if: ${{ matrix.lint }}

- run: mix deps.unlock --check-unused
if: ${{ matrix.lint }}

- run: mix deps.compile

- run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}

- run: mix test
if: ${{ ! matrix.lint }}

- run: mix test --warnings-as-errors
if: ${{ matrix.lint }}
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
elixir 1.14.0-otp-25
erlang 25.1
3 changes: 2 additions & 1 deletion lib/proto_validator/protoc/generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ defmodule ProtoValidator.Protoc.Generator do
get_type_name(type, type_name, type_mappings)
end

defp get_type_name(type, nil, _type_mappings), do: ":#{ProtoValidator.Protoc.Utils.from_enum(type)}"
defp get_type_name(type, nil, _type_mappings),
do: ":#{ProtoValidator.Protoc.Utils.from_enum(type)}"

defp get_type_name(_type, type_name, type_mappings) do
<<?., fqn::binary>> = type_name
Expand Down
2 changes: 1 addition & 1 deletion lib/validate.pb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ defmodule Validate.PbExtension do
use Protobuf, protoc_gen_elixir_version: "0.11.0", syntax: :proto2

extend Google.Protobuf.FieldOptions, :rules, 1071, optional: true, type: Validate.FieldRules
end
end
2 changes: 1 addition & 1 deletion lib/validator.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule ProtoValidator.Validator do
@validator Application.get_env(:proto_validator, :validator, :vex)
@validator Application.compile_env(:proto_validator, :validator, :vex)

import ProtoValidator.Utils, only: [pipe_validates: 2]

Expand Down
2 changes: 0 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
%{
"google_protobuf": {:git, "https://github.com/protocolbuffers/protobuf.git", "fcd26beabe034142c0f1a693f7cb6e1517b03de3", [branch: "main", submodules: true]},
"google_protos": {:hex, :google_protos, "0.2.0", "7c6280e288d7f04a58448444b12d937ddc8cc40dc3d1e4f61c69936ef71d4739", [:mix], [{:protobuf, "~> 0.8", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "5de24802e89867cea544d0ee8cbd36f6c9c1ebd4a9fcc55276d6eeadeedcc1f5"},
"protobuf": {:hex, :protobuf, "0.11.0", "58d5531abadea3f71135e97bd214da53b21adcdb5b1420aee63f4be8173ec927", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "30ad9a867a5c5a0616cac9765c4d2c2b7b0030fa81ea6d0c14c2eb5affb6ac52"},
"vex": {:hex, :vex, "0.9.0", "613ea5eb3055662e7178b83e25b2df0975f68c3d8bb67c1645f0573e1a78d606", [:mix], [], "hexpm", "c69fff44d5c8aa3f1faee71bba1dcab05dd36364c5a629df8bb11751240c857f"},
}
2 changes: 1 addition & 1 deletion test/proto_gen/example.pb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ defmodule Examplepb.Foo do
use Protobuf, protoc_gen_elixir_version: "0.11.0", syntax: :proto3

field :int32, 1, type: :int32, deprecated: false
end
end
2 changes: 1 addition & 1 deletion test/proto_gen/example.pb.validate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ defmodule ProtoValidator.Gen.Examplepb.Foo do
use ProtoValidator, entity: Examplepb.Foo

validate(:int32, type: :int32, int32: [gte: 0, lte: 10])
end
end

0 comments on commit 1a1cd12

Please sign in to comment.