Compare commits
1 Commits
master
...
standalone
Author | SHA1 | Date | |
---|---|---|---|
6b0960f8a6 |
@ -9,8 +9,9 @@ workspace:
|
|||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: iamthefij/drone-pre-commit@sha256:6ed8dae6b0067bd2e145e36421bcfbbc68975ff7ddaa5a3f285b5bcdaf0989c8
|
image: iamthefij/drone-pre-commit:latest
|
||||||
commands:
|
commands:
|
||||||
|
- pip install docker-compose
|
||||||
- make all
|
- make all
|
||||||
|
|
||||||
- name: notify
|
- name: notify
|
||||||
|
@ -5,3 +5,8 @@
|
|||||||
language: script
|
language: script
|
||||||
entry: compose-check.sh
|
entry: compose-check.sh
|
||||||
files: (docker-)?compose\.ya?ml$
|
files: (docker-)?compose\.ya?ml$
|
||||||
|
- id: docker-compose-check-standalone
|
||||||
|
name: Validate docker compose files using standalone compose binary
|
||||||
|
language: python
|
||||||
|
entry: compose-check.sh
|
||||||
|
files: (docker-)?compose\.ya?ml$
|
||||||
|
6
Makefile
6
Makefile
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
all: check test
|
all: check test
|
||||||
|
|
||||||
test: test-negative test-positive test-hooks
|
test: test-negative test-positive
|
||||||
|
|
||||||
.PHONY: test-positive
|
.PHONY: test-positive
|
||||||
test-positive:
|
test-positive:
|
||||||
@ -16,10 +16,6 @@ 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:
|
||||||
|
@ -2,40 +2,28 @@
|
|||||||
# Verifies that files passed in are valid for docker-compose
|
# Verifies that files passed in are valid for docker-compose
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Check if docker or podman commands are available
|
if command -v docker &> /dev/null && docker help compose &> /dev/null; then
|
||||||
if [[ -z "${CONTAINER_ENGINE}" ]]; then
|
COMPOSE="docker compose"
|
||||||
if command -v docker &>/dev/null; then
|
elif command -v docker-compose &> /dev/null ; then
|
||||||
CONTAINER_ENGINE=docker
|
COMPOSE=docker-compose
|
||||||
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 '${CONTAINER_ENGINE}-compose' or '${CONTAINER_ENGINE} compose' were found"
|
echo "ERROR: Neither 'docker-compose' or 'docker 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
|
||||||
@ -44,7 +32,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
|
||||||
|
|
||||||
|
17
pyproject.toml
Normal file
17
pyproject.toml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["release-gitter[builder]"]
|
||||||
|
build-backend = "pseudo_builder"
|
||||||
|
|
||||||
|
[tool.release-gitter]
|
||||||
|
git-url = "https://github.com/docker/compose"
|
||||||
|
version = "v2.23.0"
|
||||||
|
|
||||||
|
format = "docker-compose-{system}-{arch}"
|
||||||
|
# exec = "mv {} docker-compose && chmod +x docker-compose"
|
||||||
|
[tool.release-gitter.map-system]
|
||||||
|
Darwin = "darwin"
|
||||||
|
Windows = "windows"
|
||||||
|
Linux = "linux"
|
||||||
|
[tool.release-gitter.map-arch]
|
||||||
|
arm64 = "aarch64"
|
||||||
|
amd64 = "x86_64"
|
Loading…
Reference in New Issue
Block a user