github.com/hashicorp/packer@v1.14.3/.github/workflows/acceptance-test.yml (about)

     1  #
     2  # This GitHub action runs Packer's acceptance tests every night.
     3  # Failures are reported to slack.
     4  #
     5  
     6  name: "Acceptance Test"
     7  
     8  on:
     9    # workflow_dispatch allows manual triggering of the workflow
    10    workflow_dispatch:
    11    schedule:
    12    # Runs against the default branch every day at midnight
    13    - cron: "0 0 * * *"
    14  
    15  permissions:
    16    contents: read
    17  
    18  jobs:
    19    get-go-version:
    20      runs-on: ubuntu-latest
    21      outputs:
    22        go-version: ${{ steps.get-go-version.outputs.go-version }}
    23      steps:
    24        - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
    25        - name: 'Determine Go version'
    26          id: get-go-version
    27          # We use .go-version as our source of truth for current Go
    28          # version, because "goenv" can react to it automatically.
    29          run: |
    30            echo "Building with Go $(cat .go-version)"
    31            echo "go-version=$(cat .go-version)" >> $GITHUB_OUTPUT
    32    acceptance-test:
    33      runs-on: ubuntu-latest
    34      name: Acceptance Test
    35      needs: get-go-version
    36      env: 
    37        # AWS Creds for Assume Role
    38        AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
    39        AWS_ACCESS_KEY_ID: ${{ secrets.TESTACC_AWS_ACCESS_KEY_ID }}
    40        AWS_SECRET_ACCESS_KEY: ${{ secrets.TESTACC_AWS_SECRET_ACCESS_KEY }}
    41        AWS_REGION: ${{ secrets.TESTACC_AWS_REGION }}
    42        # Packer GH Token for API Rate Limiting
    43        PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    44      steps:
    45        - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
    46        - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
    47          with:
    48            go-version: ${{ needs.get-go-version.outputs.go-version }}
    49        - name: IAM Assume Role
    50          uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
    51          with:
    52            role-to-assume: ${{ env.AWS_ROLE_ARN }}
    53            aws-region: ${{ env.AWS_REGION }}
    54            aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
    55            aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
    56            role-duration-seconds: 3600
    57        - name: Install gotestsum
    58          run: go install gotest.tools/gotestsum@latest
    59        
    60      # we set the ACC_TEST_BUILDERS="amazon-ebs" since we want to test against the amazon-ebs tests (e.g. Powershell 
    61      # provisioner acceptance tests)
    62        - name: Run acceptance tests per module
    63          run: |
    64            mkdir -p /tmp/test-results
    65            make dev
    66            ACC_TEST_BUILDERS="amazon-ebs" 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)
    67    # Send a slack notification if either job defined above fails
    68    slack-notify:
    69      permissions:
    70        contents: none
    71      needs: 
    72        - get-go-version
    73        - acceptance-test
    74      if: always() && (needs.get-go-version.result == 'failure' || needs.acceptance-test.result == 'failure')
    75      runs-on: ubuntu-latest
    76      steps:
    77        - name: Send slack notification on failure
    78          uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
    79          with:
    80            payload: |
    81              {
    82                "text": ":alert: Packer Nightly Acceptance Tests *FAILED* :alert:",
    83                "attachments": [
    84                  {
    85                    "color": "#C41E3A",
    86                    "blocks": [
    87                      {
    88                        "type": "section",
    89                        "text": {
    90                          "type": "mrkdwn",
    91                          "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 }}"
    92                        }
    93                      }
    94                    ]
    95                  }
    96                ]
    97              }
    98          env:
    99            SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
   100            SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK