Skip to content

Commit

Permalink
Buildkite pipeline for acceptance tests (#741)
Browse files Browse the repository at this point in the history
* Acceptance test buildkite job

Porting the acceptance job to Buildkite.
I moved all the logic of the Makefile into a more Buildkite way of
handling secrets (via pre-command) to benefit from secrets redaction.

* Disable failing test during migration

* Disable failing test during migration

This reverts commit 4211c0e.

* Disable failing test during migration

* Re-enabled disabled tests

* Update Buildkite teams perms section

* Use more generic go version
  • Loading branch information
nkammah authored Nov 22, 2023
1 parent 475ba5f commit 29a416c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .buildkite/acceptance.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
9 changes: 9 additions & 0 deletions .buildkite/hooks/pre-exit
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions .buildkite/pipeline.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 4 additions & 4 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 29a416c

Please sign in to comment.