-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding GHA workflow for UAT Test Suite
- Loading branch information
1 parent
287758f
commit 12683ca
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: terratests-uat-suite | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
setup-tests: | ||
name: Setup UAT Tests | ||
runs-on: ubuntu-latest | ||
env: | ||
EQUINIX_API_ENDPOINT: "https://uatapi.equinix.com" | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | ||
id: actions-checkout | ||
with: | ||
ref: main | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha || github.ref }} | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: './go.mod' | ||
id: go | ||
|
||
- name: Get dependencies | ||
run: | | ||
go mod download | ||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: ${{ matrix.terraform }} | ||
terraform_wrapper: false | ||
|
||
- name: Setup Variables Files | ||
run: | ||
# Parse secret content | ||
secret_content=${{ steps.read_secret.outputs.secret_content }} | ||
|
||
# Use conditional logic to map secret content to test directories | ||
if [[ "$secret_content" == *"port-connection-port-zside"* ]]; then | ||
echo "$secret_content" > examples/port-2-port-connection/terraform.tfvars.json | ||
fi | ||
|
||
- name: Run Go Tests | ||
run: | ||
go test ./tests/uat -v -coverprofile coverage_uat_modules.txt -covermode=atomic -count 1 -parallel 8 -timeout 180m | ||
|
||
- name: Upload test coverage to Codecov | ||
if: ${{ always() }} | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage_uat_modules.txt |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/equinix/terraform-equinix-fabric | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/gruntwork-io/terratest v0.43.0 | ||
github.com/stretchr/testify v1.8.4 | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package uat | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/stretchr/testify/assert" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestPort2PortCreateConnection(t *testing.T) { | ||
// retryable errors in terraform testing. | ||
|
||
cwd, _ := os.Getwd() | ||
fmt.Println("Current working directory:", cwd) | ||
|
||
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: "../../examples/port-2-port-connection", | ||
}) | ||
|
||
defer terraform.Destroy(t, terraformOptions) | ||
|
||
terraform.InitAndApply(t, terraformOptions) | ||
output := terraform.Output(t, terraformOptions, "connection_result") | ||
assert.NotNil(t, output) | ||
} |