mirror of https://github.com/hashicorp/packer
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.4 KiB
119 lines
4.4 KiB
#
|
|
# This GitHub action runs Packer's acceptance tests every night.
|
|
# Failures are reported to slack.
|
|
#
|
|
|
|
name: "Acceptance Test"
|
|
|
|
on:
|
|
schedule:
|
|
# Runs against the default branch every day at midnight
|
|
- cron: "0 0 * * *"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
get-go-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
go-version: ${{ steps.get-go-version.outputs.go-version }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: 'Determine Go version'
|
|
id: get-go-version
|
|
# We use .go-version as our source of truth for current Go
|
|
# version, because "goenv" can react to it automatically.
|
|
run: |
|
|
echo "Building with Go $(cat .go-version)"
|
|
echo "::set-output name=go-version::$(cat .go-version)"
|
|
acceptance-test:
|
|
runs-on: ubuntu-latest
|
|
name: Packer Acceptance Test
|
|
needs: get-go-version
|
|
env:
|
|
# AWS Creds for Assume Role
|
|
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.TESTACC_AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.TESTACC_AWS_SECRET_ACCESS_KEY }}
|
|
AWS_REGION: ${{ secrets.TESTACC_AWS_REGION }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
|
- name: IAM Assume Role
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
with:
|
|
role-to-assume: ${{ env.AWS_ROLE_ARN }}
|
|
aws-region: ${{ env.AWS_REGION }}
|
|
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
|
role-duration-seconds: 3600
|
|
- name: Install gotestsum
|
|
run: go install gotest.tools/gotestsum@latest
|
|
- name: Run acceptance tests per module
|
|
run: |
|
|
mkdir -p /tmp/test-results
|
|
make dev
|
|
PACKER_ACC=1 gotestsum --format=short-verbose --junitfile /tmp/test-results/gotestsum-report.xml -- -timeout=120m -p 2 $(go list ./... | grep -v inspec | grep -v profitbricks | grep -v oneandone)
|
|
hpats:
|
|
runs-on: ubuntu-latest
|
|
name: HCP Packer Acceptance Test (HPATS)
|
|
needs: get-go-version
|
|
env:
|
|
# Set HCP credentials
|
|
HCP_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
|
|
HCP_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
|
|
AUTH0_CLIENT_ID: ${{ secrets.HCP_CLIENT_ID }}
|
|
AUTH0_CLIENT_SECRET: ${{ secrets.HCP_CLIENT_SECRET }}
|
|
AUTH0_HOST: ${{ secrets.AUTH0_HOST }}
|
|
HCP_ORG_ID: ${{ secrets.HCP_ORG_ID }}
|
|
HCP_PROJECT_ID: ${{ secrets.HCP_PROJECT_ID }}
|
|
HCP_API_HOST: ${{ secrets.HCP_API_HOST }}
|
|
HPATS_API_URL: https://${{ secrets.HCP_API_HOST }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
|
- name: Clone HPATS
|
|
run: |
|
|
eval `ssh-agent -s` && ssh-add - <<< '${{ secrets.HPATS_ACCESS_TOKEN }}'
|
|
git clone git@github.com:hashicorp/hcp-packer-acceptance-tests
|
|
cd hcp-packer-acceptance-tests
|
|
- name: Set HCP Access Token
|
|
run: export HCP_ACCESS_TOKEN=$(make hcp/get-auth0-m2m-access-token)
|
|
- name: Run HPATS
|
|
run: make test
|
|
# Send a slack notification if one of the jobs defined above fails
|
|
slack-notify:
|
|
needs:
|
|
- get-go-version
|
|
- acceptance-test
|
|
- hpats
|
|
if: always() && (needs.get-go-version.result == 'failure' || needs.acceptance-test.result == 'failure' || needs.hpats.result == 'failure')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Send slack notification on failure
|
|
uses: slackapi/slack-github-action@v1.19.0
|
|
with:
|
|
payload: |
|
|
{
|
|
"text": ":alert: Packer Nightly Acceptance Tests *FAILED* :alert:",
|
|
"attachments": [
|
|
{
|
|
"color": "#C41E3A",
|
|
"blocks": [
|
|
{
|
|
"type": "section",
|
|
"text": {
|
|
"type": "mrkdwn",
|
|
"text": "Branch: `${{ github.ref_name }}`\nRef: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nWorkflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |