Skip to content

Commit

Permalink
Revert to published protobuf library (tiziano88#11)
Browse files Browse the repository at this point in the history
Secondary imports reduce the benefit of including the Elm protobuf library directly

Bug in version 5 of elm-iso8601.  Changing the allowed version range.
  • Loading branch information
jalandis authored Apr 11, 2021
1 parent bfb0130 commit 936f5de
Show file tree
Hide file tree
Showing 31 changed files with 40 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Run tests
strategy:
matrix:
go-version: [ 1.16.x ]
go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
env:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ _cgo_export.*
/protoc-gen-elm
/bin

/elm-test-project/src/Protobuf.elm
/elm-test-project/elm-protobuf-test
/elm-project/elm-protobuf-test

.DS_Store
13 changes: 1 addition & 12 deletions cmd/protoc-gen-elm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
_ "embed"
"fmt"
"io/ioutil"
"log"
Expand All @@ -24,9 +23,6 @@ import (
const version = "0.0.2"
const docUrl = "https://github.com/jalandis/elm-protobuf"

//go:embed Protobuf.elm
var pbLibrary string

var excludedFiles = map[string]bool{
"google/protobuf/timestamp.proto": true,
"google/protobuf/wrappers.proto": true,
Expand Down Expand Up @@ -101,14 +97,7 @@ func main() {
log.Printf("Input data: %s", result)
}

libraryFile := "Protobuf.elm"
resp := &pluginpb.CodeGeneratorResponse{
File: []*pluginpb.CodeGeneratorResponse_File{{
Name: &libraryFile,
Content: &pbLibrary,
}},
}

resp := &pluginpb.CodeGeneratorResponse{}
for _, inFile := range req.GetProtoFile() {
log.Printf("Processing file %s", inFile.GetName())
// Well Known Types.
Expand Down
14 changes: 9 additions & 5 deletions elm-test-project/elm.json → elm-project/elm.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@

{
"type": "package",
"name": "jalandis/elm-protobuf",
"summary": "Test project for Elm PB",
"name": "tiziano88/elm-protobuf",
"summary": "Google Protocol Buffers runtime library",
"license": "MIT",
"version": "0.0.1",
"exposed-modules": [ "*" ],
"version": "3.0.0",
"exposed-modules": [
"Protobuf"
],
"elm-version": "0.19.0 <= v < 0.20.0",
"dependencies": {
"elm/core": "1.0.0 <= v < 2.0.0",
"elm/html": "1.0.0 <= v < 2.0.0",
"elm/json": "1.0.0 <= v < 2.0.0",
"elm/time": "1.0.0 <= v < 2.0.0",
"jweir/elm-iso8601": "5.0.0 <= v < 8.0.0"
"jweir/elm-iso8601": "6.0.0 <= v < 7.0.0"
},
"test-dependencies": {
"elm-explorations/test": "1.1.0 <= v < 2.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ mapEntriesFieldEncoder name valueEncoder v =
Nothing
else
let
items = Dict.toList v
items = Dict.toList v
encodedItems = List.map (\(key, val) -> (key, valueEncoder val)) items
in
Just ( name, JE.object encodedItems)
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions elm-project/tests/Empty.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Empty exposing (..)

-- DO NOT EDIT
-- AUTOGENERATED BY THE ELM PROTOCOL BUFFER COMPILER
-- https://github.com/tiziano88/elm-protobuf
-- source file: empty.proto

import Protobuf exposing (..)

import Json.Decode as JD
import Json.Encode as JE


uselessDeclarationToPreventErrorDueToEmptyOutputFile = 42
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Test exposing (..)
import Time
import Wrappers as W
import Dict
import Empty exposing (..)


suite : Test
Expand Down Expand Up @@ -475,7 +476,7 @@ wrappersSet =

map : M.MessageWithMaps
map =
{ stringToMessages = Dict.fromList
{ stringToMessages = Dict.fromList
[ ( "foo" , { field = True } ),
( "bar" , { field = False } )
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions elm-project/tests/proto/empty.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
syntax = "proto3";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/jalandis/elm-protobuf

go 1.16
go 1.13

require (
github.com/gogo/protobuf v1.3.2
Expand Down
2 changes: 1 addition & 1 deletion scripts/compile_test_plugin
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
set -x

readonly ROOT="$(git rev-parse --show-toplevel)"
readonly TEST_PLUGIN="${ROOT}/elm-test-project/elm-protobuf-test"
readonly TEST_PLUGIN="${ROOT}/elm-project/elm-protobuf-test"

cd "${ROOT}"
GO111MODULE=on go build -o "${TEST_PLUGIN}" ./cmd/protoc-gen-elm
4 changes: 2 additions & 2 deletions scripts/release
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ readonly NEW_VERSION=$(git tag --contains | tr -d v)

# Exit if a tag does not exist for the current commit.
if [[ -z $NEW_VERSION ]]; then
echo "Missing required version tag."
echo "Missing required version tag. Suggestion: git tag -a 0.0.2 -m 'release'"
exit 1
fi

"${ROOT}/scripts/compile_test_plugin"

readonly FOUND_VERSION="$("${ROOT}/elm-test-project/elm-protobuf-test" --version | cut -d' ' -f2)"
readonly FOUND_VERSION="$("${ROOT}/elm-project/elm-protobuf-test" --version | cut -d' ' -f2)"
if [[ "${FOUND_VERSION}" != "${NEW_VERSION}" ]]; then
echo "Versions do not match. Be sure to update the version defined in main.go"
exit 1
Expand Down
3 changes: 1 addition & 2 deletions scripts/run_diff_tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

readonly ROOT="$(git rev-parse --show-toplevel)"
readonly TEST_ROOT="${ROOT}/test-diffs"
readonly ELM_PLUGIN="${ROOT}/elm-test-project/elm-protobuf-test"
readonly ELM_PLUGIN="${ROOT}/elm-project/elm-protobuf-test"

if [[ ! -f "${ELM_PLUGIN}" ]]; then
echo "compiled test plugin required"
Expand All @@ -27,7 +27,6 @@ for TEST in "${TEST_ROOT}"/*/; do
--elm_opt=remove-deprecated \
"${INPUT_DIR}"/*.proto

rm "${OUTPUT_DIR}/Protobuf.elm"
if ! DIFF_OUTPUT=$(diff -y "${EXPECTED_DIR}" "${OUTPUT_DIR}") ; then
echo "${DIFF_OUTPUT}"
echo "Detected difference in ${INPUT_DIR}"
Expand Down
10 changes: 5 additions & 5 deletions scripts/run_elm_tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ set -euo pipefail
set -x

readonly ROOT="$(git rev-parse --show-toplevel)"
readonly TEST_PLUGIN="${ROOT}/elm-test-project/elm-protobuf-test"
readonly TEST_PLUGIN="${ROOT}/elm-project/elm-protobuf-test"

if [[ ! -f "${TEST_PLUGIN}" ]]; then
echo "compiled test plugin required"
exit 1
fi

protoc \
--proto_path="${ROOT}/elm-test-project/tests/proto" \
--elm_out="${ROOT}/elm-test-project/src" \
--proto_path="${ROOT}/elm-project/tests/proto" \
--elm_out="${ROOT}/elm-project/tests" \
--plugin=protoc-gen-elm="${TEST_PLUGIN}" \
"${ROOT}"/elm-test-project/tests/proto/*.proto
"${ROOT}"/elm-project/tests/proto/*.proto

cd "${ROOT}/elm-test-project"
cd "${ROOT}/elm-project"
elm-test

0 comments on commit 936f5de

Please sign in to comment.