-
-
Notifications
You must be signed in to change notification settings - Fork 160
116 lines (96 loc) · 4.04 KB
/
test-output.yaml
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
name: Test terraform-output
on:
- pull_request
permissions:
contents: read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
terraform-output:
runs-on: ubuntu-24.04
name: verify outputs
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Get outputs
uses: ./terraform-output
id: terraform-output
with:
path: tests/workflows/test-output
- name: Verify outputs
env:
MY_NUMBER: ${{ steps.terraform-output.outputs.my_number }}
MY_SENSITIVE_NUMBER: ${{ steps.terraform-output.outputs.my_sensitive_number }}
MY_STRING: ${{ steps.terraform-output.outputs.my_string }}
MY_SENSITIVE_STRING: ${{ steps.terraform-output.outputs.my_sensitive_string }}
MY_MULTILINE_STRING: ${{ steps.terraform-output.outputs.my_multiline_string }}
MY_SENSITIVE_MULTILINE_STRING: ${{ steps.terraform-output.outputs.my_sensitive_multiline_string }}
MY_BOOL: ${{ steps.terraform-output.outputs.my_bool }}
MY_SENSITIVE_BOOL: ${{ steps.terraform-output.outputs.my_sensitive_bool }}
AWKWARD_STRING: ${{ steps.terraform-output.outputs.awkward_string }}
AWKWARD_OBJ: ${{ join(fromJson(steps.terraform-output.outputs.awkward_compound_output).nested.thevalue) }}
MY_OBJECT_FIRST: ${{ fromJson(steps.terraform-output.outputs.my_object).first }}
MY_TUPLE: ${{ join(fromJson(steps.terraform-output.outputs.my_tuple)) }}
MY_SET: ${{ contains(fromJson(steps.terraform-output.outputs.my_set), 'one') }}
run: |
if [[ "$MY_NUMBER" != "5" ]]; then
echo "::error:: output my_number not set correctly"
exit 1
fi
if [[ "$MY_SENSITIVE_NUMBER" != "6" ]]; then
echo "::error:: output my_sensitive_number not set correctly"
exit 1
fi
if [[ "$MY_STRING" != "hello" ]]; then
echo "::error:: output my_string not set correctly"
exit 1
fi
if [[ "$MY_SENSITIVE_STRING" != "password" ]]; then
echo "::error:: output my_sensitive_string not set correctly"
exit 1
fi
if [[ "$MY_BOOL" != "true" ]]; then
echo "::error:: output my_bool not set correctly"
exit 1
fi
if [[ "$MY_SENSITIVE_BOOL" != "false" ]]; then
echo "::error:: output my_number not set correctly"
exit 1
fi
if [[ "$MY_OBJECT_FIRST" != "one" ]]; then
echo "::error:: fromJson(my_object).first not set correctly"
exit 1
fi
if [[ "$MY_TUPLE" != "one,two" ]]; then
echo "::error:: join(fromJson(my_set)) not set correctly"
exit 1
fi
if [[ "$MY_SET" != "true" ]]; then
echo "::error:: contains(fromJson(my_set)) not set correctly"
exit 1
fi
if [[ "$AWKWARD_STRING" != "hello \"there\", here are some 'quotes'." ]]; then
echo "::error:: awkward_string not set correctly"
exit 1
fi
if [[ "$AWKWARD_OBJ" != "hello \"there\", here are some 'quotes'." ]]; then
echo "::error:: fromJson(awkward_compound_output).nested.thevalue not set correctly"
exit 1
fi
expected_sensitive_multiline="qowicznobnad
trewptonopce
zxicvbnoberg"
if [[ "$expected_sensitive_multiline" != "$MY_SENSITIVE_MULTILINE_STRING" ]]; then
echo "::error:: steps.terraform-output.outputs.my_sensitive_multiline_string not set correctly"
exit 1
fi
expected_multiline="mcnbcvnxdgjt
iyriuytifdcv
pydrtdxfgcvj"
if [[ "$expected_multiline" != "$MY_MULTILINE_STRING" ]]; then
echo "::error:: steps.terraform-output.outputs.my_multiline_string not set correctly"
exit 1
fi