diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 21b97db..fa21886 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -33,10 +33,22 @@ jobs: # ------------------------------------------------------------ # Lint repository # ------------------------------------------------------------ + - name: Lint Files + run: | + make lint-files + + - name: Lint Yaml + run: | + make lint-yaml + - name: Lint workflow run: | make lint-workflow + - name: Lint Changelog + run: | + make lint-changelog + - name: Diff generated Docker files run: | make gen-dockerfiles diff --git a/Dockerfiles/work/data/sudo-devilbox b/Dockerfiles/work/data/sudo-devilbox index 16fc745..9547703 100644 --- a/Dockerfiles/work/data/sudo-devilbox +++ b/Dockerfiles/work/data/sudo-devilbox @@ -4,4 +4,3 @@ Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/loca # Allow devilbox user to do anything without password %devilbox ALL=(ALL) NOPASSWD: ALL - diff --git a/Makefile b/Makefile index 09b5372..3c956fc 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ endif # Docker configuration # ------------------------------------------------------------------------------------------------- +CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + DIR = Dockerfiles IMAGE = devilbox/php-fpm NO_CACHE = @@ -15,6 +17,11 @@ PHP_EXT_DIR = # Run checks after each module has been installed (slow, but yields errors faster) FAIL_FAST = False +# File lint +FL_VERSION = 0.3 +FL_IGNORES = .git/,.github/ + + # ------------------------------------------------------------------------------------------------- # DEFAULT TARGET # ------------------------------------------------------------------------------------------------- @@ -74,9 +81,15 @@ help: # Lint Targets # ------------------------------------------------------------------------------------------------- +lint: lint-files +lint: lint-yaml +lint: lint-changelog lint: lint-workflow lint-workflow: + @echo "################################################################################" + @echo "# Lint Workflow" + @echo "################################################################################" @\ GIT_CURR_MAJOR="$$( git tag | sort -V | tail -1 | sed 's|\.[0-9]*$$||g' )"; \ GIT_CURR_MINOR="$$( git tag | sort -V | tail -1 | sed 's|^[0-9]*\.||g' )"; \ @@ -88,6 +101,43 @@ lint-workflow: else \ echo "[OK] Git Tag present in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \ fi + @echo + +lint-changelog: + @echo "################################################################################" + @echo "# Lint Changelog" + @echo "################################################################################" + @\ + GIT_CURR_MAJOR="$$( git tag | sort -V | tail -1 | sed 's|\.[0-9]*$$||g' )"; \ + GIT_CURR_MINOR="$$( git tag | sort -V | tail -1 | sed 's|^[0-9]*\.||g' )"; \ + GIT_NEXT_TAG="$${GIT_CURR_MAJOR}.$$(( GIT_CURR_MINOR + 1 ))"; \ + if ! grep -E "^## Release $${GIT_NEXT_TAG}$$" CHANGELOG.md >/dev/null; then \ + echo "[ERR] Missing '## Release $${GIT_NEXT_TAG}' section in CHANGELOG.md"; \ + exit 1; \ + else \ + echo "[OK] Section '## Release $${GIT_NEXT_TAG}' present in CHANGELOG.md"; \ + fi + @echo + +lint-files: + @echo "################################################################################" + @echo "# Lint Files" + @echo "################################################################################" + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORES)' --path . + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORES)' --path . + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORES)' --path . + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORES)' --path . + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORES)' --path . + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORES)' --path . + @echo + +lint-yaml: + @# Lint all files + @echo "################################################################################" + @echo "# Lint Yaml" + @echo "################################################################################" + @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/yamllint . + @echo # ------------------------------------------------------------------------------------------------- diff --git a/README.md b/README.md index 3955109..40fcef0 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ One main problem with a running Docker container is to **synchronize the ownersh #### Unsynchronized permissions -Consider the following directory structure of a mounted volume. Your hosts computer uid/gid are `1000` which does not have a corresponding user/group within the container. Fortunately the `tmp/` directory allows everybody to create new files in it. +Consider the following directory structure of a mounted volume. Your hosts computer uid/gid are `1000` which does not have a corresponding user/group within the container. Fortunately the `tmp/` directory allows everybody to create new files in it. ```shell [Host] | [Container]