-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (93 loc) · 3.35 KB
/
e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: E2E Test
on:
push:
branches:
- master
pull_request:
permissions:
checks: write
jobs:
test:
name: e2e
runs-on: ubuntu-latest
env:
tf_organization: takescoop-oss
tf_working_directory: test-e2e/
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Generate workspace name
id: workspace-name
run: echo "::set-output name=result::${{ github.event.repository.name }}-e2e-${{ github.run_id }}"
- name: Create workspace
id: workspace
uses: TakeScoop/terraform-cloud-workspace-action@v2
with:
terraform_organization: ${{ env.tf_organization }}
terraform_token: ${{ secrets.TF_TOKEN_OSS }}
name: ${{ steps.workspace-name.outputs.result }}
apply: true
execution_mode: local
- uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_TOKEN_OSS }}
- run: |-
cat << EOF > ${{ env.tf_working_directory }}backend.tf.json
{
"terraform": {
"backend": {
"remote": {
"organization": "${{ env.tf_organization }}",
"workspaces": {
"name": "${{ steps.workspace-name.outputs.result }}"
}
}
}
}
}
EOF
- name: Terraform init
run: terraform -chdir=${{ env.tf_working_directory }} init
- name: Terraform apply
run: terraform -chdir=${{ env.tf_working_directory }} apply -auto-approve
- name: Run action
id: action
uses: ./
with:
workspace: ${{ steps.workspace-name.outputs.result }}
organization: ${{ env.tf_organization }}
token: ${{ secrets.TF_TOKEN_OSS }}
- name: Test string
run: test "${{ steps.action.outputs.foo }}" == "bar"
- name: Test JSON output
run: test "${{ fromJson(steps.action.outputs.json).foo }}" == "bar"
- name: Test sensitive output
run: test "${{ steps.action.outputs.sensitive }}" == "secret"
- name: Test int
run: test ${{ steps.action.outputs.int }} == 2
- name: Test float
run: test ${{ steps.action.outputs.float }} == 3.14
- name: Test map
run: test "${{ fromJson(steps.action.outputs.map).foo.bar }}" == "baz"
- name: Test list
run: test "${{ fromJson(steps.action.outputs.list)[0] }}" == "foo"
- name: Test set
run: |
test '${{ steps.action.outputs.set }}' == '["foo","bar"]' ||
test '${{ steps.action.outputs.set }}' == '["bar","foo"]'
- name: Test null
run: test "${{ steps.action.outputs.null }}" == ""
- name: Test multiline output
env:
multiline: "${{ steps.action.outputs.multiline }}"
run: test "$multiline" == "$(printf "%s\n" "multi" "line" "output")"
- name: Cleanup workspace
if: always()
env:
TOKEN: ${{ secrets.TF_TOKEN_OSS }}
run: |-
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
https://app.terraform.io/api/v2/organizations/${{ env.tf_organization }}/workspaces/${{ steps.workspace-name.outputs.result }}