Skip to content

Test

Test #669

Workflow file for this run

name: Run Tests
on:
workflow_call:
inputs:
acc-test-pattern:
type: string
default: 'Test.*'
workflow_dispatch:
inputs:
acc-test-pattern:
type: string
default: 'Test.*'
concurrency: acceptance-testing-environment
permissions:
contents: read
jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
token: ${{ secrets.HCP_SDK_PIPELINE_TOKEN }}
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
cache: true
go-version-file: 'go.mod'
cache-dependency-path: go.sum
- name: Install Dependencies
env:
GOPRIVATE: 'github.com/hashicorp/*'
run: |
go install github.com/golangci/golangci-lint/cmd/[email protected]
go mod tidy
sudo wget https://github.com/jmespath/jp/releases/latest/download/jp-linux-amd64 -O /usr/local/bin/jp
sudo chmod +x /usr/local/bin/jp
- name: Run Unit Tests and Linter
run: make test-ci
- name: Upload Unit Test Coverage Artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: Test Coverage
path: coverage.html
- name: Warn If Non-default Pattern
if: inputs.acc-test-pattern != 'Test.*'
run: |
echo "## WARNING: Some tests may have been skipped!" >> $GITHUB_STEP_SUMMARY
echo "The default acceptance test pattern is \`Test.*\`, but it was overridden with \`${{ inputs.acc-test-pattern }}\`." >> $GITHUB_STEP_SUMMARY
- name: Run E2E Tests
env:
HCP_API_HOST: ${{ secrets.HCP_API_HOST }}
HCP_AUTH_URL: ${{ secrets.HCP_AUTH_URL }}
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
HCP_ORGANIZATION_ID: ${{ secrets.HCP_ORGANIZATION_ID }}
HCP_PROJECT_ID: ${{ secrets.HCP_PROJECT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AWS_REGION: us-west-1
AZURE_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
AZURE_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
AWS_OUTPUT=$(aws sts assume-role --role-arn $AWS_ROLE_ARN --role-session-name e2e-test --duration-seconds 43200)
export AWS_ACCESS_KEY_ID=$(echo $AWS_OUTPUT | jp --unquoted Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $AWS_OUTPUT | jp --unquoted Credentials.SessionToken)
make testacc-ci TESTARGS='-run=${{ inputs.acc-test-pattern }} -test.v'
- name: Upload E2E Coverage Artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: Test Coverage
path: coverage-e2e.html