-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (121 loc) · 4.44 KB
/
ci.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
#(C) Copyright 2022-2024 Hewlett Packard Enterprise Development LP
name: ci
on:
pull_request:
push:
branches:
- 'master'
jobs:
ci:
needs: ecr_login
runs-on: ubuntu-20.04
env:
BIN_PATH: /tmp/bin
METAL_PROJECT: TestTeam1
METAL_PROJECT_ROLE: project_owner
METAL_HOSTER: TestHoster1
METAL_HOSTER_ROLE: hoster_owner
MACHINES_CHECK_INTERVAL: 30s
MACHINES_CHECK_ATTEMPTS: 20
services:
simulator:
image: 463106798219.dkr.ecr.us-east-1.amazonaws.com/hpe-hcss/quake/simulator:master-simulator
credentials:
username: AWS
password: ${{ needs.ecr_login.outputs.ecr_password }}
ports:
- 80:80
- 3002:3002
env:
AUTH0_ID: ${{ secrets.SIM_AUTH0 }}
PASSWD: ${{ secrets.SIM_PASSWD }}
EMAIL: ${{ secrets.SIM_USER }}
PORTAL_URL: localhost
SKIP_USER_MON: true
options: >-
--health-timeout=30s
--health-start-period=60s
--health-cmd="curl -k http://localhost:3002/info/time"
--name SimPortal
steps:
- name: Checkout workspace
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.7
- name: Install tools
run: make tools
- name: Verify document generation
run: make docs
- name: Build and Install TF plugin
run: make install
- name: Terraform-Lint
uses: actionshub/[email protected]
- name: Run GO linter checks
run: |
TARGET_BRANCH=${{ github.base_ref }}
if [[ ${TARGET_BRANCH} == "" ]]; then
TARGET_BRANCH='master'
fi
TARGET_SHA=`git merge-base -a HEAD origin/${TARGET_BRANCH}`
echo "Running lint on changes from branch ${TARGET_BRANCH} ${TARGET_SHA}"
golangci-lint run --config golangci-lint-config.yaml --new-from-rev ${TARGET_SHA} --verbose --max-issues-per-linter 0 --max-same-issues 0
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.1.7
terraform_wrapper: false
- name: Fetch qctl from Simulator instance
run: |
mkdir -p ${BIN_PATH}
docker cp SimPortal:/var/local/quattro/downloads/qctl/linux/qctl ${BIN_PATH}
chmod +x ${BIN_PATH}/qctl
${BIN_PATH}/qctl -v
- name: Wait for machines to become available
run: |
PASSWD=${{ secrets.SIM_PASSWD }}
EMAIL=${{ secrets.SIM_USER }}
${BIN_PATH}/qctl login --portal http://localhost:3002 -u ${EMAIL} -p ${PASSWD} -m ${METAL_HOSTER} -r ${METAL_HOSTER_ROLE}
total_attempts=$MACHINES_CHECK_ATTEMPTS
remaining=$total_attempts
count=0
while [ $remaining -gt 0 ]; do
# count of available machines
count=`${BIN_PATH}/qctl machines list --format json | jq '.[] | select(.state == "Available")' \
| jq '.state' | wc -l`
# few machines available?
if [[ $count -ge 5 ]]; then
break
fi
remaining=$(($remaining-1))
echo "Remaining attempts: $remaining"
sleep $MACHINES_CHECK_INTERVAL
done
if [[ $remaining -eq 0 ]]; then
echo "machines didn't become available within the wait duration"
exit 1
fi
- name: Run tests
run: |
PASSWD=${{ secrets.SIM_PASSWD }}
EMAIL=${{ secrets.SIM_USER }}
# generate .qjwt file required by the Metal provider
${BIN_PATH}/qctl login --portal http://localhost:3002 -u ${EMAIL} -p ${PASSWD} -m ${METAL_PROJECT} -r ${METAL_PROJECT_ROLE}
export HPEGL_METAL_GL_TOKEN=false
make acceptance
ecr_login:
runs-on: ubuntu-latest
outputs:
ecr_password: ${{ steps.retrieve_password.outputs.ecr_password }}
steps:
- name: Set up AWS CLI
uses: chrislennon/[email protected]
- id: retrieve_password
name: Retrieve ECR password and store as secret
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
run: echo "::set-output name=ecr_password::$(aws ecr get-login-password)"