Skip to content

Commit

Permalink
Add CI task to run tests
Browse files Browse the repository at this point in the history
It needs to be a separate group because moto server needs to be installed and
running
  • Loading branch information
Shaun Verch committed Apr 23, 2023
1 parent ae86f72 commit d18e6dd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .circleci/config.yml
Expand Up @@ -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
Expand Down Expand Up @@ -379,6 +420,15 @@ workflows:
tags:
only: /^v.*/

- mock_aws_test:
context:
- Gruntwork Admin
requires:
- setup
filters:
tags:
only: /^v.*/

- deploy:
context:
- Gruntwork Admin
Expand Down
7 changes: 7 additions & 0 deletions 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 (
Expand Down

0 comments on commit d18e6dd

Please sign in to comment.