Skip to content
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
22 changes: 13 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sudo: required
###
### Language
###
language: python
language: minimal


###
Expand Down Expand Up @@ -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}


###
Expand Down
51 changes: 27 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "------------------------------------------------------------"
Expand All @@ -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)
Expand All @@ -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; \
))
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) **•**
Expand All @@ -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)


Expand Down Expand Up @@ -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 **<sup>[1]</sup>** |
| [goimports](https://github.com/cytopia/docker-phpcs) | Go | Format Go source code **<sup>[1]</sup>** |
| [goimports](https://github.com/cytopia/docker-goimports) | Go | Format Go source code **<sup>[1]</sup>** |
| [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 |
Expand All @@ -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) **<sup>[1]</sup>** |
| [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 **<sup>[1]</sup>** |

> **<sup>[1]</sup>** Uses a shell wrapper to add **enhanced functionality** not available by original project.

Expand Down