Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use structs instead factory functions #1

Merged
merged 3 commits into from
Mar 28, 2024
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
50 changes: 27 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,43 @@ name: Elixir CI

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

permissions:
contents: read

jobs:
build:

name: Build and test
runs-on: ubuntu-latest
strategy:
matrix:
otp: [24]
elixir: [1.12]

steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@988e02bfe678367a02564f65ca2e37726dc0268f
with:
elixir-version: '1.12.3' # Define the elixir version [required]
otp-version: '24.1' # Define the OTP version [required]
- uses: actions/checkout@v3

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{matrix.elixir}}
otp-version: ${{matrix.otp}} # Define the OTP version [required]

- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.17.3"
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.17.3"

- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test
13 changes: 6 additions & 7 deletions lib/mix/protobuf.generate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ defmodule Mix.Tasks.Protobuf.Generate do

files = normalize_import_paths(files, imports, [])

Google.Protobuf.Compiler.CodeGeneratorRequest.new(
%Google.Protobuf.Compiler.CodeGeneratorRequest{
file_to_generate: files,
proto_file: file_descriptors
)
}
end

defp generate(ctx, request) do
Expand All @@ -126,11 +126,10 @@ defmodule Mix.Tasks.Protobuf.Generate do
CodeGen.generate(ctx, desc, plugins)
end)

response =
Google.Protobuf.Compiler.CodeGeneratorResponse.new(
file: files,
supported_features: Protobuf.Protoc.CLI.supported_features()
)
response = %Google.Protobuf.Compiler.CodeGeneratorResponse{
file: files,
supported_features: Protobuf.Protoc.CLI.supported_features()
}

response
end
Expand Down
8 changes: 4 additions & 4 deletions lib/protobuf_generate/code_gen.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ defmodule ProtobufGenerate.CodeGen do
for {mod_name, content} <- module_definitions do
file_name = Macro.underscore(mod_name) <> ".pb.ex"

Google.Protobuf.Compiler.CodeGeneratorResponse.File.new(
%Google.Protobuf.Compiler.CodeGeneratorResponse.File{
name: file_name,
content: content
)
}
end
end

Expand All @@ -71,10 +71,10 @@ defmodule ProtobufGenerate.CodeGen do
|> Util.format()

[
Google.Protobuf.Compiler.CodeGeneratorResponse.File.new(
%Google.Protobuf.Compiler.CodeGeneratorResponse.File{
name: file_name,
content: content
)
}
]
end

Expand Down