diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 17973373..4be7119b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.1 +current_version = 0.2.2 commit = True message = Bumps version to {new_version} tag = False diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2b381df0..832df08e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,6 +15,11 @@ updates: schedule: interval: weekly open-pull-requests-limit: 10 +- package-ecosystem: pip + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 - package-ecosystem: docker directory: "/" schedule: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 971b1c29..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,15 +0,0 @@ - -name: Update terraform dependencies - -on: - schedule: - - cron: '0 6 * * *' - -jobs: - dependabot-terraform: - runs-on: ubuntu-latest - steps: - - name: update terraform dependencies - uses: plus3it/dependabot-terraform-action@p3-implementation - with: - github_dependency_token: ${{ secrets.GH_READONLY_TOKEN }} diff --git a/.travis.yml b/.travis.yml index 43280b24..d2781e78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ -dist: bionic +dist: focal + +language: minimal stages: - lint @@ -7,32 +9,29 @@ stages: if: branch = master OR type = pull_request -stage: test - -name: Project Tests - -language: python - -python: - - "3.8" - - "3.9" - -install: skip - -script: - - | - set -e - make docker/run target=python/test - make localstack/up - make localstack/pytest - make localstack/clean +before_install: + - tmpdaemon=$(mktemp) + - sudo jq '."registry-mirrors" += ["https://mirror.gcr.io"]' /etc/docker/daemon.json > "$tmpdaemon" + - sudo mv "$tmpdaemon" /etc/docker/daemon.json + - sudo systemctl daemon-reload + - sudo systemctl restart docker + - docker system info jobs: include: - stage: lint name: Project Syntax Verification - script: - - make docker/run target=lint + script: make docker/run target=lint + - stage: test + name: Run unit tests + script: make docker/run target=pytest/lambda/tests + - stage: test + name: Run integration tests against a mock AWS stack + install: + - make docker-compose/install + - make mockstack/up + script: make mockstack/pytest/lambda + after_script: make mockstack/clean - stage: deploy if: branch = master AND type = push AND repo = plus3it/terraform-aws-org-new-account-trust-policy before_script: diff --git a/CHANGELOG.md b/CHANGELOG.md index 20a37347..33f1576a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +### 0.2.2 + +**Commit Delta**: [Change from 0.2.1 release](https://github.com/plus3it/terraform-aws-org-new-account-trust-policy/compare/0.2.1...0.2.2) + +**Released**: 2021.07.22 + +**Summary**: + +* Moved common requirements to `requirements_common.txt`. Dependabot + does not want to see duplicate requirements. + +* Updated the `Makefile` to take advantage of new targets in tardigrade-ci. + +* Updated the Travis workflow to reflect changes in tardigrade-ci + ### 0.2.1 **Commit Delta**: [Change from 0.2.0 release](https://github.com/plus3it/terraform-aws-org-new-account-trust-policy/compare/0.2.0...0.2.1) diff --git a/Dockerfile b/Dockerfile index 0d14bc41..09087351 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ -FROM plus3it/tardigrade-ci:0.14.1 +FROM plus3it/tardigrade-ci:0.16.1 -COPY ./lambda/src/requirements.txt /src/requirements.txt -COPY ./lambda/tests/requirements_dev.txt /tests/requirements_dev.txt +COPY ./lambda/src/requirements.txt /lambda/src/requirements.txt +COPY ./lambda/tests/requirements_dev.txt /lambda/tests/requirements_dev.txt COPY ./tests/requirements_test.txt /tests/requirements_test.txt +COPY ./requirements_common.txt /requirements_common.txt RUN python -m pip install --no-cache-dir \ - -r /src/requirements.txt \ - -r /tests/requirements_dev.txt \ + -r /lambda/src/requirements.txt \ + -r /lambda/tests/requirements_dev.txt \ -r /tests/requirements_test.txt diff --git a/Dockerfile_test b/Dockerfile_test index 1548a43b..a335f254 100644 --- a/Dockerfile_test +++ b/Dockerfile_test @@ -1,5 +1,6 @@ -FROM plus3it/tardigrade-ci:0.14.1 +FROM plus3it/tardigrade-ci:0.16.1 COPY ./tests/requirements_test.txt /tests/requirements_test.txt +COPY ./requirements_common.txt /requirements_common.txt RUN python -m pip install --no-cache-dir -r /tests/requirements_test.txt diff --git a/Makefile b/Makefile index b523e8b6..b8cddb6c 100644 --- a/Makefile +++ b/Makefile @@ -1,55 +1,26 @@ SHELL := /bin/bash export PYTHONPATH := $(PYTHONPATH):./lambda/src +export TERRAFORM_PYTEST_DIR := tests include $(shell test -f .tardigrade-ci || curl -sSL -o .tardigrade-ci "https://raw.githubusercontent.com/plus3it/tardigrade-ci/master/bootstrap/Makefile.bootstrap"; echo .tardigrade-ci) -pytest/install: - @ $(MAKE) install/pip/$(@D) PYPI_PKG_NAME=$(@D) +.PHONY: pytest/deps +pytest/deps: + @ echo "[@] Installing dependencies used for unit and integration tests" @ python -m pip install \ -r lambda/tests/requirements_dev.txt \ -r tests/requirements_test.txt .PHONY: python/deps python/deps: - @ echo "[$@] Installing package dependencies" + @ echo "[$@] Installing lambda dependencies" @ python -m pip install -r lambda/src/requirements.txt -.PHONY: python/test -python/test: | guard/program/pytest -python/test: - @ echo "[$@] Starting Python tests" - pytest lambda/tests - @ echo "[$@]: Tests executed!" - -.PHONY: terraform/pytest -terraform/pytest: | guard/program/terraform guard/program/pytest - @ echo "[$@] Starting test of Terraform lambda installation" - @ echo "[$@] LocalStack must be running; 'make localstack/up' can " - @ echo "[$@] be used to start LocalStack" - @ echo "[$@] Terraform 'apply' command is slow ... be patient !!!" - pytest tests - @ echo "[$@]: Completed successfully!" - -.PHONY: localstack/pytest localstack/up localstack/down localstack/clean -localstack/pytest: | guard/program/terraform guard/program/pytest +.PHONY: mockstack/pytest/lambda +mockstack/pytest/lambda: | guard/program/terraform guard/program/pytest @ echo "[$@] Running Terraform tests against LocalStack" DOCKER_RUN_FLAGS="--network tests_default --rm -e LOCALSTACK_HOST=localstack" \ TARDIGRADE_CI_DOCKERFILE=Dockerfile_test \ IMAGE_NAME=new-account-trust-policy-integration-test:latest \ $(MAKE) docker/run target=terraform/pytest @ echo "[$@]: Completed successfully!" - -localstack/up: | guard/program/terraform guard/program/pytest - @ echo "[$@] Starting LocalStack container" - docker-compose -f tests/docker-compose-localstack.yml up --detach - -localstack/down: | guard/program/terraform guard/program/pytest - @ echo "[$@] Stopping LocalStack container" - docker-compose -f tests/docker-compose-localstack.yml down - -localstack/clean: | localstack/down - @ echo "[$@] Stopping and removing LocalStack container and images" - set +o pipefail; docker images | grep lambci | \ - awk '{print $$1 ":" $$2}' | xargs -r docker rmi - set +o pipefail; docker images | grep new-account-trust-policy | \ - awk '{print $$1 ":" $$2}' | xargs -r docker rmi diff --git a/README.md b/README.md index 2c87845c..65203cb3 100644 --- a/README.md +++ b/README.md @@ -30,17 +30,24 @@ aws cloudformation deploy --profile mock-dev --template package.yaml --capabilit ## Testing -To set up and run tests against the Terraform configuration: +To set up and run tests: ``` -# Start up LocalStack, a mock AWS stack: -make localstack/up +# Ensure the dependencies are installed on your system. +make python/deps +make pytest/deps + +# Start up a mock AWS stack: +make mockstack/up + +# Run unit tests: +make docker/run target=pytest/lambda/tests # Run the tests: -make terraform/pytest +make mockstack/pytest/lambda -# Shut down LocalStack and clean up docker images: -make localstack/clean +# Shut down the mock AWS stack and clean up docker images: +make mockstack/clean ``` diff --git a/lambda/src/requirements.txt b/lambda/src/requirements.txt index 5618ea41..f5f2c275 100644 --- a/lambda/src/requirements.txt +++ b/lambda/src/requirements.txt @@ -1,3 +1,3 @@ aws-lambda-powertools==1.17.1 -boto3==1.17.109 +boto3==1.18.2 aws-assume-role-lib==1.7.0 diff --git a/lambda/tests/requirements_dev.txt b/lambda/tests/requirements_dev.txt index 2e85dbb2..066a671a 100644 --- a/lambda/tests/requirements_dev.txt +++ b/lambda/tests/requirements_dev.txt @@ -1,2 +1,2 @@ -moto==2.0.11 -pytest==6.2.3 +moto==2.1.0 +-r ../../requirements_common.txt diff --git a/requirements_common.txt b/requirements_common.txt new file mode 100644 index 00000000..95ea1e6a --- /dev/null +++ b/requirements_common.txt @@ -0,0 +1 @@ +pytest==6.2.4 diff --git a/tests/requirements_test.txt b/tests/requirements_test.txt index 2201fad7..5fe425f3 100644 --- a/tests/requirements_test.txt +++ b/tests/requirements_test.txt @@ -1,3 +1,3 @@ tftest==1.6.0 -pytest==6.2.3 localstack-client==1.21 +-r ../requirements_common.txt