Skip to content

Commit

Permalink
Merge pull request #1 from sleipnir/fix/remove-depreciated
Browse files Browse the repository at this point in the history
Use structs instead factory functions
  • Loading branch information
drowzy authored Mar 28, 2024
2 parents 9e5b885 + 50bed30 commit f470494
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
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

0 comments on commit f470494

Please sign in to comment.