-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (113 loc) · 3.43 KB
/
tests.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: 'Tests - YAML to Env action'
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'action.yaml'
- '.github/workflows/tests.yaml'
- 'test-values.yaml'
pull_request:
jobs:
test:
strategy:
matrix:
yq-version:
- ''
- 'v4.44.3'
name: 'Test Action (yq: ${{ matrix.yq-version }})'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Execute action
id: y2e
uses: ./
with:
yaml-file: test-values.yaml
mask-values: "true"
yq-version: '${{ matrix.yq-version }}'
- name: Test env
# language=sh
run: |
_EXPECTED_ENVS=(
"STRING"
"hello there"
'${{ env.STRING }}'
"STRING_QUOTED"
"hello there"
'${{ env.STRING_QUOTED }}'
"STRING_INNER_QUOTED"
'hello "there"'
'${{ env.STRING_INNER_QUOTED }}'
"STRING_MULTILINE"
'This is some multiline text
this is pretty cool
the quork brewn facs jammed über teh cndl
'
'${{ env.STRING_MULTILINE }}'
"STRING_MULTILINE_BAR"
'This is some multiline text
this is pretty cool
the quork brewn facs jammed über teh cndl'
'${{ env.STRING_MULTILINE_BAR }}'
"NUMBER"
"5"
'${{ env.NUMBER }}'
"FLOAT"
"5.5"
'${{ env.FLOAT }}'
"OBJECT_KEY1"
"value1"
'${{ env.OBJECT_KEY1 }}'
"OBJECT_KEY2"
"2"
'${{ env.OBJECT_KEY2 }}'
"OBJECT_KEY3_0"
"nested value 1"
'${{ env.OBJECT_KEY3_0 }}'
"OBJECT_KEY3_1"
"nested value 2"
'${{ env.OBJECT_KEY3_1 }}'
"OBJECT_KEY3_2"
'nested value "3"'
'${{ env.OBJECT_KEY3_2 }}'
"ARRAY_0"
"one"
'${{ env.ARRAY_0 }}'
"ARRAY_1"
"two"
'${{ env.ARRAY_1 }}'
"ARRAY_2_0"
"nested one"
'${{ env.ARRAY_2_0 }}'
"STRING_WITH_EQUALS"
'value = yep'
'${{ env.STRING_WITH_EQUALS }}'
"STRING_MULTILINE_WITH_EQUALS"
'value
=
yep
'
'${{ env.STRING_MULTILINE_WITH_EQUALS }}'
'HYPHENATED_KEY'
"hi there."
'${{ env.HYPHENATED_KEY }}'
'SECOND_HYPHENATED_KEY'
'hi there.'
'${{ env.SECOND_HYPHENATED_KEY }}'
'KEY_WITH__WEIRD___'
'what have you got.'
'${{ env.KEY_WITH__WEIRD___ }}'
)
for (( i=0; i < "${#_EXPECTED_ENVS[@]}"; i+=3 )); do
_env="${_EXPECTED_ENVS[$i]}"
_exp="${_EXPECTED_ENVS[$i+1]}"
_act="${_EXPECTED_ENVS[$i+2]}"
if [[ "${_act}" != "${_exp}" ]]; then
echo "Environment variable \"${_env}\" value mismatch:"
echo " Expected: \"${_exp}\""
echo " Actual: \"${_act}\""
exit 1
fi
done