2022-08-23 19:53:41 +00:00
|
|
|
---
|
|
|
|
name: enos
|
|
|
|
|
|
|
|
on:
|
2022-12-12 20:46:04 +00:00
|
|
|
# Only trigger this working using workflow_call. This workflow requires many
|
|
|
|
# secrets that must be inherited from the caller workflow.
|
2022-08-23 19:53:41 +00:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
2022-12-12 20:46:04 +00:00
|
|
|
# The name of the artifact that we're going to use for testing. This should
|
|
|
|
# match exactly to build artifacts uploaded to Github and Artifactory.
|
|
|
|
build-artifact-name:
|
2022-08-23 19:53:41 +00:00
|
|
|
required: true
|
|
|
|
type: string
|
2023-09-08 19:31:09 +00:00
|
|
|
# The maximum number of scenarios to include in the test sample.
|
|
|
|
sample-max:
|
|
|
|
default: 1
|
|
|
|
type: number
|
|
|
|
# The name of the enos scenario sample that defines compatible scenarios we can
|
|
|
|
# can test with.
|
|
|
|
sample-name:
|
2022-10-04 20:08:26 +00:00
|
|
|
required: true
|
|
|
|
type: string
|
2022-12-12 20:46:04 +00:00
|
|
|
runs-on:
|
|
|
|
# NOTE: The value should be JSON encoded as that's the only way we can
|
|
|
|
# pass arrays with workflow_call.
|
|
|
|
type: string
|
2022-10-17 23:47:37 +00:00
|
|
|
required: false
|
2022-12-12 20:46:04 +00:00
|
|
|
default: '"ubuntu-latest"'
|
|
|
|
ssh-key-name:
|
2022-10-17 23:47:37 +00:00
|
|
|
type: string
|
2023-01-18 21:09:19 +00:00
|
|
|
default: ${{ github.event.repository.name }}-ci-ssh-key
|
2023-09-11 21:23:55 +00:00
|
|
|
vault-edition:
|
|
|
|
required: false
|
2023-09-06 17:24:39 +00:00
|
|
|
type: string
|
2023-09-11 21:23:55 +00:00
|
|
|
default: oss
|
2022-12-12 20:46:04 +00:00
|
|
|
# The Git commit SHA used as the revision when building vault
|
|
|
|
vault-revision:
|
2022-10-04 20:08:26 +00:00
|
|
|
required: true
|
|
|
|
type: string
|
2023-09-11 21:23:55 +00:00
|
|
|
vault-version:
|
|
|
|
required: true
|
|
|
|
type: string
|
2022-08-23 19:53:41 +00:00
|
|
|
|
|
|
|
jobs:
|
2022-12-12 20:46:04 +00:00
|
|
|
metadata:
|
|
|
|
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
2022-09-14 18:17:07 +00:00
|
|
|
outputs:
|
2022-12-12 20:46:04 +00:00
|
|
|
build-date: ${{ steps.metadata.outputs.build-date }}
|
2023-09-08 19:31:09 +00:00
|
|
|
sample: ${{ steps.metadata.outputs.sample }}
|
2023-09-11 21:23:55 +00:00
|
|
|
vault-version: ${{ steps.metadata.outputs.vault-version }}
|
2022-09-14 18:17:07 +00:00
|
|
|
steps:
|
2023-07-05 21:19:49 +00:00
|
|
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-12-16 20:19:10 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ inputs.vault-revision }}
|
2023-09-08 19:31:09 +00:00
|
|
|
- uses: hashicorp/action-setup-enos@v1
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2022-12-12 20:46:04 +00:00
|
|
|
- id: metadata
|
2022-09-14 18:17:07 +00:00
|
|
|
run: |
|
2023-03-22 19:02:06 +00:00
|
|
|
echo "build-date=$(make ci-get-date)" >> "$GITHUB_OUTPUT"
|
2023-09-08 19:31:09 +00:00
|
|
|
sample="$(enos scenario sample observe ${{ inputs.sample-name }} --chdir ./enos --min 1 --max ${{ inputs.sample-max }} --seed "$(date +%s%N)" --format json | jq -c ".observation.elements")"
|
|
|
|
echo "sample=$sample"
|
|
|
|
echo "sample=$sample" >> "$GITHUB_OUTPUT"
|
2023-09-11 21:23:55 +00:00
|
|
|
if [[ "${{ inputs.vault-edition }}" == "oss" ]]; then
|
|
|
|
echo "vault-version=${{ inputs.vault-version }}" >> "$GITHUB_OUTPUT"
|
|
|
|
else
|
|
|
|
# shellcheck disable=2001
|
|
|
|
vault_version="$(sed 's/+ent/+${{ inputs.vault-edition }}/g' <<< '${{ inputs.vault-version }}')"
|
|
|
|
echo "vault-version=$vault_version"
|
|
|
|
echo "vault-version=$vault_version" >> "$GITHUB_OUTPUT"
|
|
|
|
fi
|
2022-12-12 20:46:04 +00:00
|
|
|
|
2023-09-08 19:31:09 +00:00
|
|
|
# Run the Enos test scenario(s)
|
2022-12-12 20:46:04 +00:00
|
|
|
run:
|
|
|
|
needs: metadata
|
2023-09-08 19:31:09 +00:00
|
|
|
name: run ${{ matrix.scenario.id.filter }}
|
2022-08-23 19:53:41 +00:00
|
|
|
strategy:
|
2022-09-01 19:16:17 +00:00
|
|
|
fail-fast: false # don't fail as that can skip required cleanup steps for jobs
|
2023-09-08 19:31:09 +00:00
|
|
|
matrix:
|
|
|
|
include: ${{ fromJSON(needs.metadata.outputs.sample) }}
|
|
|
|
runs-on: ${{ fromJSON(inputs.runs-on) }}
|
2022-08-23 19:53:41 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2022-12-12 20:46:04 +00:00
|
|
|
# Pass in enos variables
|
2023-09-08 19:31:09 +00:00
|
|
|
ENOS_VAR_aws_region: ${{ matrix.attributes.aws_region }}
|
2022-12-12 20:46:04 +00:00
|
|
|
ENOS_VAR_aws_ssh_keypair_name: ${{ inputs.ssh-key-name }}
|
|
|
|
ENOS_VAR_aws_ssh_private_key_path: ./support/private_key.pem
|
|
|
|
ENOS_VAR_tfc_api_token: ${{ secrets.TF_API_TOKEN }}
|
|
|
|
ENOS_VAR_artifactory_username: ${{ secrets.ARTIFACTORY_USER }}
|
|
|
|
ENOS_VAR_artifactory_token: ${{ secrets.ARTIFACTORY_TOKEN }}
|
|
|
|
ENOS_VAR_terraform_plugin_cache_dir: ./support/terraform-plugin-cache
|
2023-07-20 20:51:07 +00:00
|
|
|
ENOS_VAR_vault_artifact_path: ./support/downloads/${{ inputs.build-artifact-name }}
|
2022-12-12 20:46:04 +00:00
|
|
|
ENOS_VAR_vault_build_date: ${{ needs.metadata.outputs.build-date }}
|
2023-09-11 21:23:55 +00:00
|
|
|
ENOS_VAR_vault_product_version: ${{ needs.metadata.outputs.vault-version }}
|
2022-12-12 20:46:04 +00:00
|
|
|
ENOS_VAR_vault_revision: ${{ inputs.vault-revision }}
|
|
|
|
ENOS_VAR_vault_license_path: ./support/vault.hclic
|
2023-04-11 17:06:51 +00:00
|
|
|
ENOS_DEBUG_DATA_ROOT_DIR: /tmp/enos-debug-data
|
2022-08-23 19:53:41 +00:00
|
|
|
steps:
|
2023-07-05 21:19:49 +00:00
|
|
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-12-12 20:46:04 +00:00
|
|
|
- uses: hashicorp/setup-terraform@v2
|
2022-08-23 19:53:41 +00:00
|
|
|
with:
|
|
|
|
# the Terraform wrapper will break Terraform execution in Enos because
|
|
|
|
# it changes the output to text when we expect it to be JSON.
|
|
|
|
terraform_wrapper: false
|
2023-07-05 21:19:49 +00:00
|
|
|
- uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
|
2022-08-23 19:53:41 +00:00
|
|
|
with:
|
2023-01-18 21:09:19 +00:00
|
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CI }}
|
|
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CI }}
|
2023-09-08 19:31:09 +00:00
|
|
|
aws-region: ${{ matrix.attributes.aws_region }}
|
2023-01-18 21:09:19 +00:00
|
|
|
role-to-assume: ${{ secrets.AWS_ROLE_ARN_CI }}
|
2022-08-23 19:53:41 +00:00
|
|
|
role-skip-session-tagging: true
|
|
|
|
role-duration-seconds: 3600
|
2022-12-12 20:46:04 +00:00
|
|
|
- uses: hashicorp/action-setup-enos@v1
|
2022-08-23 19:53:41 +00:00
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2022-12-12 20:46:04 +00:00
|
|
|
- name: Prepare scenario dependencies
|
2023-03-31 18:31:35 +00:00
|
|
|
id: prepare_scenario
|
2022-08-23 19:53:41 +00:00
|
|
|
run: |
|
2023-04-05 19:49:46 +00:00
|
|
|
mkdir -p "./enos/support/terraform-plugin-cache"
|
|
|
|
echo "${{ secrets.SSH_KEY_PRIVATE_CI }}" > "./enos/support/private_key.pem"
|
|
|
|
chmod 600 "./enos/support/private_key.pem"
|
2023-04-06 17:04:09 +00:00
|
|
|
echo "debug_data_artifact_name=enos-debug-data_$(echo "${{ matrix.scenario }}" | sed -e 's/ /_/g' | sed -e 's/:/=/g')" >> "$GITHUB_OUTPUT"
|
2023-09-08 19:31:09 +00:00
|
|
|
- if: contains(inputs.sample-name, 'build')
|
2023-05-22 17:18:06 +00:00
|
|
|
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
|
2022-08-23 19:53:41 +00:00
|
|
|
with:
|
2022-12-12 20:46:04 +00:00
|
|
|
name: ${{ inputs.build-artifact-name }}
|
2022-08-23 19:53:41 +00:00
|
|
|
path: ./enos/support/downloads
|
2023-09-08 19:31:09 +00:00
|
|
|
- if: contains(inputs.sample-name, 'ent')
|
2022-12-12 20:46:04 +00:00
|
|
|
name: Configure Vault license
|
|
|
|
run: echo "${{ secrets.VAULT_LICENSE }}" > ./enos/support/vault.hclic || true
|
2023-10-03 19:29:40 +00:00
|
|
|
- id: launch
|
|
|
|
name: enos scenario launch ${{ matrix.scenario.id.filter }}
|
|
|
|
# Continue once and retry to handle occasional blips when creating infrastructure.
|
2022-08-23 19:53:41 +00:00
|
|
|
continue-on-error: true
|
2023-10-03 19:29:40 +00:00
|
|
|
run: enos scenario launch --timeout 60m0s --chdir ./enos ${{ matrix.scenario.id.filter }}
|
|
|
|
- if: steps.launch.outcome == 'failure'
|
|
|
|
id: launch_retry
|
|
|
|
name: Retry enos scenario launch ${{ matrix.scenario.id.filter }}
|
|
|
|
run: enos scenario launch --timeout 60m0s --chdir ./enos ${{ matrix.scenario.id.filter }}
|
2023-03-31 18:31:35 +00:00
|
|
|
- name: Upload Debug Data
|
|
|
|
if: failure()
|
2023-05-22 17:18:06 +00:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2023-03-31 18:31:35 +00:00
|
|
|
with:
|
|
|
|
# The name of the artifact is the same as the matrix scenario name with the spaces replaced with underscores and colons replaced by equals.
|
|
|
|
name: ${{ steps.prepare_scenario.outputs.debug_data_artifact_name }}
|
|
|
|
path: ${{ env.ENOS_DEBUG_DATA_ROOT_DIR }}
|
|
|
|
retention-days: 30
|
2023-06-30 19:51:51 +00:00
|
|
|
continue-on-error: true
|
2023-10-03 19:29:40 +00:00
|
|
|
- if: ${{ always() }}
|
2023-06-30 19:51:51 +00:00
|
|
|
id: destroy
|
2023-10-03 19:29:40 +00:00
|
|
|
name: enos scenario destroy ${{ matrix.scenario.id.filter }}
|
|
|
|
continue-on-error: true
|
|
|
|
run: enos scenario destroy --timeout 60m0s --chdir ./enos ${{ matrix.scenario.id.filter }}
|
|
|
|
- if: steps.destroy.outcome == 'failure'
|
|
|
|
id: destroy_retry
|
|
|
|
name: Retry enos scenario destroy ${{ matrix.scenario.id.filter }}
|
2022-09-29 20:55:44 +00:00
|
|
|
continue-on-error: true
|
2023-09-08 19:31:09 +00:00
|
|
|
run: enos scenario destroy --timeout 60m0s --chdir ./enos ${{ matrix.scenario.id.filter }}
|
2022-12-12 20:46:04 +00:00
|
|
|
- name: Clean up Enos runtime directories
|
2023-06-30 19:51:51 +00:00
|
|
|
id: cleanup
|
2022-09-14 18:17:07 +00:00
|
|
|
if: ${{ always() }}
|
2023-06-30 19:51:51 +00:00
|
|
|
continue-on-error: true
|
2022-08-23 19:53:41 +00:00
|
|
|
run: |
|
2022-09-14 18:17:07 +00:00
|
|
|
rm -rf /tmp/enos*
|
|
|
|
rm -rf ./enos/support
|
|
|
|
rm -rf ./enos/.enos
|
2023-10-03 19:29:40 +00:00
|
|
|
# Send slack notifications to #feed-vault-enos-failures any of our enos scenario commands fail.
|
|
|
|
# There is an incoming webhook set up on the "Enos Vault Failure Bot" Slackbot:
|
|
|
|
# https://api.slack.com/apps/A05E31CH1LG/incoming-webhooks
|
|
|
|
- if: ${{ always() && ! cancelled() }}
|
|
|
|
name: Notify launch failed
|
2023-06-30 19:51:51 +00:00
|
|
|
uses: hashicorp/actions-slack-status@v1
|
|
|
|
with:
|
2023-10-03 19:29:40 +00:00
|
|
|
failure-message: "enos scenario launch ${{ matrix.scenario.id.filter}} failed. \nTriggering event: `${{ github.event_name }}` \nActor: `${{ github.actor }}`"
|
|
|
|
status: ${{ steps.launch.outcome }}
|
2023-07-13 16:09:34 +00:00
|
|
|
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
2023-10-03 19:29:40 +00:00
|
|
|
- if: ${{ always() && ! cancelled() }}
|
|
|
|
name: Notify retry launch failed
|
2023-06-30 19:51:51 +00:00
|
|
|
uses: hashicorp/actions-slack-status@v1
|
|
|
|
with:
|
2023-10-03 19:29:40 +00:00
|
|
|
failure-message: "retry enos scenario launch ${{ matrix.scenario.id.filter}} failed. \nTriggering event: `${{ github.event_name }}` \nActor: `${{ github.actor }}`"
|
|
|
|
status: ${{ steps.launch_retry.outcome }}
|
2023-07-13 16:09:34 +00:00
|
|
|
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
2023-10-03 19:29:40 +00:00
|
|
|
- if: ${{ always() && ! cancelled() }}
|
|
|
|
name: Notify destroy failed
|
2023-06-30 19:51:51 +00:00
|
|
|
uses: hashicorp/actions-slack-status@v1
|
|
|
|
with:
|
2023-10-03 19:29:40 +00:00
|
|
|
failure-message: "enos scenario destroy ${{ matrix.scenario.id.filter}} failed. \nTriggering event: `${{ github.event_name }}` \nActor: `${{ github.actor }}`"
|
2023-07-13 16:09:34 +00:00
|
|
|
status: ${{ steps.destroy.outcome }}
|
|
|
|
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
2023-10-03 19:29:40 +00:00
|
|
|
- if: ${{ always() && ! cancelled() }}
|
|
|
|
name: Notify retry destroy failed
|
|
|
|
uses: hashicorp/actions-slack-status@v1
|
|
|
|
with:
|
|
|
|
failure-message: "retry enos scenario destroy ${{ matrix.scenario.id.filter}} failed. \nTriggering event: `${{ github.event_name }}` \nActor: `${{ github.actor }}`"
|
|
|
|
status: ${{ steps.destroy_retry.outcome }}
|
|
|
|
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
|