This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (144 loc) · 4.87 KB
/
test-command.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
# Attribution for a bunch of this goes to CloudPosse
# https://github.com/cloudposse/actions/blob/master/.github/workflows/test-command.yml
name: test
on:
repository_dispatch:
types: [test-command]
push:
branches:
- main
permissions:
id-token: write
contents: read
defaults:
run:
# We need -e -o pipefail for consistency with GitHub Actions' default behavior
shell: bash -e -o pipefail {0}
jobs:
# Parse the command so we can decide which tests to run. Examples: "/test all", "/test validate", "/test e2e"
# We can do as many of these as we want to get as granular as we want.
parse:
runs-on: ubuntu-latest
outputs:
run-ping: ${{ steps.parse.outputs.run-ping }}
run-e2e: ${{ steps.parse.outputs.run-e2e }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }}
- name: Parse Args
id: parse
uses: ./.github/actions/parse-test
# Update the comment that triggered the /test command to show the run url
comment:
if: github.event_name == 'repository_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }}
- name: Update Comment
uses: ./.github/actions/comment
with:
token: ${{ secrets.PAT }}
# Do a simple ping/pong status update to validate things are working
ping:
runs-on: ubuntu-latest
needs: parse
if: needs.parse.outputs.run-ping == 'true'
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.client_payload.pull_request.head.ref || github.ref_name }}
- name: Ping Test
uses: ./.github/actions/ping
with:
token: ${{ secrets.PAT }}
# Run the E2E tests
e2e:
runs-on: ubuntu-latest
needs: parse
if: needs.parse.outputs.run-e2e == 'true'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to registry1
uses: docker/login-action@v2
with:
registry: registry1.dso.mil
username: ${{ secrets.REGISTRY1_USERNAME }}
password: ${{ secrets.REGISTRY1_PASSWORD }}
- name: Install homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install uds-cli via homebrew
run: |
brew tap defenseunicorns/tap
brew install uds
- name: Build gitlab and all dependencies
run: |
uds run ci-build-all
- name: Add zarf to bin on path
run: |
sudo cp build/zarf /usr/local/bin/zarf
- name: Create k3s cluster in AWS
id: create-cluster
uses: defenseunicorns/uds-aws-ci-k3d@swf_additions
with:
cluster-action: create
aws-assume-role: ${{ secrets.AWS_COMMERCIAL_ROLE_TO_ASSUME }}
aws-region: us-west-2
instance-size: "m7a.8xlarge"
ami-prefix: "rc-uds-ci-k3d"
k3s: "true"
- name: Install Pepr nlb lb module
run: |
zarf tools kubectl apply -f test/lb-annotation-aws/pepr-module-lb-annotate.yaml
- name: Deploy gitlab and all dependencies
run: |
uds run ci-deploy-all
- name: Setup LB hostnames
run: |
utils/metallb/dns.sh
sudo utils/metallb/hosts-write.sh
- name: Run tests
run: |
uds run test-all -f test/tasks.yaml
- name: Print cluster info
if: failure()
run: |
kubectl get nodes -o wide
- name: Print pod info
if: failure()
run: |
kubectl get pods -A -o wide
- name: Print service info
if: failure()
run: |
kubectl get svc -A -o wide
- name: Print events
if: failure()
run: |
kubectl get events -A -o wide
- name: Teardown k3s cluster
if: always()
# renovate: datasource=github-tags depName=defenseunicorns/uds-aws-ci-k3d versioning=semver
uses: defenseunicorns/uds-aws-ci-k3d@swf_additions
with:
cluster-action: destroy