Skip to content

Commit

Permalink
Add composite action acctest
Browse files Browse the repository at this point in the history
  • Loading branch information
1 parent c8d323f commit 770c18f
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/actions/acctest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: acctest
inputs:
provider-test-infra-dir:
required: false
provider-go-test-dir:
required: false
provider-go-test-tags:
required: false
default: ''
provider-tf-apply:
required: false
default: terraform apply -auto-approve
runs:
using: composite
steps:
- uses: "./.github/actions/tf-install"
- uses: actions/checkout@v3.5.0
- name: download and install AWS CLI
run: |-
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
echo -e "${AWS_CLI_GPG_KEY}" | gpg --import
curl -o awscliv2.sig https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip.sig
gpg --verify awscliv2.sig awscliv2.zip
unzip awscliv2.zip
sudo ./aws/install
if: "'aws' == ${{ inputs.provider-test-infra-dir }}"
shell: bash
- name: set assume-role creds
run: |-
CREDENTIALS="$(aws sts assume-role --role-arn ${SERVICE_GO_DISCOVER_TESTS_ROLE_ARN} --role-session-name build-${{ github.sha }} | jq '.Credentials')"
echo "export AWS_ACCESS_KEY_ID=$(echo $CREDENTIALS | jq -r '.AccessKeyId')" >> $BASH_ENV
echo "export AWS_SECRET_ACCESS_KEY=$(echo $CREDENTIALS | jq -r '.SecretAccessKey')" >> $BASH_ENV
echo "export AWS_SESSION_TOKEN=$(echo $CREDENTIALS | jq -r '.SessionToken')" >> $BASH_ENV
if: "'aws' == ${{ inputs.provider-test-infra-dir }}"
shell: bash
- run: terraform init
working-directory: "./test/tf/${{ inputs.provider-test-infra-dir }}"
shell: bash
- run: "${{ inputs.provider-tf-apply }}"
working-directory: "./test/tf/${{ inputs.provider-test-infra-dir }}"
shell: bash
- run: mkdir -p /tmp/test-results
shell: bash
- name: Run provider tests
run: |-
gotestsum -f standard-verbose --junitfile ${TEST_RESULTS}/results.xml -- \
-run ${{ inputs.provider-go-test-tags }} \
-v ./provider/${{ inputs.provider-go-test-dir }}
if: "${{ inputs.provider-go-test-tags }}"
shell: bash
- name: Run provider tests
run: |-
gotestsum -f standard-verbose --junitfile ${TEST_RESULTS}/results.xml -- \
-v ./provider/${{ inputs.provider-go-test-dir }}
if: "${{ !(${{ inputs.provider-go-test-tags }}) }}"
shell: bash
- uses: actions/upload-artifact@v3.1.1
with:
path: "/tmp/test-results"
- run: terraform destroy --force
working-directory: "./test/tf/${{ inputs.provider-test-infra-dir }}"
if: always()
shell: bash

0 comments on commit 770c18f

Please sign in to comment.