Skip to content

Commit

Permalink
Merge pull request #104 from tremble/test_policies
Browse files Browse the repository at this point in the history
Add tests against 'hacking' policies and add a size test
  • Loading branch information
jillr authored Nov 23, 2020
2 parents 6406276 + 7883413 commit 725821a
Show file tree
Hide file tree
Showing 15 changed files with 192 additions and 389 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ default:
.PHONY: test-all
test-all: test
make test -C aws
make test -C hacking

.PHONY: test-all-requirements
test-all-requirements: test-requirements
make test-requirements -C aws FLAGS="$(FLAGS)"
make test-requirements -C hacking

.PHONY: test
test: yamllint
Expand Down
3 changes: 2 additions & 1 deletion aws/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import argparse
import logging
import os
import sys
import yaml

import boto3
Expand Down Expand Up @@ -54,7 +55,7 @@ def default_ctor(_dummy, tag_suffix, node):
account_id = boto3.client('sts').get_caller_identity().get('Account')

if account_id != config['lambda_account_id']:
exit(f'The terminator must be run from the lambda account: {config["lambda_account_id"]}')
sys.exit(f'The terminator must be run from the lambda account: {config["lambda_account_id"]}')

cleanup(args.stage, check=args.check, force=args.force, api_name=api_name, test_account_id=test_account_id, targets=args.target)

Expand Down
40 changes: 40 additions & 0 deletions hacking/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
PYTHON3 ?= python3.7

EXTRA_VARS=ansible_connection=local ansible_python_interpreter=$(shell which python)
RUN_TEST_POLICY_PLAYBOOK=ansible-playbook -i localhost, -e '$(EXTRA_VARS)' deploy-test-policy.yml $(FLAGS)
RUN_TERMINATOR_PLAYBOOK=ansible-playbook -i localhost, -e '$(EXTRA_VARS)' terminator.yml $(FLAGS)

VAULT_ARGS := $(if $(ANSIBLE_VAULT_PASSWORD_FILE),,--ask-vault-pass)

.PHONY: default
default:
@echo ">>> Running Tests"
@echo
@echo "USAGE: make test|test-requirements|yamllint|pycodestyle|pylint [PYTHON3=$(PYTHON3)]"

.PHONY: test_policy
test_policy:
$(RUN_TEST_POLICY_PLAYBOOK)

.PHONY: test
test: yamllint policy

.PHONY: test-requirements
test-requirements:
"$(PYTHON3)" -m pip install -c ../constraints.txt -r requirements.txt -r test-requirements.txt --disable-pip-version-check

.PHONY: yamllint
yamllint:
"$(PYTHON3)" -m yamllint --config-file ../.yamllint .

.PHONY: policy
policy:
ansible-playbook -i localhost aws_config/test-policies.yml

.PHONY: pycodestyle
pycodestyle:
find . -name '*.py' | xargs "$(PYTHON3)" -m pycodestyle --config ../pycodestyle.ini

.PHONY: pylint
pylint:
find . -name '*.py' | xargs "$(PYTHON3)" -m pylint --rcfile pylint.rc
Loading

0 comments on commit 725821a

Please sign in to comment.