F21 closed pull request #33: [CALCITE-2579] Implement live reloading of tests 
when source files change during development
URL: https://github.com/apache/calcite-avatica-go/pull/33
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/Dockerfile b/Dockerfile
index 92b8bd4..1a908d9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -13,8 +13,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM golang:1.11-alpine
+FROM golang:1.11-alpine as base
 
+ENV DEV ""
+
+RUN apk --no-cache --no-progress add build-base git
+RUN go get github.com/unchartedsoftware/witch
 WORKDIR /source
-COPY . .
-RUN apk --no-cache --no-progress add build-base git
\ No newline at end of file
+ENTRYPOINT ["sh", "./entrypoint.sh"]
diff --git a/docker-compose.yml b/docker-compose.yml
index 4eb45f1..147aee1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -20,7 +20,10 @@ services:
     environment:
       PHOENIX_HOST: http://phoenix:8765
       HSQLDB_HOST: http://hsqldb:8765
-    command: sh -c "export AVATICA_FLAVOR=HSQLDB && go test -v ./...; export 
AVATICA_FLAVOR=PHOENIX && go test -v ./..."
+      DEV: ${DEV}
+    volumes:
+      - .:/source
+      - $GOPATH/pkg/mod/cache:/go/pkg/mod/cache
   phoenix:
     image: boostport/hbase-phoenix-all-in-one:2.0-5.0
   hsqldb:
diff --git a/moby.yml b/entrypoint.sh
old mode 100644
new mode 100755
similarity index 53%
rename from moby.yml
rename to entrypoint.sh
index f85c051..0d061fd
--- a/moby.yml
+++ b/entrypoint.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
@@ -12,32 +14,11 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-#
-services:
-  - id: phoenix
-    image: boostport/hbase-phoenix-all-in-one:2.0-5.0
-
-  - id: hsqldb
-    image: f21global/calcite-avatica:1.12.0-hypersql
-    command: -u jdbc:hsqldb:mem:public
-    ports:
-      - "8765"
-
-dev:
-  image: golang:1.11-alpine
-  env:
-    PHOENIX_HOST: http://phoenix:8765
-    HSQLDB_HOST: http://hsqldb:8765
 
-  steps:
-    - type: script
-      name: Install build tools and git
-      options:
-        command: apk --no-cache --no-progress add build-base git
+TEST_COMMAND="export AVATICA_FLAVOR=HSQLDB && go test -v ./...; export 
AVATICA_FLAVOR=PHOENIX && go test -v ./..."
 
-  reload:
-    - type: script
-      name: Run tests
-      cwd: /source
-      options:
-        command: export AVATICA_FLAVOR=HSQLDB && go test -v ./... && export 
AVATICA_FLAVOR=PHOENIX && go test -v ./...
\ No newline at end of file
+if [[ -z "${DEV}" ]]; then
+  sh -c "$TEST_COMMAND"
+else
+  witch --cmd="$TEST_COMMAND" --watch="*.mod,**/*.go"
+fi
\ No newline at end of file
diff --git a/site/develop/avatica-go.md b/site/develop/avatica-go.md
index 81bd539..30d5c38 100644
--- a/site/develop/avatica-go.md
+++ b/site/develop/avatica-go.md
@@ -36,6 +36,17 @@ as the component.
 To update the procotol buffer definitions, update `AVATICA_VER` in 
`gen-protobuf.bat` and `gen-protobuf.sh` to match
 the version you want to generate protobufs for and then run the appropriate 
script for your platform.
 
+## Live reload during development
+
+It is possible to reload the code in real-time during development. This 
executes the test suite every time a `.go` or
+`.mod` file is updated. The test suite takes a while to run, so the tests will 
not complete instantly, but live-reloading
+during development allows us to not have to manually execute the test suite on 
save.
+
+### Set up
+1. Install [docker](https://docs.docker.com/install/) and 
[docker-compose](https://docs.docker.com/compose/install/).
+
+2. From the root of the repository, run `DEV=true docker-compose up --build`.
+
 ## Testing
 
 The test suite takes around 4 minutes to run if you run both the Avatica 
HSQLDB and Apache Phoenix tests.
@@ -43,7 +54,7 @@ The test suite takes around 4 minutes to run if you run both 
the Avatica HSQLDB
 ### Easy way
 1. Install [docker](https://docs.docker.com/install/) and 
[docker-compose](https://docs.docker.com/compose/install/).
 
-2. From the root of the repository, run `docker-compose up --build`.
+2. From the root of the repository, run `docker-compose up --build 
--abort-on-container-exit`.
 
 ### Manual set up
 1. Install [Go](https://golang.org/doc/install).


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to