Nightly TFE Tests #308
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 TFE Tests | |
on: | |
workflow_dispatch: | |
schedule: | |
# Monday-Friday at 7AM UTC (1 hour after infrastructure rebuild) | |
- cron: '0 7 * * 1-5' | |
jobs: | |
instance: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Build nightly tflocal instance | |
uses: hashicorp-forge/terraform-cloud-action/apply@4adbe7eea886138ac10a4c09e63c5c568aaa6672 # main | |
with: | |
token: ${{ secrets.TF_WORKFLOW_TFLOCAL_CLOUD_TFC_TOKEN }} | |
organization: "hashicorp-v2" | |
workspace: tflocal-terraform-provider-tfe-nightly | |
wait: true | |
tests: | |
needs: instance | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
total: [ 5 ] | |
index: [ 0, 1, 2, 3, 4 ] | |
steps: | |
- name: Fetch Outputs | |
id: tflocal | |
uses: hashicorp-forge/terraform-cloud-action/outputs@4adbe7eea886138ac10a4c09e63c5c568aaa6672 # main | |
with: | |
token: "${{ secrets.TF_WORKFLOW_TFLOCAL_CLOUD_TFC_TOKEN }}" | |
organization: hashicorp-v2 | |
workspace: tflocal-terraform-provider-tfe-nightly | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- uses: ./.github/actions/test-provider-tfe | |
with: | |
matrix_index: ${{ matrix.index }} | |
matrix_total: ${{ matrix.total }} | |
hostname: ${{ fromJSON(steps.tflocal.outputs.workspace-outputs-json).ngrok_domain }} | |
token: ${{ fromJSON(steps.tflocal.outputs.workspace-outputs-json).tfe_token }} | |
testing-github-token: ${{ secrets.TESTING_GITHUB_TOKEN }} | |
enterprise: "1" | |
tests-summarize: | |
needs: [tests] | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
steps: | |
- name: Check tests Status | |
run: | | |
if [ "${{ needs.tests.result }}" = "success" ]; then | |
exit 0 | |
fi | |
exit 1 | |
slack-notify: | |
needs: tests-summarize | |
if: always() && (needs.tests-summarize.result == 'failure') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send slack notification on failure | |
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 | |
with: | |
payload: | | |
{ | |
"text": ":x::moon::sob: Nightly TFE tests *FAILED*", | |
"attachments": [ | |
{ | |
"color": "#C41E3A", | |
"blocks": [ | |
{ | |
"type": "section", | |
"fields": [ | |
{ | |
"type": "mrkdwn", | |
"text": "*Workflow:*\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
cleanup: | |
runs-on: ubuntu-latest | |
needs: [tests-summarize] | |
if: "${{ always() }}" | |
steps: | |
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version-file: go.mod | |
check-latest: true | |
cache: true | |
- name: Destroy nightly tflocal instance | |
uses: hashicorp-forge/terraform-cloud-action/destroy@4adbe7eea886138ac10a4c09e63c5c568aaa6672 # main | |
with: | |
token: ${{ secrets.TF_WORKFLOW_TFLOCAL_CLOUD_TFC_TOKEN }} | |
organization: "hashicorp-v2" | |
workspace: tflocal-terraform-provider-tfe-nightly | |
wait: true | |
is-destroy: true |