diff --git a/.buildkite/acceptance.sh b/.buildkite/acceptance.sh new file mode 100644 index 000000000..da88a65b9 --- /dev/null +++ b/.buildkite/acceptance.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +echo "--- Download dependencies" +make vendor + +echo "--- Run acceptance tests" +EC_API_KEY=$TERRAFORM_PROVIDER_API_KEY_SECRET make testacc diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 71a3fc2ea..bdf58ea54 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -2,10 +2,16 @@ set -euo pipefail +#Mimic Jenkins behavior during the migration +export BUILD_ID=$BUILDKITE_BUILD_ID + VAULT_PATH=secret/ci/elastic-terraform-provider-ec/terraform-provider-secrets # Secrets must be redacted # https://buildkite.com/docs/pipelines/managing-log-output#redacted-environment-variables +if [[ "$BUILDKITE_PIPELINE_SLUG" == "terraform-provider-ec-acceptance" ]]; then + export TERRAFORM_PROVIDER_API_KEY_SECRET=$(scripts/retry.sh 5 vault kv get -field apikey ${VAULT_PATH}) +fi if [[ "$BUILDKITE_PIPELINE_SLUG" == "terraform-provider-ec-release" ]]; then export GPG_PRIVATE_SECRET=$(scripts/retry.sh 5 vault kv get -field gpg_private ${VAULT_PATH}) diff --git a/.buildkite/hooks/pre-exit b/.buildkite/hooks/pre-exit new file mode 100644 index 000000000..db6fbbcaf --- /dev/null +++ b/.buildkite/hooks/pre-exit @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +if [[ "$BUILDKITE_STEP_KEY" == "acceptance-tests" ]]; then + echo "--- Sweeps any deployments older than 1h." + EC_API_KEY=$TERRAFORM_PROVIDER_API_KEY_SECRET SWEEPARGS=-sweep-run=ec_deployments make sweep + rm -rf reports bin +fi diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml old mode 100644 new mode 100755 index 904c4fca7..2cbd26d3d --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,3 +1,7 @@ steps: - - label: ":wave: Greetings" - command: "echo 'My first pipeline!'" + - label: ":test_tube: Acceptance tests" + command: .buildkite/acceptance.sh + agents: + image: "docker.io/library/golang:1.21" + cpu: "8" + memory: "4G" diff --git a/catalog-info.yaml b/catalog-info.yaml index 91dfe2915..3316694a0 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -3,8 +3,8 @@ apiVersion: backstage.io/v1alpha1 kind: Resource metadata: - name: buildkite-pipeline-terraform-provider-ec - description: Buildkite Pipeline for terraform-provider-ec + name: buildkite-pipeline-terraform-provider-ec-acceptance + description: Buildkite Pipeline for terraform-provider-ec acceptance tests links: - title: Pipeline url: https://buildkite.com/elastic/terraform-provider-ec @@ -17,11 +17,11 @@ spec: apiVersion: buildkite.elastic.dev/v1 kind: Pipeline metadata: - name: terraform-provider-ec + name: terraform-provider-ec-acceptance spec: repository: elastic/terraform-provider-ec pipeline_file: ".buildkite/pipeline.yml" ---- + # yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json apiVersion: backstage.io/v1alpha1 kind: Resource