Skip to content

Add integration tests #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);