forked from hashicorp/terraform-provider-vsphere
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (104 loc) · 4.41 KB
/
acceptance-tests.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
name: Nightly Acceptance tests
on:
schedule:
- cron: '0 0 * * *' # Runs at 12:00 AM UTC
jobs:
acceptance_tests:
runs-on: ubuntu-latest
environment: acctests
env:
TF_VAR_VSPHERE_ESXI1: ${{ secrets.TF_VAR_VSPHERE_ESXI1 }}
TF_VAR_VSPHERE_ESXI1_PW: ${{ secrets.TF_VAR_VSPHERE_ESXI1_PW }}
TF_VAR_VSPHERE_LICENSE: ${{ secrets.TF_VAR_VSPHERE_LICENSE }}
TF_VAR_VSPHERE_PRIVATE_NETWORK: ${{ secrets.TF_VAR_VSPHERE_PRIVATE_NETWORK }}
TF_VAR_VSPHERE_PUBLIC_NETWORK: ${{ secrets.TF_VAR_VSPHERE_PUBLIC_NETWORK }}
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_PASSWORD }}
VSPHERE_SERVER: ${{ secrets.VSPHERE_SERVER }}
VSPHERE_USER: ${{ secrets.VSPHERE_USER }}
TF_VAR_VSPHERE_CLUSTER: ${{ vars.TF_VAR_VSPHERE_CLUSTER }}
TF_VAR_VSPHERE_DATACENTER: ${{ vars.TF_VAR_VSPHERE_DATACENTER }}
TF_VAR_VSPHERE_ESXI1_BOOT_DISK1: ${{ vars.TF_VAR_VSPHERE_ESXI1_BOOT_DISK1 }}
TF_VAR_VSPHERE_ESXI1_BOOT_DISK1_SIZE: ${{ vars.TF_VAR_VSPHERE_ESXI1_BOOT_DISK1_SIZE }}
TF_VAR_VSPHERE_ESXI_TRUNK_NIC: ${{ vars.TF_VAR_VSPHERE_ESXI_TRUNK_NIC }}
TF_VAR_VSPHERE_PG_NAME: ${{ vars.TF_VAR_VSPHERE_PG_NAME }}
VSPHERE_ALLOW_UNVERIFIED_SSL: ${{ vars.VSPHERE_ALLOW_UNVERIFIED_SSL }}
VSPHERE_PERSIST_SESSION: true
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: 'main'
- name: Write the SSH key and create session folders
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ./ssh_private_key
chmod 600 ./ssh_private_key
echo "TF_VAR_PRIV_KEY=$(pwd)/ssh_private_key" >> $GITHUB_ENV
mkdir -p sessions
echo "VSPHERE_VIM_SESSION_PATH=$(pwd)/sessions" >> $GITHUB_ENV
mkdir -p rest_sessions
echo "VSPHERE_REST_SESSION_PATH=$(pwd)/rest_sessions" >> $GITHUB_ENV
- name: Set up Terraform
uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_wrapper: false
- name: Create testrun resources
run: |
cd acctests/vsphere/testrun
terraform init
terraform apply -auto-approve
while read -r line; do
if [[ $line == export* ]]; then
echo "${line#export }" >> $GITHUB_ENV
fi
done < devrc
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: '.go-version'
- name: Set up Node
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
with:
node-version: 20
# Due to third party action restrictions, install and use the tool directly
- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- name: Go mod verify
run: go mod verify
- name: Run acceptance tests
continue-on-error: true
run: |
set -euo pipefail
TF_ACC=1 go test -json -v ./... -timeout 360m 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Get today's date
run: echo "TODAY_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Upload test log
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: test-log-${{ env.TODAY_DATE }}
path: /tmp/gotest.log
- name: Panic check
run: |
if grep -q "panic:" /tmp/gotest.log; then
echo "Panic found in log file."
exit 1
else
echo "No panic found in log file."
fi
- name: Summary
run: node ./scripts/summarize-testlog.js /tmp/gotest.log
- name: Get yesterday's date
run: echo "YESTERDAY_DATE=$(date -d 'yesterday' +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Download previous day's log file
uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d # v3.0.0
with:
name: test-log-${{ env.YESTERDAY_DATE }}
workflow_conclusion: "" # ignore status
search_artifacts: true
path: /tmp/yesterday
- name: Regression check
run: node ./scripts/compare-testlogs.js /tmp/gotest.log /tmp/yesterday/gotest.log
- name: Cleanup testrun resources
if: always()
run: |
cd acctests/vsphere/testrun
terraform destroy -auto-approve