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
|
2022-12-12 20:46:04 +00:00
|
|
|
# The base name of the file in ./github/enos-run-matrices that we use to
|
|
|
|
# determine which scenarios to run for the build artifact.
|
|
|
|
#
|
|
|
|
# They are named in the format of:
|
|
|
|
# $caller_workflow_name-$artifact_source-$vault_edition-$platform-$arch-$packing_type
|
|
|
|
#
|
|
|
|
# Where each are:
|
|
|
|
# caller_workflow_name: the Github Actions workflow that is calling
|
|
|
|
# this one
|
|
|
|
# artifact_source: where we're getting the artifact from. Either
|
|
|
|
# "github" or "artifactory"
|
|
|
|
# vault_edition: which edition of vault that we're testing. e.g. "oss"
|
|
|
|
# or "ent"
|
|
|
|
# platform: the vault binary target platform, e.g. "linux" or "macos"
|
|
|
|
# arch: the vault binary target architecture, e.g. "arm64" or "amd64"
|
|
|
|
# packing_type: how vault binary is packaged, e.g. "zip", "deb", "rpm"
|
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
# build-github-oss-linux-amd64-zip
|
|
|
|
matrix-file-name:
|
2022-10-04 20:08:26 +00:00
|
|
|
required: true
|
|
|
|
type: string
|
2022-12-12 20:46:04 +00:00
|
|
|
# The test group we want to run. This corresponds to the test_group attribute
|
|
|
|
# defined in the enos-run-matrices files.
|
|
|
|
matrix-test-group:
|
|
|
|
default: 0
|
|
|
|
type: string
|
|
|
|
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
|
2022-12-12 20:46:04 +00:00
|
|
|
# Which edition of Vault we're using. e.g. "oss", "ent", "ent.hsm.fips1402"
|
|
|
|
vault-edition:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
# 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
|
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 }}
|
|
|
|
matrix: ${{ steps.metadata.outputs.matrix }}
|
|
|
|
version: ${{ steps.metadata.outputs.version }}
|
|
|
|
version-minor: ${{ steps.metadata.outputs.matrix }}
|
|
|
|
env:
|
|
|
|
# Pass the vault edition as VAULT_METADATA so the CI make targets can create
|
|
|
|
# values that consider the edition.
|
|
|
|
VAULT_METADATA: ${{ inputs.vault-edition }}
|
|
|
|
# Pass in the matrix and matrix group for filtering
|
|
|
|
MATRIX_FILE: ./.github/enos-run-matrices/${{ inputs.matrix-file-name }}.json
|
|
|
|
MATRIX_TEST_GROUP: ${{ inputs.matrix-test-group }}
|
2022-09-14 18:17:07 +00:00
|
|
|
steps:
|
2022-12-12 20:46:04 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-12-16 20:19:10 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ inputs.vault-revision }}
|
2022-12-12 20:46:04 +00:00
|
|
|
- id: metadata
|
2022-09-14 18:17:07 +00:00
|
|
|
run: |
|
2022-12-12 20:46:04 +00:00
|
|
|
echo "build-date=$(make ci-get-date)" >> $GITHUB_OUTPUT
|
|
|
|
echo "version=$(make ci-get-version)" >> $GITHUB_OUTPUT
|
|
|
|
filtered=$(make ci-filter-matrix)
|
|
|
|
echo "matrix=$(echo $filtered)}" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
# Run the Enos test scenarios
|
|
|
|
run:
|
|
|
|
needs: metadata
|
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
|
2022-12-12 20:46:04 +00:00
|
|
|
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }}
|
2022-08-23 19:53:41 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2022-12-12 20:46:04 +00:00
|
|
|
# Pass in enos variables
|
|
|
|
ENOS_VAR_aws_region: ${{ matrix.aws_region }}
|
|
|
|
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
|
|
|
|
ENOS_VAR_vault_build_date: ${{ needs.metadata.outputs.build-date }}
|
|
|
|
ENOS_VAR_vault_product_version: ${{ needs.metadata.outputs.version }}
|
|
|
|
ENOS_VAR_vault_revision: ${{ inputs.vault-revision }}
|
|
|
|
ENOS_VAR_vault_bundle_path: ./support/downloads/${{ inputs.build-artifact-name }}
|
|
|
|
ENOS_VAR_vault_license_path: ./support/vault.hclic
|
2022-08-23 19:53:41 +00:00
|
|
|
steps:
|
2022-12-12 20:46:04 +00:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- 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
|
2022-12-12 20:46:04 +00:00
|
|
|
- uses: aws-actions/configure-aws-credentials@v1-node16
|
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 }}
|
2022-08-23 19:53:41 +00:00
|
|
|
aws-region: ${{ matrix.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
|
2022-08-23 19:53:41 +00:00
|
|
|
run: |
|
2022-12-12 20:46:04 +00:00
|
|
|
mkdir -p ./enos/support/terraform-plugin-cache
|
2023-01-18 21:09:19 +00:00
|
|
|
echo "${{ secrets.SSH_KEY_PRIVATE_CI }}" > ./enos/support/private_key.pem
|
2022-08-23 19:53:41 +00:00
|
|
|
chmod 600 ./enos/support/private_key.pem
|
2022-12-12 20:46:04 +00:00
|
|
|
- if: contains(inputs.matrix-file-name, 'github')
|
2022-08-23 19:53:41 +00:00
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
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
|
2022-12-12 20:46:04 +00:00
|
|
|
- if: contains(inputs.matrix-file-name, 'ent')
|
|
|
|
name: Configure Vault license
|
|
|
|
run: echo "${{ secrets.VAULT_LICENSE }}" > ./enos/support/vault.hclic || true
|
2022-08-23 19:53:41 +00:00
|
|
|
- name: Run Enos scenario
|
|
|
|
id: run
|
|
|
|
# Continue once and retry to handle occasional blips when creating
|
|
|
|
# infrastructure.
|
|
|
|
continue-on-error: true
|
2022-12-12 20:46:04 +00:00
|
|
|
run: enos scenario run --timeout 60m0s --chdir ./enos ${{ matrix.scenario }}
|
|
|
|
- name: Retry Enos scenario if necessary
|
2022-08-23 19:53:41 +00:00
|
|
|
id: run_retry
|
|
|
|
if: steps.run.outcome == 'failure'
|
2022-12-12 20:46:04 +00:00
|
|
|
run: enos scenario run --timeout 60m0s --chdir ./enos ${{ matrix.scenario }}
|
|
|
|
- name: Ensure scenario has been destroyed
|
2022-08-23 19:53:41 +00:00
|
|
|
if: ${{ always() }}
|
2022-09-29 20:55:44 +00:00
|
|
|
# With Enos version 0.0.11 the destroy step returns an error if the infrastructure
|
|
|
|
# is already destroyed by enos run. So temporarily setting it to continue on error in GHA
|
|
|
|
continue-on-error: true
|
2022-12-12 20:46:04 +00:00
|
|
|
run: enos scenario destroy --timeout 60m0s --chdir ./enos ${{ matrix.scenario }}
|
|
|
|
- name: Clean up Enos runtime directories
|
2022-09-14 18:17:07 +00:00
|
|
|
if: ${{ always() }}
|
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
|