Skip to content

Commit d18e6dd

Browse files
author
Shaun Verch
committed
Add CI task to run tests
It needs to be a separate group because moto server needs to be installed and running
1 parent ae86f72 commit d18e6dd

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

.circleci/config.yml

+50
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,47 @@ jobs:
316316
- store_test_results:
317317
path: /tmp/logs
318318

319+
mock_aws_test:
320+
<<: *env
321+
docker:
322+
- image: cimg/python:3.10.2
323+
steps:
324+
- attach_workspace:
325+
at: /home/circleci
326+
#- run:
327+
# <<: *install_gruntwork_utils
328+
- run:
329+
name: install mock aws server
330+
command: |
331+
pip install moto[server]
332+
- run:
333+
name: install aws cli
334+
command: |
335+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
336+
unzip awscliv2.zip
337+
sudo ./aws/install
338+
- run:
339+
name: run mock aws server
340+
command: |
341+
moto_server | tee /tmp/logs/moto_server_output.log
342+
background: true
343+
- run:
344+
name: wait for mock aws server
345+
command: |
346+
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
347+
echo "Waiting for local mock AWS server"
348+
sleep 1
349+
done
350+
- run:
351+
command: |
352+
mkdir -p /tmp/logs
353+
run-go-tests --packages "-tags=mockaws ./test/" | tee /tmp/logs/test_output.log
354+
355+
# Store test result and log artifacts for browsing purposes
356+
- store_artifacts:
357+
path: /tmp/logs
358+
- store_test_results:
359+
path: /tmp/logs
319360

320361
deploy:
321362
<<: *defaults
@@ -379,6 +420,15 @@ workflows:
379420
tags:
380421
only: /^v.*/
381422

423+
- mock_aws_test:
424+
context:
425+
- Gruntwork Admin
426+
requires:
427+
- setup
428+
filters:
429+
tags:
430+
only: /^v.*/
431+
382432
- deploy:
383433
context:
384434
- Gruntwork Admin

test/terraform_aws_endpoint_example_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
//go:build mockaws
2+
// +build mockaws
3+
4+
// NOTE: We use build tags to differentiate mockaws testing because this uses
5+
// a local mock AWS service
6+
// (https://docs.getmoto.org/en/latest/docs/server_mode.html)
7+
18
package test
29

310
import (

0 commit comments

Comments
 (0)