-
Notifications
You must be signed in to change notification settings - Fork 3
185 lines (183 loc) · 7.79 KB
/
integration-test.yml
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
on:
push:
branches:
- main
pull_request: {}
schedule:
- cron: '0 11 * * *'
workflow_dispatch:
name: integration-test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
filter:
runs-on: [ARM64, self-hosted, Linux]
outputs:
should_run_integration_tests: ${{ steps.check_branch.outputs.result }}
steps:
- name: Check if integration-test file changed
# the output of this step is only used if the run was triggered by a pull_request
if: ${{ github.event_name == 'pull_request' }}
uses: dorny/paths-filter@v2
id: integration_test_changes
with:
filters: |
dependencies:
- '.github/workflows/integration-test.yml'
- name: Check for if the head branch is the release-please branch
id: check_branch
uses: actions/github-script@v6
with:
script: |
if ('${{ github.event_name }}' === 'pull_request') {
return ${{ steps.integration_test_changes.outputs.dependencies == 'true' }} || '${{ github.head_ref }}' === 'release-please--branches--main'
}
// run for all non-pull_request triggers (ie, pushes to main, workflow_dispatch)
return true
integration-test:
needs: filter
if: ${{ needs.filter.outputs.should_run_integration_tests == 'true' }}
runs-on: [ARM64, self-hosted, Linux]
timeout-minutes: 20
permissions:
id-token: write
contents: read
env:
TFE_TOKEN: ${{ secrets.TFE_TOKEN_PLAYGROUND }}
steps:
- run: |
mkdir -p ~/.ssh/
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
- name: Install SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.SHARED_INFRA_DEPLOY_KEY }}
- name: Assume happy-api deployement role
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_INTEGRATION_PLAYGROUND }}
role-duration-seconds: 1200
role-session-name: HappyCLIIntegrationTest
- uses: azure/setup-kubectl@v3
- name: Install AWS CLI
id: install-aws-cli
uses: unfor19/install-aws-cli-action@master
with:
arch: arm64
version: 2
- name: Debug
run: |
aws eks list-clusters --region us-west-2
aws eks update-kubeconfig --name si-playground-eks-v2 --region us-west-2
kubectl get nodes
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.0
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: cli/go.mod
cache: true
- name: Get go cache paths
id: cache-paths
run: |
echo "gocache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "gomodcache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
${{steps.cache-paths.outputs.gocache}}
${{steps.cache-paths.outputs.gomodcache}}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build CLI
run: |
go mod tidy
go build -o happy
working-directory: ./cli
- name: Get Stack Name
id: get-stack-name
run: |
SHORT_SHA=$(git rev-parse --short ${{ github.sha }})
echo "stack_name=integration-test-$SHORT_SHA" >> $GITHUB_OUTPUT
- name: List stacks
run: ../../cli/happy --detached --aws-profile="" list -v
working-directory: ./examples/integration_test
- name: Delete a stack
run: ../../cli/happy --detached --aws-profile="" delete ${{steps.get-stack-name.outputs.stack_name}} -v || true
working-directory: ./examples/integration_test
- name: List stacks
run: |
MATCHING_STACK_COUNT=$(../../cli/happy --detached --aws-profile="" list --output json | jq '[.[] | select(.stack=="${{steps.get-stack-name.outputs.stack_name}}")] | length')
if [ "$MATCHING_STACK_COUNT" != "0" ]; then
echo "Expected 0 stacks, got $MATCHING_STACK_COUNT"
exit 1
else
echo "Stack was deleted, as expected"
fi
working-directory: ./examples/integration_test
- name: Build an image
run: ../../cli/happy --detached --aws-profile="" build
working-directory: ./examples/integration_test
- name: Validate TF code
run: ../../cli/happy --detached --aws-profile="" infra validate --force
working-directory: ./examples/integration_test
- name: Ingest TF code
run: ../../cli/happy --detached --aws-profile="" infra ingest --force
working-directory: ./examples/integration_test
- name: Generate TF code
run: ../../cli/happy --detached --aws-profile="" infra generate --force
working-directory: ./examples/integration_test
- name: Ingest TF code
run: ../../cli/happy --detached --aws-profile="" infra refresh --pin main --force
working-directory: ./examples/integration_test
- name: Create a stack
run: ../../cli/happy --detached --aws-profile="" create ${{steps.get-stack-name.outputs.stack_name}} -v --tag integrationtest --force
working-directory: ./examples/integration_test
- name: List stacks
run: |
MATCHING_STACK_COUNT=$(../../cli/happy --detached --aws-profile="" list --output json | jq '[.[] | select(.stack=="${{steps.get-stack-name.outputs.stack_name}}")] | length')
if [ "$MATCHING_STACK_COUNT" != "1" ]; then
echo "Expected 1 stack, got $MATCHING_STACK_COUNT"
exit 1
else
echo "Found 1 stack, as expected"
fi
working-directory: ./examples/integration_test
- name: Push an image
run: ../../cli/happy --detached --aws-profile="" push ${{steps.get-stack-name.outputs.stack_name}} --tag integrationtest
working-directory: ./examples/integration_test
- name: Get events
run: ../../cli/happy --detached --aws-profile="" events ${{steps.get-stack-name.outputs.stack_name}} -v
working-directory: ./examples/integration_test
- name: Update a stack
run: ../../cli/happy --detached --aws-profile="" update ${{steps.get-stack-name.outputs.stack_name}} -v --tag integrationtest
working-directory: ./examples/integration_test
- name: Get stack logs
run: ../../cli/happy --detached --aws-profile="" logs ${{steps.get-stack-name.outputs.stack_name}} frontend -v
working-directory: ./examples/integration_test
- name: Get stack resources
run: ../../cli/happy --detached --aws-profile="" resources ${{steps.get-stack-name.outputs.stack_name}} -v
working-directory: ./examples/integration_test
- name: Get stack
run: ../../cli/happy --detached --aws-profile="" get ${{steps.get-stack-name.outputs.stack_name}} -v
working-directory: ./examples/integration_test
- name: Delete a stack
run: ../../cli/happy --detached --aws-profile="" delete ${{steps.get-stack-name.outputs.stack_name}} -v --force || true
working-directory: ./examples/integration_test
- name: List stacks
run: |
MATCHING_STACK_COUNT=$(../../cli/happy --detached --aws-profile="" list --output json | jq '[.[] | select(.stack=="${{steps.get-stack-name.outputs.stack_name}}")] | length')
if [ "$MATCHING_STACK_COUNT" != "0" ]; then
echo "Expected 0 stacks, got $MATCHING_STACK_COUNT"
exit 1
else
echo "Stack was deleted, as expected"
fi
working-directory: ./examples/integration_test