Skip to content

Commit ceb8b7b

Browse files
committed
pipeline fix
1 parent 5115b52 commit ceb8b7b

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

.github/workflows/pipeline.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ jobs:
138138
- name: Configure AWS Namespace
139139
env:
140140
PR_NUMBER: ${{ github.event.number }}
141+
# This is the branch name, or the git tag name
141142
NS_BRANCH_OR_TAG: ${{ github.ref_name }}
142143
run: |
143144
echo "PR_NUMBER=${{ env.PR_NUMBER }}"
@@ -160,6 +161,8 @@ jobs:
160161
test $(shasum -a 256 ./dce_linux_amd64.zip | awk '{print $1}') == "${expected_sha}"
161162
unzip ./dce_linux_amd64.zip -d ./
162163
164+
# Lease a DCE account, to use for deploying our PR environment
165+
# (deploy DCE in DCE)
163166
- name: Lease DCE Account
164167
env:
165168
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -176,7 +179,8 @@ jobs:
176179
basepath: /api
177180
region: us-east-1
178181
" > ./dce.yml
179-
182+
183+
# Check to see if there's an active lease for this PR
180184
lease_id=$(
181185
./dce --config=dce.yml leases list \
182186
-p ${NAMESPACE} -s Active | \
@@ -197,16 +201,18 @@ jobs:
197201
./dce --config=dce.yml leases login ${lease_id}
198202
echo "${lease_id}" > ./lease_id.txt
199203
204+
# Install Terraform
200205
- name: Install Terraform
201206
uses: hashicorp/setup-terraform@v2
202207
with:
203208
terraform_version: ${{ inputs.terraform_version }}
204209

210+
# Configure the Terraform backend
205211
- name: Configure Terraform Backend
206212
run: |
207213
lease_id=$(cat lease_id.txt)
208214
./scripts/create-tf-backend.sh ${lease_id}
209-
215+
# terraform init
210216
- name: Terraform Init/Apply
211217
env:
212218
NAMESPACE: ${{ env.namespace }}
@@ -391,7 +397,8 @@ jobs:
391397
cp ${{ github.workspace }}/backend-tf/backend.tf ./modules/
392398
chmod +x ./dce
393399
394-
- name: Install Terraform for Cleanup
400+
# Cleanup the PR environment
401+
- name: Terraform for Cleanup
395402
uses: hashicorp/setup-terraform@v2
396403
with:
397404
terraform_version: ${{ inputs.terraform_version }}
@@ -411,7 +418,8 @@ jobs:
411418
cd modules
412419
terraform init -input=false
413420
terraform destroy -auto-approve
414-
421+
422+
# End the DCE lease
415423
- name: End DCE Lease
416424
env:
417425
AWS_DEFAULT_REGION: us-east-1

tests/acceptance/api_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ func TestApi(t *testing.T) {
6060
tfOut := terraform.OutputAll(t, tfOpts)
6161

6262
apiURL, ok := tfOut["api_url"].(string)
63-
if !ok {
64-
t.Fatalf("api_url should be a non-empty string, but got: %v", tfOut["api_url"])
65-
}
6663
if !ok || apiURL == "" {
6764
t.Fatalf("api_url should be a non-empty string, but got: %v", tfOut["api_url"])
6865
}

tests/acceptance/artifacts_bucket_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ func TestArtifactsBucket(t *testing.T) {
2424
tfOpts := &terraform.Options{
2525
TerraformDir: "../../modules",
2626
}
27-
// Initialize and apply the Terraform configuration
28-
terraform.InitAndApply(t, tfOpts)
29-
defer terraform.Destroy(t, tfOpts)
30-
31-
// Fetch the bucket name from Terraform output
3227
bucketName := terraform.Output(t, tfOpts, "artifacts_bucket_name")
3328

3429
t.Run("should be encrypted by default", func(t *testing.T) {

tests/acceptance/credentials_web_page_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ func TestCredentialsWebPageLoads(t *testing.T) {
1919
TerraformDir: "../../modules",
2020
}
2121

22-
// Ensure Terraform is initialized and applied before reading outputs
23-
terraform.InitAndApply(t, tfOpts)
24-
defer terraform.Destroy(t, tfOpts)
22+
tfOut := terraform.OutputAll(t, tfOpts)
23+
apiURL := tfOut["api_url"].(string)
2524

26-
// Get the specific output value instead of all outputs
27-
apiURL, err := terraform.OutputE(t, tfOpts, "api_url")
28-
assert.NoError(t, err)
29-
assert.NotEmpty(t, apiURL, "api_url should not be empty")
30-
3125
var chainCredentials = credentials.NewChainCredentials([]credentials.Provider{
3226
&credentials.EnvProvider{},
3327
&credentials.SharedCredentialsProvider{Filename: "", Profile: ""},

tests/acceptance/outputs_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ func TestTerraformOutputs(t *testing.T) {
1414
TerraformDir: "../../modules",
1515
}
1616

17-
tfOut, ok := terraform.OutputAll(t, tfOpts).(map[string]interface{})
18-
if !ok {
19-
t.Fatalf("Failed to cast terraform outputs to map[string]interface{}")
20-
}
17+
tfOut := terraform.OutputAll(t, tfOpts)
2118

2219
assert.Regexp(t,
2320
regexp.MustCompile("^Accounts"),

0 commit comments

Comments
 (0)