forked from aws-samples/eks-workshop-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (121 loc) · 4.4 KB
/
module-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Execute module test
on:
workflow_call:
inputs:
module:
type: string
default: "-"
glob:
type: string
default: "-"
outputs:
durations-artifact:
description: "The artifact ID of the test durations file"
value: ${{ jobs.run-tests.outputs.durations-artifact }}
permissions:
id-token: write
contents: read
jobs:
run-tests:
if: github.repository == 'aws-samples/eks-workshop-v2'
name: run-tests
runs-on: ubuntu-latest
outputs:
durations-artifact: ${{ steps.upload-durations.outputs.artifact-id }}
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install utilities
run: |
sudo apt install -y gettext
mkdir -p ${HOME}/.local/bin
wget -q https://github.com/jckuester/awsweeper/releases/download/v0.12.0/awsweeper_0.12.0_linux_amd64.tar.gz
tar zxf awsweeper_0.12.0_linux_amd64.tar.gz
mv awsweeper_0.12.0_linux_amd64/awsweeper ${HOME}/.local/bin
chmod +x ${HOME}/.local/bin/*
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set cluster ID
env:
RUN_ID: "${{ github.job }}"
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
CLUSTER_ID=$(echo $RANDOM | md5sum | head -c 8)
echo "Using cluster ID ${CLUSTER_ID}"
echo "CLUSTER_ID=$CLUSTER_ID" >> $GITHUB_ENV
- name: Get AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-duration-seconds: 3600
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GithubActionsSession-${{ env.CLUSTER_ID }}
- name: Create infrastructure
id: create-infrastructure
env:
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
make create-infrastructure environment="$CLUSTER_ID"
- name: Refresh AWS credentials
if: always()
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-duration-seconds: 3600
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GithubActionsSession-${{ env.CLUSTER_ID }}
- name: Run tests - Module
env:
DOCKER_BUILDKIT: 1
DEV_MODE: 1
GENERATE_TIMINGS: 1
TEST_REPORT: /tmp/test-output.json
MODULE: ${{ inputs.module }}
GLOB: ${{ inputs.glob }}
AWS_REGION: "${{ secrets.AWS_REGION }}"
ASSUME_ROLE: "${{ secrets.AWS_ROLE_ARN }}"
DOCKER_DNS_OVERRIDE: "8.8.8.8"
run: |
export AWS_DEFAULT_REGION="$AWS_REGION"
make test environment="$CLUSTER_ID" module="$MODULE" glob="$GLOB"
- uses: actions/upload-artifact@v4
id: upload-durations
with:
name: test-durations-${{ env.CLUSTER_ID }}
path: website/test-durations.json
- name: Refresh AWS credentials
if: always()
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-duration-seconds: 3600
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GithubActionsSession-${{ env.CLUSTER_ID }}
- name: Run tests - Cleanup
if: always()
env:
DOCKER_BUILDKIT: 1
DEV_MODE: 1
AWS_REGION: "${{ secrets.AWS_REGION }}"
ASSUME_ROLE: "${{ secrets.AWS_ROLE_ARN }}"
run: |
export AWS_DEFAULT_REGION="$AWS_REGION"
make test environment="$CLUSTER_ID" module="cleanup"
- name: Refresh AWS credentials
if: always()
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-duration-seconds: 3600
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: GithubActionsSession-${{ env.CLUSTER_ID }}
- name: Cleanup environment
if: always()
env:
AWS_REGION: "${{ secrets.AWS_REGION }}"
run: |
export CLEANUP_ENVIRONMENT_NAME="eks-workshop-$CLUSTER_ID"
export AWS_DEFAULT_REGION="$AWS_REGION"
envsubst < hack/lib/filter.yml > filter.yml
cat filter.yml
awsweeper --force filter.yml
make destroy-infrastructure environment="$CLUSTER_ID"