Compare commits

..

8 Commits

Author SHA1 Message Date
62a24686f7 Merge branch 'cdalvaro/podman_support'
Some checks failed
continuous-integration/drone/push Build is failing
Closes #16
2024-06-24 11:36:03 -07:00
Carlos Álvaro
d10b550878
feat: Add podman support 2024-05-12 18:50:33 +02:00
d67a852ae8 Add test hooks with try-repo
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-26 14:56:42 -07:00
6cf8fe749d Use personal drone-pre-commit image that has docker-compose binary installed
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-26 14:53:53 -07:00
f626253b23 Fix regex to match a literal dot before extension
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Also simplifies the optional a match a bit.

Fixes #15
2023-04-19 09:19:08 -07:00
15a900b1bb Use compose plugin language in documentation 2023-04-19 09:18:55 -07:00
098ffc1472 Remove hadolint completely (inclusing script)
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-18 17:19:44 -07:00
1acd61cff1 Remove hadolint completely
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-04-18 17:18:48 -07:00
6 changed files with 32 additions and 42 deletions

View File

@ -9,9 +9,8 @@ workspace:
steps: steps:
- name: test - name: test
image: iamthefij/drone-pre-commit:latest image: iamthefij/drone-pre-commit@sha256:6ed8dae6b0067bd2e145e36421bcfbbc68975ff7ddaa5a3f285b5bcdaf0989c8
commands: commands:
- pip install docker-compose
- make all - make all
- name: notify - name: notify

View File

@ -1,21 +1,7 @@
--- ---
- id: docker-compose-check - id: docker-compose-check
name: Validate docker-compose files name: Validate docker compose files
description: Checks that docker-compose files are valid description: Checks that docker compose files are valid
language: script language: script
entry: compose-check.sh entry: compose-check.sh
files: (docker-)?compose.y[a]{0,1}ml$ files: (docker-)?compose\.ya?ml$
- id: hadolint
name: Lint Dockerfiles
description: Deprecated! Runs hadolint Docker image to lint Dockerfiles
language: script
entry: hadolint-deprecation.sh
files: Dockerfile
- id: hadolint-system
name: Lint Dockerfiles
description: Deprecated! Runs system hadolint to lint Dockerfiles
language: script
entry: hadolint-deprecation.sh
files: Dockerfile

View File

@ -2,7 +2,7 @@
all: check test all: check test
test: test-negative test-positive test: test-negative test-positive test-hooks
.PHONY: test-positive .PHONY: test-positive
test-positive: test-positive:
@ -16,6 +16,10 @@ test-negative:
@echo "Check multiple files. Should error." @echo "Check multiple files. Should error."
./compose-check.sh tests/docker-compose* && { echo 'fail'; exit 1; } || echo 'ok' ./compose-check.sh tests/docker-compose* && { echo 'fail'; exit 1; } || echo 'ok'
.PHONY: test-hooks
test-hooks:
pre-commit try-repo . --all-files
# Installs pre-commit hooks # Installs pre-commit hooks
.PHONY: install-hooks .PHONY: install-hooks
install-hooks: install-hooks:

View File

@ -19,7 +19,4 @@ and then run `pre-commit autoupdate`.
## Hooks ## Hooks
### docker-compose-check ### docker-compose-check
Verifies that docker-compose files are valid by using `docker-compose config` to parse them. Verifies that docker compose files are valid by using `docker compose config` to parse them.
### hadolint (Removed)
These hooks have been removed in favor of the ones that have been added to https://github.com/hadolint/hadolint

View File

@ -2,28 +2,40 @@
# Verifies that files passed in are valid for docker-compose # Verifies that files passed in are valid for docker-compose
set -e set -e
if command -v docker &> /dev/null && docker help compose &> /dev/null; then # Check if docker or podman commands are available
COMPOSE="docker compose" if [[ -z "${CONTAINER_ENGINE}" ]]; then
elif command -v docker-compose &> /dev/null ; then if command -v docker &>/dev/null; then
COMPOSE=docker-compose CONTAINER_ENGINE=docker
elif command -v podman &>/dev/null; then
CONTAINER_ENGINE=podman
else
echo "ERROR: Neither 'docker' or 'podman' were found"
exit 1
fi
fi
if command -v "${CONTAINER_ENGINE}" &>/dev/null && ${CONTAINER_ENGINE} help compose &> /dev/null; then
COMPOSE="${CONTAINER_ENGINE} compose"
elif command -v "${CONTAINER_ENGINE}-compose" &> /dev/null; then
COMPOSE="${CONTAINER_ENGINE}-compose"
else else
echo "ERROR: Neither 'docker-compose' or 'docker compose' were found" echo "ERROR: Neither '${CONTAINER_ENGINE}-compose' or '${CONTAINER_ENGINE} compose' were found"
exit 1 exit 1
fi fi
check_file() { check_file() {
local file=$1 local file=$1
env $COMPOSE --file "$file" config --quiet 2>&1 \ env $COMPOSE --file "$file" config --quiet 2>&1 |
| sed "/variable is not set. Defaulting/d" sed "/variable is not set. Defaulting/d"
return "${PIPESTATUS[0]}" return "${PIPESTATUS[0]}"
} }
check_files() { check_files() {
local all_files=( "$@" ) local all_files=( "$@" )
has_error=0 has_error=0
for file in "${all_files[@]}" ; do for file in "${all_files[@]}"; do
if [[ -f "$file" ]]; then if [[ -f "$file" ]]; then
if ! check_file "$file" ; then if ! check_file "$file"; then
echo "ERROR: $file" echo "ERROR: $file"
has_error=1 has_error=1
fi fi
@ -32,7 +44,7 @@ check_files() {
return $has_error return $has_error
} }
if ! check_files "$@" ; then if ! check_files "$@"; then
echo "Some compose files failed" echo "Some compose files failed"
fi fi

View File

@ -1,8 +0,0 @@
#! /bin/sh
echo "Hadolint hooks have been deprecated in favor of upstream"
echo "repo: https://github.com/hadolint/hadolint"
echo "Replace hook 'hadolint' with 'hadolint-docker'"
echo "Replace hook 'hadolint-system' with 'hadolint'"
exit 1