Skip to content

Commit

Permalink
Merge pull request #3 from cytopia/release-0.3
Browse files Browse the repository at this point in the history
Add integration tests
  • Loading branch information
cytopia authored Jun 13, 2019
2 parents 68488ea + 4aeff6a commit 6912f61
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
38 changes: 34 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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="$$( \
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
9 changes: 9 additions & 0 deletions tests/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"parserOptions": {
"ecmaVersion": 2017
},

"env": {
"es6": true
}
}
6 changes: 6 additions & 0 deletions tests/node.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 6912f61

Please sign in to comment.