-
-
Notifications
You must be signed in to change notification settings - Fork 160
116 lines (93 loc) · 4.4 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
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-latest
name: verify outputs
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get outputs
uses: ./terraform-output
id: terraform-output
with:
path: tests/workflows/test-output
- name: Print the outputs
run: |
echo "my_number = ${{ steps.terraform-output.outputs.my_number }}"
echo "my_sensitive_number = ${{ steps.terraform-output.outputs.my_sensitive_number }}"
echo "my_string = ${{ steps.terraform-output.outputs.my_string }}"
echo "my_sensitive_string = ${{ steps.terraform-output.outputs.my_sensitive_string }}"
echo "my_multiline_string = ${{ steps.terraform-output.outputs.my_multiline_string }}"
echo "my_sensitive_multiline_string = ${{ steps.terraform-output.outputs.my_sensitive_multiline_string }}"
echo "my_bool = ${{ steps.terraform-output.outputs.my_bool }}"
echo "my_sensitive_bool = ${{ steps.terraform-output.outputs.my_sensitive_bool }}"
- name: Verify outputs
env:
AWKWARD_STRING: ${{ steps.terraform-output.outputs.awkward_string }}
AWKWARD_OBJ: ${{ join(fromJson(steps.terraform-output.outputs.awkward_compound_output).nested.thevalue) }}
run: |
if [[ "${{ steps.terraform-output.outputs.my_number }}" != "5" ]]; then
echo "::error:: output my_number not set correctly"
exit 1
fi
if [[ "${{ steps.terraform-output.outputs.my_sensitive_number }}" != "6" ]]; then
echo "::error:: output my_sensitive_number not set correctly"
exit 1
fi
if [[ "${{ steps.terraform-output.outputs.my_string }}" != "hello" ]]; then
echo "::error:: output my_string not set correctly"
exit 1
fi
if [[ "${{ steps.terraform-output.outputs.my_sensitive_string }}" != "password" ]]; then
echo "::error:: output my_sensitive_string not set correctly"
exit 1
fi
if [[ "${{ steps.terraform-output.outputs.my_bool }}" != "true" ]]; then
echo "::error:: output my_bool not set correctly"
exit 1
fi
if [[ "${{ steps.terraform-output.outputs.my_sensitive_bool }}" != "false" ]]; then
echo "::error:: output my_number not set correctly"
exit 1
fi
if [[ "${{ fromJson(steps.terraform-output.outputs.my_object).first }}" != "one" ]]; then
echo "::error:: fromJson(my_object).first not set correctly"
exit 1
fi
if [[ "${{ join(fromJson(steps.terraform-output.outputs.my_tuple)) }}" != "one,two" ]]; then
echo "::error:: join(fromJson(my_set)) not set correctly"
exit 1
fi
if [[ "${{ contains(fromJson(steps.terraform-output.outputs.my_set), 'one') }}" != "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"
actual_sensitive_multiline="${{ steps.terraform-output.outputs.my_sensitive_multiline_string }}"
if [[ "$expected_sensitive_multiline" != "$actual_sensitive_multiline" ]]; then
echo "::error:: steps.terraform-output.outputs.my_sensitive_multiline_string not set correctly"
exit 1
fi
expected_multiline="mcnbcvnxdgjt
iyriuytifdcv
pydrtdxfgcvj"
actual_multiline="${{ steps.terraform-output.outputs.my_multiline_string }}"
if [[ "$expected_multiline" != "$actual_multiline" ]]; then
echo "::error:: steps.terraform-output.outputs.my_multiline_string not set correctly"
exit 1
fi