diff --git a/.circleci/config.yml b/.circleci/config.yml index c88e0f6bf..1fdb10467 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -316,6 +316,47 @@ jobs: - store_test_results: path: /tmp/logs + mock_aws_test: + <<: *env + docker: + - image: cimg/python:3.10.2 + steps: + - attach_workspace: + at: /home/circleci + #- run: + # <<: *install_gruntwork_utils + - run: + name: install mock aws server + command: | + pip install moto[server] + - run: + name: install aws cli + command: | + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + sudo ./aws/install + - run: + name: run mock aws server + command: | + moto_server | tee /tmp/logs/moto_server_output.log + background: true + - run: + name: wait for mock aws server + command: | + while ! AWS_REGION=us-west-2 AWS_ACCESS_KEY_ID=dummy AWS_SECRET_ACCESS_KEY=dummy aws --endpoint http://localhost:5000 sts get-caller-identity; do + echo "Waiting for local mock AWS server" + sleep 1 + done + - run: + command: | + mkdir -p /tmp/logs + run-go-tests --packages "-tags=mockaws ./test/" | tee /tmp/logs/test_output.log + + # Store test result and log artifacts for browsing purposes + - store_artifacts: + path: /tmp/logs + - store_test_results: + path: /tmp/logs deploy: <<: *defaults @@ -386,6 +427,15 @@ workflows: tags: only: /^v.*/ + - mock_aws_test: + context: + - Gruntwork Admin + requires: + - setup + filters: + tags: + only: /^v.*/ + - deploy: context: - AWS__PHXDEVOPS__circle-ci-test diff --git a/test/terraform_aws_endpoint_example_test.go b/test/terraform_aws_endpoint_example_test.go index e2ae89460..0f24048d5 100644 --- a/test/terraform_aws_endpoint_example_test.go +++ b/test/terraform_aws_endpoint_example_test.go @@ -1,3 +1,10 @@ +//go:build mockaws +// +build mockaws + +// NOTE: We use build tags to differentiate mockaws testing because this uses +// a local mock AWS service +// (https://docs.getmoto.org/en/latest/docs/server_mode.html) + package test import (