diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 094ab5d..811f645 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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: diff --git a/.gitignore b/.gitignore index 409d003..2525379 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/cmd/protoc-gen-elm/main.go b/cmd/protoc-gen-elm/main.go index 5e57dbd..51f2878 100644 --- a/cmd/protoc-gen-elm/main.go +++ b/cmd/protoc-gen-elm/main.go @@ -2,7 +2,6 @@ package main import ( "bytes" - _ "embed" "fmt" "io/ioutil" "log" @@ -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, @@ -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. diff --git a/elm-test-project/elm.json b/elm-project/elm.json similarity index 55% rename from elm-test-project/elm.json rename to elm-project/elm.json index 16c0cd2..df124a9 100644 --- a/elm-test-project/elm.json +++ b/elm-project/elm.json @@ -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" diff --git a/cmd/protoc-gen-elm/Protobuf.elm b/elm-project/src/Protobuf.elm similarity index 99% rename from cmd/protoc-gen-elm/Protobuf.elm rename to elm-project/src/Protobuf.elm index 1b00c2d..6806434 100644 --- a/cmd/protoc-gen-elm/Protobuf.elm +++ b/elm-project/src/Protobuf.elm @@ -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) diff --git a/elm-test-project/src/Dir/Other_dir.elm b/elm-project/tests/Dir/Other_dir.elm similarity index 100% rename from elm-test-project/src/Dir/Other_dir.elm rename to elm-project/tests/Dir/Other_dir.elm diff --git a/elm-project/tests/Empty.elm b/elm-project/tests/Empty.elm new file mode 100644 index 0000000..acfba02 --- /dev/null +++ b/elm-project/tests/Empty.elm @@ -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 diff --git a/elm-test-project/src/Fuzzer.elm b/elm-project/tests/Fuzzer.elm similarity index 100% rename from elm-test-project/src/Fuzzer.elm rename to elm-project/tests/Fuzzer.elm diff --git a/elm-test-project/src/Integers.elm b/elm-project/tests/Integers.elm similarity index 100% rename from elm-test-project/src/Integers.elm rename to elm-project/tests/Integers.elm diff --git a/elm-test-project/src/Keywords.elm b/elm-project/tests/Keywords.elm similarity index 100% rename from elm-test-project/src/Keywords.elm rename to elm-project/tests/Keywords.elm diff --git a/elm-test-project/tests/Main.elm b/elm-project/tests/Main.elm similarity index 99% rename from elm-test-project/tests/Main.elm rename to elm-project/tests/Main.elm index c5a59d6..b1279a3 100644 --- a/elm-test-project/tests/Main.elm +++ b/elm-project/tests/Main.elm @@ -17,6 +17,7 @@ import Test exposing (..) import Time import Wrappers as W import Dict +import Empty exposing (..) suite : Test @@ -475,7 +476,7 @@ wrappersSet = map : M.MessageWithMaps map = - { stringToMessages = Dict.fromList + { stringToMessages = Dict.fromList [ ( "foo" , { field = True } ), ( "bar" , { field = False } ) ], diff --git a/elm-test-project/src/Map.elm b/elm-project/tests/Map.elm similarity index 100% rename from elm-test-project/src/Map.elm rename to elm-project/tests/Map.elm diff --git a/elm-test-project/src/Other.elm b/elm-project/tests/Other.elm similarity index 100% rename from elm-test-project/src/Other.elm rename to elm-project/tests/Other.elm diff --git a/elm-test-project/src/Recursive.elm b/elm-project/tests/Recursive.elm similarity index 100% rename from elm-test-project/src/Recursive.elm rename to elm-project/tests/Recursive.elm diff --git a/elm-test-project/src/Simple.elm b/elm-project/tests/Simple.elm similarity index 100% rename from elm-test-project/src/Simple.elm rename to elm-project/tests/Simple.elm diff --git a/elm-test-project/src/Wrappers.elm b/elm-project/tests/Wrappers.elm similarity index 100% rename from elm-test-project/src/Wrappers.elm rename to elm-project/tests/Wrappers.elm diff --git a/elm-test-project/tests/proto/dir/other_dir.proto b/elm-project/tests/proto/dir/other_dir.proto similarity index 100% rename from elm-test-project/tests/proto/dir/other_dir.proto rename to elm-project/tests/proto/dir/other_dir.proto diff --git a/elm-project/tests/proto/empty.proto b/elm-project/tests/proto/empty.proto new file mode 100644 index 0000000..410bfde --- /dev/null +++ b/elm-project/tests/proto/empty.proto @@ -0,0 +1 @@ +syntax = "proto3"; diff --git a/elm-test-project/tests/proto/fuzzer.proto b/elm-project/tests/proto/fuzzer.proto similarity index 100% rename from elm-test-project/tests/proto/fuzzer.proto rename to elm-project/tests/proto/fuzzer.proto diff --git a/elm-test-project/tests/proto/integers.proto b/elm-project/tests/proto/integers.proto similarity index 100% rename from elm-test-project/tests/proto/integers.proto rename to elm-project/tests/proto/integers.proto diff --git a/elm-test-project/tests/proto/keywords.proto b/elm-project/tests/proto/keywords.proto similarity index 100% rename from elm-test-project/tests/proto/keywords.proto rename to elm-project/tests/proto/keywords.proto diff --git a/elm-test-project/tests/proto/map.proto b/elm-project/tests/proto/map.proto similarity index 100% rename from elm-test-project/tests/proto/map.proto rename to elm-project/tests/proto/map.proto diff --git a/elm-test-project/tests/proto/other.proto b/elm-project/tests/proto/other.proto similarity index 100% rename from elm-test-project/tests/proto/other.proto rename to elm-project/tests/proto/other.proto diff --git a/elm-test-project/tests/proto/recursive.proto b/elm-project/tests/proto/recursive.proto similarity index 100% rename from elm-test-project/tests/proto/recursive.proto rename to elm-project/tests/proto/recursive.proto diff --git a/elm-test-project/tests/proto/simple.proto b/elm-project/tests/proto/simple.proto similarity index 100% rename from elm-test-project/tests/proto/simple.proto rename to elm-project/tests/proto/simple.proto diff --git a/elm-test-project/tests/proto/wrappers.proto b/elm-project/tests/proto/wrappers.proto similarity index 100% rename from elm-test-project/tests/proto/wrappers.proto rename to elm-project/tests/proto/wrappers.proto diff --git a/go.mod b/go.mod index 9955335..e9f8337 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/jalandis/elm-protobuf -go 1.16 +go 1.13 require ( github.com/gogo/protobuf v1.3.2 diff --git a/scripts/compile_test_plugin b/scripts/compile_test_plugin index eec871f..b1eeef3 100755 --- a/scripts/compile_test_plugin +++ b/scripts/compile_test_plugin @@ -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 diff --git a/scripts/release b/scripts/release index b4afc8f..919a73d 100755 --- a/scripts/release +++ b/scripts/release @@ -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 diff --git a/scripts/run_diff_tests b/scripts/run_diff_tests index 0bd448e..bcd456d 100755 --- a/scripts/run_diff_tests +++ b/scripts/run_diff_tests @@ -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" @@ -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}" diff --git a/scripts/run_elm_tests b/scripts/run_elm_tests index 189969b..745ecd5 100755 --- a/scripts/run_elm_tests +++ b/scripts/run_elm_tests @@ -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" if [[ ! -f "${TEST_PLUGIN}" ]]; then echo "compiled test plugin required" @@ -12,10 +12,10 @@ if [[ ! -f "${TEST_PLUGIN}" ]]; then 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