diff --git a/.travis.yml b/.travis.yml
index 52d3402..7cad066 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,7 @@ sudo: required
###
### Language
###
-language: python
+language: minimal
###
@@ -48,20 +48,24 @@ env:
### Install requirements
###
install:
- # Get newer docker version
- - while ! sudo apt-get update; do sleep 1; done
- - while ! sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; do sleep 1; done
- - docker version
+ - retry() {
+ for ((n=0; n<10; n++)); do
+ echo "[${n}] ${*}";
+ if eval "${*}"; then
+ return 0;
+ fi;
+ done;
+ return 1;
+ }
###
### Check generation changes, build and test
###
before_script:
- - make lint
- - while ! make build PHPCS=${PHPCS} PHP=${PHP}; do sleep 1; done
- - while ! make test PHPCS=${PHPCS} PHP=${PHP}; do sleep 1; done
- - git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
+ - retry make lint
+ - retry make build PHPCS=${PHPCS} PHP=${PHP}
+ - retry make test PHPCS=${PHPCS} PHP=${PHP}
###
diff --git a/Makefile b/Makefile
index ad0dc14..5fe51d8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,10 @@ ifneq (,)
.error This Makefile requires GNU Make.
endif
-.PHONY: build rebuild lint test _test-phpcs-version _test-php-version _test-run tag pull login push enter
+.PHONY: build rebuild lint test _test-phpcs-version _test-php-version _test-run _get-php-version tag pull login push enter
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
+CURRENT_PHP_VERSION =
DIR = .
FILE = Dockerfile
@@ -69,33 +70,16 @@ _test-phpcs-version:
fi; \
echo "Success"; \
-_test-php-version:
+_test-php-version: _get-php-version
@echo "------------------------------------------------------------"
@echo "- Testing correct PHP version"
@echo "------------------------------------------------------------"
- @if [ "$(PHP)" = "latest" ]; then \
- echo "Fetching latest version from GitHub"; \
- LATEST="$$( \
- curl -L -sS https://github.com/php/php-src/releases \
- | tac | tac \
- | grep -Eo '/php-[.0-9]+?\.[.0-9]+"' \
- | grep -Eo '[.0-9]+' \
- | sort -V \
- | tail -1 \
- )"; \
- echo "Testing for latest: $${LATEST}"; \
- if ! docker run --rm --entrypoint=php $(IMAGE) --version | head -1 | grep -E "^PHP[[:space:]]+$${LATEST}[[:space:]]"; then \
- echo "Failed"; \
- exit 1; \
- fi; \
- else \
- echo "Testing for tag: $(PHP).x"; \
- if ! docker run --rm --entrypoint=php $(IMAGE) --version | head -1 | grep -E "^PHP[[:space:]]+$(PHP)\.[.0-9]+[[:space:]]"; then \
- echo "Failed"; \
- exit 1; \
- fi; \
+ @echo "Testing for tag: $(CURRENT_PHP_VERSION)"
+ @if ! docker run --rm --entrypoint=php $(IMAGE) --version | head -1 | grep -E "^PHP[[:space:]]+$(CURRENT_PHP_VERSION)([.0-9]+)?"; then \
+ echo "Failed"; \
+ exit 1; \
fi; \
- echo "Success"; \
+ echo "Success";
_test-run:
@echo "------------------------------------------------------------"
@@ -119,9 +103,13 @@ tag:
docker tag $(IMAGE) $(IMAGE):$(TAG)
pull:
+ @echo "Pull base image"
@grep -E '^\s*FROM' Dockerfile \
| sed -e 's/^FROM//g' -e 's/[[:space:]]*as[[:space:]]*.*$$//g' \
+ | head -1 \
| xargs -n1 docker pull;
+ @echo "Pull target image"
+ docker pull php:$(PHP)-cli-alpine
login:
yes | docker login --username $(USER) --password $(PASS)
@@ -132,3 +120,18 @@ push:
enter:
docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=/bin/sh $(ARG) $(IMAGE):$(TAG)
+
+# Fetch latest available PHP version for cli-alpine
+_get-php-version:
+ $(eval CURRENT_PHP_VERSION = $(shell \
+ if [ "$(PHP)" = "latest" ]; then \
+ curl -L -sS https://hub.docker.com/api/content/v1/products/images/php \
+ | tac | tac \
+ | grep -Eo '`[.0-9]+-cli-alpine' \
+ | grep -Eo '[.0-9]+' \
+ | sort -u \
+ | tail -1; \
+ else \
+ echo $(PHP); \
+ fi; \
+ ))
diff --git a/README.md b/README.md
index a0915ae..54d8389 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
> [eslint](https://github.com/cytopia/docker-eslint) **•**
> [file-lint](https://github.com/cytopia/docker-file-lint) **•**
> [gofmt](https://github.com/cytopia/docker-gofmt) **•**
-> [goimports](https://github.com/cytopia/docker-phpcs) **•**
+> [goimports](https://github.com/cytopia/docker-goimports) **•**
> [golint](https://github.com/cytopia/docker-golint) **•**
> [jsonlint](https://github.com/cytopia/docker-jsonlint) **•**
> [phpcbf](https://github.com/cytopia/docker-phpcbf) **•**
@@ -27,6 +27,7 @@
> [pylint](https://github.com/cytopia/docker-pylint) **•**
> [terraform-docs](https://github.com/cytopia/docker-terraform-docs) **•**
> [terragrunt](https://github.com/cytopia/docker-terragrunt) **•**
+> [terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt) **•**
> [yamllint](https://github.com/cytopia/docker-yamllint)
@@ -122,7 +123,7 @@ linter below for reproducible local or remote CI tests:
| [ansible](https://github.com/cytopia/docker-ansible) | Ansible | Multiple versoins of Ansible |
| [ansible-lint](https://github.com/cytopia/docker-ansible-lint) | Ansible | Lint Ansible |
| [gofmt](https://github.com/cytopia/docker-gofmt) | Go | Format Go source code **[1]** |
-| [goimports](https://github.com/cytopia/docker-phpcs) | Go | Format Go source code **[1]** |
+| [goimports](https://github.com/cytopia/docker-goimports) | Go | Format Go source code **[1]** |
| [golint](https://github.com/cytopia/docker-golint) | Go | Lint Go code |
| [eslint](https://github.com/cytopia/docker-eslint) | Javascript | Lint Javascript code |
| [checkmake](https://github.com/cytopia/docker-checkmake) | Make | Lint Makefiles |
@@ -134,6 +135,7 @@ linter below for reproducible local or remote CI tests:
| [pylint](https://github.com/cytopia/docker-pylint) | Python | Python source code, bug and quality checker |
| [terraform-docs](https://github.com/cytopia/docker-terraform-docs) | Terraform | Terraform doc generator (TF 0.12 ready) **[1]** |
| [terragrunt](https://github.com/cytopia/docker-terragrunt) | Terraform | Terragrunt and Terraform |
+| [terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt) | Terraform | `terraform fmt` for Terragrunt files **[1]** |
> **[1]** Uses a shell wrapper to add **enhanced functionality** not available by original project.