Skip to content

Commit

Permalink
Basic test and docker compose runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
crdoconnor committed Oct 22, 2021
1 parent 7f15254 commit 8815d16
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 2 deletions.
56 changes: 56 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: '3.4'

# Defaults

x-build-args-36: &build_args_36
IMAGE_TAG: "3.6-buster"

x-build-args-37: &build_args_37
IMAGE_TAG: "3.7-buster"

x-build-args-38: &build_args_38
IMAGE_TAG: "3.8-buster"

services:

# Devbox

dev: &dev
build: &dev_build
dockerfile: ./docker/Dockerfile
context: .
image: avro-to-markdown-dev
command: /bin/bash
volumes:
- ./:/app

# Test & Lint suite

test-36:
<<: *dev
build:
<<: *dev_build
args:
IMAGE: python:3.6-buster
image: avro-to-markdown-test-36
command: docker/run_tests.sh

test-37:
<<: *dev
build:
<<: *dev_build
args:
IMAGE: python:3.7-buster
image: avro-to-markdown-test-37
command: docker/run_tests.sh

# NOTE: test-38 command includes `--format-code` option that will
# apply changes when the lint suite is run
test-38:
<<: *dev
build:
<<: *dev_build
args:
IMAGE: python:3.8-buster
image: avro-to-markdown-test-38
command: docker/run_tests.sh --format-code
53 changes: 53 additions & 0 deletions docker/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

set -eo pipefail

BLACK_ACTION="--check"
ISORT_ACTION="--check-only"

function usage
{
echo "usage: run_tests.sh [--format-code]"
echo ""
echo " --format-code : Format the code instead of checking formatting."
exit 1
}

while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in
--format-code)
BLACK_ACTION="--quiet"
ISORT_ACTION=""
;;
-h|--help)
usage
;;
"")
# ignore
;;
*)
echo "Unexpected argument: ${arg}"
usage
;;
esac
shift
done

# only generate html locally
pytest tests/unit --cov-report html

echo "Running MyPy..."
mypy avro_to_markdown tests

echo "Running black..."
black ${BLACK_ACTION} avro_to_markdown tests

echo "Running iSort..."
isort ${ISORT_ACTION} avro_to_markdown tests

echo "Running flake8..."
flake8 avro_to_markdown tests

echo "Running bandit..."
bandit --ini .bandit --quiet -r avro_to_markdown
4 changes: 2 additions & 2 deletions tests/unit/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import avro_to_markdown


def test_avro_to_markdown():
pass
def test_avro_to_markdown_version():
assert avro_to_markdown.__version__ == "0.1.0"

0 comments on commit 8815d16

Please sign in to comment.