Skip to content

Commit f4b1a09

Browse files
authored
Merge pull request #2 from cytopia/docs
Docs
2 parents 3190e00 + b1c6df0 commit f4b1a09

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

.travis.yml

+13-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sudo: required
99
###
1010
### Language
1111
###
12-
language: python
12+
language: minimal
1313

1414

1515
###
@@ -48,20 +48,24 @@ env:
4848
### Install requirements
4949
###
5050
install:
51-
# Get newer docker version
52-
- while ! sudo apt-get update; do sleep 1; done
53-
- while ! sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; do sleep 1; done
54-
- docker version
51+
- retry() {
52+
for ((n=0; n<10; n++)); do
53+
echo "[${n}] ${*}";
54+
if eval "${*}"; then
55+
return 0;
56+
fi;
57+
done;
58+
return 1;
59+
}
5560

5661

5762
###
5863
### Check generation changes, build and test
5964
###
6065
before_script:
61-
- make lint
62-
- while ! make build PHPCBF=${PHPCBF} PHP=${PHP}; do sleep 1; done
63-
- while ! make test PHPCBF=${PHPCBF} PHP=${PHP}; do sleep 1; done
64-
- git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
66+
- retry make lint
67+
- retry make build PHPCBF=${PHPCBF} PHP=${PHP}
68+
- retry make test PHPCBF=${PHPCBF} PHP=${PHP}
6569

6670

6771
###

Makefile

+26-24
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ifneq (,)
22
.error This Makefile requires GNU Make.
33
endif
44

5-
.PHONY: build rebuild lint test _test-phpcbf-version _test-php-version _test-run tag pull login push enter
5+
.PHONY: build rebuild lint test _test-phpcbf-version _test-php-version _test-run _get-php-version tag pull login push enter
66

77
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
88

@@ -69,33 +69,16 @@ _test-phpcbf-version:
6969
fi; \
7070
echo "Success"; \
7171

72-
_test-php-version:
72+
_test-php-version: _get-php-version
7373
@echo "------------------------------------------------------------"
7474
@echo "- Testing correct PHP version"
7575
@echo "------------------------------------------------------------"
76-
@if [ "$(PHP)" = "latest" ]; then \
77-
echo "Fetching latest version from GitHub"; \
78-
LATEST="$$( \
79-
curl -L -sS https://github.com/php/php-src/releases \
80-
| tac | tac \
81-
| grep -Eo '/php-[.0-9]+?\.[.0-9]+"' \
82-
| grep -Eo '[.0-9]+' \
83-
| sort -V \
84-
| tail -1 \
85-
)"; \
86-
echo "Testing for latest: $${LATEST}"; \
87-
if ! docker run --rm --entrypoint=php $(IMAGE) --version | head -1 | grep -E "^PHP[[:space:]]+$${LATEST}[[:space:]]"; then \
88-
echo "Failed"; \
89-
exit 1; \
90-
fi; \
91-
else \
92-
echo "Testing for tag: $(PHP).x"; \
93-
if ! docker run --rm --entrypoint=php $(IMAGE) --version | head -1 | grep -E "^PHP[[:space:]]+$(PHP)\.[.0-9]+[[:space:]]"; then \
94-
echo "Failed"; \
95-
exit 1; \
96-
fi; \
76+
@echo "Testing for tag: $(CURRENT_PHP_VERSION)"
77+
@if ! docker run --rm --entrypoint=php $(IMAGE) --version | head -1 | grep -E "^PHP[[:space:]]+$(CURRENT_PHP_VERSION)([.0-9]+)?"; then \
78+
echo "Failed"; \
79+
exit 1; \
9780
fi; \
98-
echo "Success"; \
81+
echo "Success";
9982

10083
_test-run:
10184
@echo "------------------------------------------------------------"
@@ -119,9 +102,13 @@ tag:
119102
docker tag $(IMAGE) $(IMAGE):$(TAG)
120103

121104
pull:
105+
@echo "Pull base image"
122106
@grep -E '^\s*FROM' Dockerfile \
123107
| sed -e 's/^FROM//g' -e 's/[[:space:]]*as[[:space:]]*.*$$//g' \
108+
| head -1 \
124109
| xargs -n1 docker pull;
110+
@echo "Pull target image"
111+
docker pull php:$(PHP)-cli-alpine
125112

126113
login:
127114
yes | docker login --username $(USER) --password $(PASS)
@@ -132,3 +119,18 @@ push:
132119

133120
enter:
134121
docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=/bin/sh $(ARG) $(IMAGE):$(TAG)
122+
123+
# Fetch latest available PHP version for cli-alpine
124+
_get-php-version:
125+
$(eval CURRENT_PHP_VERSION = $(shell \
126+
if [ "$(PHP)" = "latest" ]; then \
127+
curl -L -sS https://hub.docker.com/api/content/v1/products/images/php \
128+
| tac | tac \
129+
| grep -Eo '`[.0-9]+-cli-alpine' \
130+
| grep -Eo '[.0-9]+' \
131+
| sort -u \
132+
| tail -1; \
133+
else \
134+
echo $(PHP); \
135+
fi; \
136+
))

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
> [eslint](https://github.com/cytopia/docker-eslint) ****
1818
> [file-lint](https://github.com/cytopia/docker-file-lint) ****
1919
> [gofmt](https://github.com/cytopia/docker-gofmt) ****
20-
> [goimports](https://github.com/cytopia/docker-phpcbf) ****
20+
> [goimports](https://github.com/cytopia/docker-goimports) ****
2121
> [golint](https://github.com/cytopia/docker-golint) ****
2222
> [jsonlint](https://github.com/cytopia/docker-jsonlint) ****
2323
> [phpcbf](https://github.com/cytopia/docker-phpcbf) ****
24-
> [phpcs](https://github.com/cytopia/docker-phpcbf) ****
24+
> [phpcs](https://github.com/cytopia/docker-phpcs) ****
2525
> [php-cs-fixer](https://github.com/cytopia/docker-php-cs-fixer) ****
2626
> [pycodestyle](https://github.com/cytopia/docker-pycodestyle) ****
2727
> [pylint](https://github.com/cytopia/docker-pylint) ****
2828
> [terraform-docs](https://github.com/cytopia/docker-terraform-docs) ****
2929
> [terragrunt](https://github.com/cytopia/docker-terragrunt) ****
30+
> [terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt) ****
3031
> [yamllint](https://github.com/cytopia/docker-yamllint)
3132
3233

@@ -122,7 +123,7 @@ linter below for reproducible local or remote CI tests:
122123
| [ansible](https://github.com/cytopia/docker-ansible) | Ansible | Multiple versoins of Ansible |
123124
| [ansible-lint](https://github.com/cytopia/docker-ansible-lint) | Ansible | Lint Ansible |
124125
| [gofmt](https://github.com/cytopia/docker-gofmt) | Go | Format Go source code **<sup>[1]</sup>** |
125-
| [goimports](https://github.com/cytopia/docker-phpcbf) | Go | Format Go source code **<sup>[1]</sup>** |
126+
| [goimports](https://github.com/cytopia/docker-goimports) | Go | Format Go source code **<sup>[1]</sup>** |
126127
| [golint](https://github.com/cytopia/docker-golint) | Go | Lint Go code |
127128
| [eslint](https://github.com/cytopia/docker-eslint) | Javascript | Lint Javascript code |
128129
| [checkmake](https://github.com/cytopia/docker-checkmake) | Make | Lint Makefiles |
@@ -134,6 +135,7 @@ linter below for reproducible local or remote CI tests:
134135
| [pylint](https://github.com/cytopia/docker-pylint) | Python | Python source code, bug and quality checker |
135136
| [terraform-docs](https://github.com/cytopia/docker-terraform-docs) | Terraform | Terraform doc generator (TF 0.12 ready) **<sup>[1]</sup>** |
136137
| [terragrunt](https://github.com/cytopia/docker-terragrunt) | Terraform | Terragrunt and Terraform |
138+
| [terragrunt-fmt](https://github.com/cytopia/docker-terragrunt-fmt) | Terraform | `terraform fmt` for Terragrunt files **<sup>[1]</sup>** |
137139

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

0 commit comments

Comments
 (0)