This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
131 lines (107 loc) · 4.79 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: E2E Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]
jobs:
test:
runs-on: ubuntu-latest
env:
LF_TELEMETRY_DISABLED: "1"
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.6
terraform_wrapper: false
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
- run: go install .
- name: layerform config set-context
run: |
# validations, fails if command succeeds
! layerform config set-context test -t local # missing --dir
! layerform config set-context test -t s3 --bucket bucket # missing region
! layerform config set-context test -t s3 --region region # missing bucket
! layerform config set-context test -t cloud --url "invalid url" --email [email protected] --password strongpass
! layerform config set-context test -t cloud --url https://a.b.com --email invalid --password strongpass
! layerform config set-context test -t cloud --email invalid --password strongpass # missing url
! layerform config set-context test -t cloud --url https://a.b.com --password strongpass # missing email
! layerform config set-context test -t cloud --url https://a.b.com --email [email protected] # missing password
# set valid contexts
layerform config set-context test-s3 -t s3 --bucket bucket --region us-east-1
layerform config set-context test-cloud -t cloud --url https://demo.layerform.dev --email [email protected] --password strongpass
layerform config set-context test-local -t local --dir test
- name: layerform config use-context
run: |
# fails if command succeeds
! layerform config use-context test-does-not-exist # context does not exist
# switch context to test-local
layerform config use-context test-local
layerfrom get-contexts | tee usecontext
grep -E '^\*\s+test-local' usecontext
!grep -E '^\*\s+test-s3' usecontext
# switch context to test-s3
layerform config use-context test-s3
layerfrom get-contexts | tee usecontext
!grep -E '^\*\s+test-local' usecontext
grep -E '^\*\s+test-s3' usecontext
- name: Configure
run: |
layerform configure --file examples/local/layerform.json
- name: List definitions
run: |
layerform list definitions | tee definitions
grep -E 'foo' definitions
grep -E 'bar\s+foo' definitions
grep -E 'baz\s+foo' definitions
- name: List instances
run: |
layerform list instances | tee instances
grep 'No layer instances spawned' instances
- name: Spawn instances
run: |`
layerform spawn bar test_bar
layerform spawn baz test_baz
layerform spawn bar test_custom_foo --base foo=custom
layerform list instances | tee instances
grep -E 'default\s+foo\s+alive' instances
grep -E 'test_bar\s+bar\s+foo=default\s+alive' instances
grep -E 'test_baz\s+baz\s+foo=default\s+alive' instances
grep -E 'custom\s+foo\s+alive' instances
grep -E 'test_custom_foo\s+bar\s+foo=custom\s+alive' instances
- name: Output
run: |
layerform output bar test_bar | jq .bar_file.value | tee output
grep -E '\.layerform\/examples\/local\/foo-default\/bar-test_bar\.txt' output
layerform output bar test_bar | jq .foo_file.value | tee output
grep -E '\.layerform\/examples\/local\/foo-default\/\.keep' output
- name: Refresh
run: |
layerform refresh bar test_bar --var prefix=test-prefix-
layerform output bar test_bar | jq .bar_file.value | tee output
grep -E '\.layerform\/examples\/local\/test-prefix-foo-default\/bar-test_bar\.txt' output
layerform refresh bar test_bar
- name: Can't kill instance that has dependants
run: |
# fails if kill succeeds
! layerform kill foo default
- name: Kill instance
run: |
yes yes | layerform kill bar test_bar
layerform list instances | tee instances
# fails if instance is still there
! grep -E 'test_bar\s+bar\s+foo=default\s+alive' instances
- name: Can't spawn instance with invalid name
run: |
# fails if spawn succeeds
! layerform spawn foo 'this has spaces'
! layerform spawn foo 'this#has%special&chars'
! layerform spawn foo '_cant-start-with-underscore'
! layerform spawn foo 'cant-end-with-underscore_'
! layerform spawn foo 'cant-end-with-dash-'