Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted test-integration to YAML template with inline script #328

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,9 @@ jobs:
TF_VAR_remote_state_container: $(REMOTE_STATE_CONTAINER)
TF_VAR_remote_state_account: $(REMOTE_STATE_ACCOUNT)

- task: AzureCLI@1
displayName: 'Integration Test Terraform Template'
condition: not(coalesce(variables.SKIP_TESTS, ${{ parameters.skipTests }}))
inputs:
azureSubscription: '$(SERVICE_CONNECTION_NAME)'
scriptPath: './$(RELEASE_ARTIFACT_NAME)/$(PIPELINE_ROOT_DIR)/$(SCRIPTS_DIR)/test-integration.sh'
addSpnToEnvironment: true
workingDirectory: '$(System.DefaultWorkingDirectory)'
env:
TF_VAR_remote_state_container: $(REMOTE_STATE_CONTAINER)
TF_VAR_remote_state_account: $(REMOTE_STATE_ACCOUNT)
- template: scripts/test-integration.yml
parameters:
skip: ${{ parameters.skipTests }}

- ${{ if containsValue(config.environmentsToTeardownAfterRelease, parameters.environment) }}:
- task: AzureCLI@1
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
parameters:
skip: false

steps:
- task: AzureCLI@1
displayName: 'Integration Test Terraform Template'
condition: not(coalesce(variables.SKIP_TESTS, ${{ parameters.skip }}))
awkwardindustries marked this conversation as resolved.
Show resolved Hide resolved
env:
TF_VAR_remote_state_container: $(REMOTE_STATE_CONTAINER)
TF_VAR_remote_state_account: $(REMOTE_STATE_ACCOUNT)
inputs:
azureSubscription: '$(SERVICE_CONNECTION_NAME)'
addSpnToEnvironment: true
scriptLocation: inlineScript
inlineScript: |
#!/usr/bin/env bash

set -euo pipefail

function storageAccountPrimaryKey() {
az storage account keys list --subscription "$ARM_SUBSCRIPTION_ID" --account-name "$TF_VAR_remote_state_account" --query "[0].value" --output tsv
}

function azureTenantId() {
az account show --query "tenantId" --output tsv
}

export ARM_ACCESS_KEY=$(storageAccountPrimaryKey)
export ARM_CLIENT_SECRET="$servicePrincipalKey"
export ARM_CLIENT_ID="$servicePrincipalId"
export ARM_TENANT_ID=$(azureTenantId)

cd "$ARTIFACT_ROOT"/"$TERRAFORM_TEMPLATE_PATH"

# Setting the scripts to be run as executable
chmod -fR 755 *.sh || true

go test -v $(go list ./... | grep "$TERRAFORM_TEMPLATE_PATH" | grep "integration")