From d0bf1fb704574748511554d8e581256b537a21be Mon Sep 17 00:00:00 2001 From: cytopia Date: Thu, 13 Jun 2019 15:10:21 +0200 Subject: [PATCH 1/2] Add integration tests --- Makefile | 38 ++++++++++++++++++++++++++++++++++---- tests/.eslintrc | 9 +++++++++ tests/node.js | 6 ++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tests/.eslintrc create mode 100644 tests/node.js diff --git a/Makefile b/Makefile index 3832b8c..cec8d68 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,10 @@ -.PHONY: build rebuild test tag pull login push enter +ifneq (,) +.error This Makefile requires GNU Make. +endif + +.PHONY: build rebuild test _test_version _test_run tag pull login push enter + +CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) DIR = . FILE = Dockerfile @@ -12,6 +18,13 @@ rebuild: pull docker build --no-cache --build-arg VERSION=$(TAG) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) test: + @$(MAKE) --no-print-directory _test_version + @$(MAKE) --no-print-directory _test_run + +_test_version: + @echo "------------------------------------------------------------" + @echo "- Testing correct version" + @echo "------------------------------------------------------------" @if [ "$(TAG)" = "latest" ]; then \ echo "Fetching latest version from GitHub"; \ LATEST="$$( \ @@ -22,11 +35,28 @@ test: | sed 's/.*v//g' \ )"; \ echo "Testing for latest: $${LATEST}"; \ - docker run --rm $(IMAGE) --version | grep -E "^v?$${LATEST}$$"; \ + if ! docker run --rm $(IMAGE) --version | grep -E "^v?$${LATEST}$$"; then \ + echo "Failed"; \ + exit 1; \ + fi; \ else \ echo "Testing for tag: $(TAG)"; \ - docker run --rm $(IMAGE) --version | grep -E "^v?$(TAG)[.0-9]+$$"; \ - fi + if ! docker run --rm $(IMAGE) --version | grep -E "^v?$(TAG)[.0-9]+$$"; then \ + echo "Failed"; \ + exit 1; \ + fi; \ + fi; \ + echo "Success"; \ + +_test_run: + @echo "------------------------------------------------------------" + @echo "- Testing javascript files " + @echo "------------------------------------------------------------" + @if ! docker run --rm -v $(CURRENT_DIR)/tests:/data $(IMAGE) . ; then \ + echo "Failed"; \ + exit 1; \ + fi; \ + echo "Success"; tag: docker tag $(IMAGE) $(IMAGE):$(TAG) diff --git a/tests/.eslintrc b/tests/.eslintrc new file mode 100644 index 0000000..749edb2 --- /dev/null +++ b/tests/.eslintrc @@ -0,0 +1,9 @@ +{ + "parserOptions": { + "ecmaVersion": 2017 + }, + + "env": { + "es6": true + } +} diff --git a/tests/node.js b/tests/node.js new file mode 100644 index 0000000..4af0d30 --- /dev/null +++ b/tests/node.js @@ -0,0 +1,6 @@ +var http = require('http'); + +http.createServer(function (req, res) { + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.end('Hello World!'); +}).listen(8080); From 4aeff6aa11b2cf910f4d9f2e4f08cfb110de5c82 Mon Sep 17 00:00:00 2001 From: cytopia Date: Thu, 13 Jun 2019 15:11:30 +0200 Subject: [PATCH 2/2] Clarify latest tag --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d519635..d31eb7d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The image is built nightly against multiple stable versions and pushed to Docker | Docker tag | Build from | |------------|------------| -| `latest` | [Branch: master](https://github.com/eslint/eslint) | +| `latest` | Latest stable version | | `5` | Tag: v5.x.x | | `4` | Tag: v4.x.x | | `3` | Tag: v3.x.x |