Nightly Acceptance tests #403
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |