Compare commits

..

10 Commits

Author SHA1 Message Date
IamTheFij 27792a2e4d Add openssl dependency
continuous-integration/drone/push Build is passing Details
2020-01-28 15:12:23 -05:00
IamTheFij 7c0c912374 Add more dependencies for tests
continuous-integration/drone/push Build is failing Details
2020-01-28 14:59:47 -05:00
IamTheFij 3f215fb2f4 Add gcc to test env
continuous-integration/drone/push Build is failing Details
2020-01-28 14:04:36 -05:00
IamTheFij f1d00cd499 Add docker-compose to test env
continuous-integration/drone/push Build is failing Details
2020-01-28 14:03:31 -05:00
IamTheFij fa2c56fced Try to add bash to tests
continuous-integration/drone/push Build is failing Details
2020-01-28 14:02:51 -05:00
IamTheFij 3522297171 Debug test working dir
continuous-integration/drone/push Build is failing Details
2020-01-28 14:01:52 -05:00
IamTheFij 204c916c7e Add workspace for drone tests
continuous-integration/drone/push Build is failing Details
2020-01-28 13:59:48 -05:00
IamTheFij 51fcfd76c4 Add make
continuous-integration/drone/push Build is failing Details
2020-01-28 13:57:54 -05:00
IamTheFij 8fa016eeb7 Fix apk add
continuous-integration/drone/push Build is failing Details
2020-01-28 13:56:28 -05:00
IamTheFij 7b55d67b34 Add some tests and drone to run them
continuous-integration/drone/push Build is failing Details
2020-01-27 17:17:55 -05:00
7 changed files with 24 additions and 63 deletions

View File

@ -9,8 +9,10 @@ workspace:
steps:
- name: test
image: iamthefij/drone-pre-commit@sha256:6ed8dae6b0067bd2e145e36421bcfbbc68975ff7ddaa5a3f285b5bcdaf0989c8
image: python:3-alpine
commands:
- apk add bash shellcheck make gcc musl-dev libffi-dev openssl-dev
- pip install docker-compose
- make all
- name: notify

View File

@ -1,14 +0,0 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args:
- --allow-multiple-documents
- id: check-merge-conflict
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.7.1.1
hooks:
- id: shellcheck

View File

@ -1,7 +1,6 @@
---
- id: docker-compose-check
name: Validate docker compose files
description: Checks that docker compose files are valid
language: script
name: Validate docker-compose files
description: Checks that vault files are encrypted
entry: compose-check.sh
files: (docker-)?compose\.ya?ml$
files: docker-compose.y[a]{0,1}ml$
language: script

View File

@ -1,8 +1,12 @@
.PHONY: all test clean
all: check test
all: test shellcheck
test: test-negative test-positive test-hooks
test: test-negative test-positive
.PHONY: shellcheck
shellcheck:
shellcheck *.sh
.PHONY: test-positive
test-positive:
@ -15,17 +19,3 @@ test-negative:
./compose-check.sh tests/docker-compose.bad.yml && { echo 'fail'; exit 1; } || echo 'ok'
@echo "Check multiple files. Should error."
./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
.PHONY: install-hooks
install-hooks:
pre-commit install --install-hooks
# Checks files for encryption
.PHONY: check
check:
pre-commit run --all-files

View File

@ -2,21 +2,7 @@
A set of [pre-commit](http://pre-commit.com) hooks for Docker services
# Installation
Add the following to your `.pre-commit-config.yaml` file
```yaml
- repo: https://github.com/iamthefij/docker-pre-commit
rev: master
hooks:
- id: docker-compose-check
```
and then run `pre-commit autoupdate`.
## Hooks
### 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.

View File

@ -1,19 +1,10 @@
#! /usr/bin/env bash
#! /bin/bash
# Verifies that files passed in are valid for docker-compose
set -e
if command -v docker &> /dev/null && docker help compose &> /dev/null; then
COMPOSE="docker compose"
elif command -v docker-compose &> /dev/null ; then
COMPOSE=docker-compose
else
echo "ERROR: Neither 'docker-compose' or 'docker compose' were found"
exit 1
fi
check_file() {
local file=$1
env $COMPOSE --file "$file" config --quiet 2>&1 \
docker-compose -f "$file" config -q 2>&1 \
| sed "/variable is not set. Defaulting/d"
return "${PIPESTATUS[0]}"
}
@ -33,7 +24,7 @@ check_files() {
}
if ! check_files "$@" ; then
echo "Some compose files failed"
echo "To ignore, use --no-verify"
fi
exit $has_error

7
hooks.yaml Normal file
View File

@ -0,0 +1,7 @@
---
- id: docker-compose-check
name: Validate docker-compose files
description: Checks that docker-compose files are valid
entry: compose-check.sh
files: docker-compose.y[a]{0,1}ml$
language: script