diff --git a/README.md b/README.md index 774c193..2d53b18 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,32 @@ You'll need a separate resource for each Tracker project. * `repos`: *Required.* Paths to the git repositories which will contain the delivering commits. * `comment`: *Optional.* A file containing a comment to leave on any delivered stories. + +## Development + +### Prerequisites + +* golang is *required* - version 1.9.x is tested; earlier versions may also + work. +* docker is *required* - version 17.06.x is tested; earlier versions may also + work. +* godep is used for dependency management of the golang packages. + +### Running the tests + +The tests have been embedded with the `Dockerfile`; ensuring that the testing +environment is consistent across any `docker` enabled platform. When the docker +image builds, the test are run inside the docker container, on failure they +will stop the build. + +Run the tests with the following commands for both `alpine` and `ubuntu` images: + +```sh +docker build -t tracker-resource -f dockerfiles/alpine/Dockerfile . +docker build -t tracker-resource -f dockerfiles/ubuntu/Dockerfile . +``` + +### Contributing + +Please make all pull requests to the `master` branch and ensure tests pass +locally. diff --git a/Dockerfile b/dockerfiles/alpine/Dockerfile similarity index 100% rename from Dockerfile rename to dockerfiles/alpine/Dockerfile diff --git a/dockerfiles/ubuntu/Dockerfile b/dockerfiles/ubuntu/Dockerfile new file mode 100644 index 0000000..e1fb076 --- /dev/null +++ b/dockerfiles/ubuntu/Dockerfile @@ -0,0 +1,31 @@ +FROM concourse/golang-builder as builder +COPY . /go/src/github.com/concourse/tracker-resource +ENV CGO_ENABLED 0 +ENV GOPATH /go/src/github.com/concourse/tracker-resource/Godeps/_workspace:${GOPATH} +ENV PATH /go/src/github.com/concourse/tracker-resource/Godeps/_workspace/bin:${PATH} +RUN go build -o /assets/out github.com/concourse/tracker-resource/out/cmd/out +RUN go build -o /assets/in github.com/concourse/tracker-resource/in/cmd/in +RUN go build -o /assets/check github.com/concourse/tracker-resource/check/cmd/check +RUN set -e; mkdir /tests; for pkg in $(go list ./...); do \ + cp -a $(go list -f '{{.Dir}}' $pkg) /tests/$(basename $pkg); \ + go test -o "/tests/$(basename $pkg)/run" -c $pkg; \ + done + +FROM ubuntu:bionic AS resource +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive \ + apt-get install -y --no-install-recommends \ + tzdata \ + ca-certificates \ + git \ + && rm -rf /var/lib/apt/lists/* +COPY --from=builder /assets /opt/resource + +FROM resource AS tests +COPY --from=builder /tests /tests +RUN set -e; for test in /tests/*/run; do \ + cd $(dirname $test); \ + ./run; \ + done + +FROM resource