-
Notifications
You must be signed in to change notification settings - Fork 74
205 lines (181 loc) · 4.25 KB
/
test-pr.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: 'Test Action (Pull Requests)'
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- 'releases/*'
jobs:
build: # make sure build/ci work properly
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: |
yarn set version berry
yarn install --frozen-lockfile
- run: |
yarn run all
test-clean: # make sure the action works on a clean machine without building
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Test filename
uses: ./
with:
envkey_DEBUG: false
file_name: .other-file
- name: Verify envfile
shell: bash
run: |
TEST=$(cat <<-END
DEBUG=false
END
)
if [ "$TEST" != "$(cat .other-file)" ]
then
echo "Actual:"
cat .other-file
echo "Expected:"
echo "$TEST"
exit 1
fi
- name: Cleanup
shell: bash
run: |
rm .other-file
- name: Test relative path above
uses: ./
with:
envkey_DEBUG: false
directory: ../
- name: Verify envfile
shell: bash
run: |
TEST=$(cat <<-END
DEBUG=false
END
)
if [ "$TEST" != "$(cat ../.env)" ]
then
echo "Actual:"
cat ../.env
echo "Expected:"
echo "$TEST"
exit 1
fi
- name: Cleanup
shell: bash
run: |
rm ../.env
- name: Create folder
shell: bash
run: |
mkdir -p subdir
- name: Test relative path subdirectory 1
uses: ./
with:
envkey_DEBUG: false
directory: subdir
- name: Verify envfile
shell: bash
run: |
TEST=$(cat <<-END
DEBUG=false
END
)
if [ "$TEST" != "$(cat subdir/.env)" ]
then
echo "Actual:"
cat subdir/.env
echo "Expected:"
echo "$TEST"
exit 1
fi
- name: Cleanup
shell: bash
run: |
rm -rf subdir
- name: Test empty envkey default option
uses: ./
with:
envkey_SECRET_KEY: ''
- name: Verify envfile
shell: bash
run: |
TEST=$(cat <<-END
SECRET_KEY=
END
)
if [ "$TEST" != "$(cat .env)" ]
then
echo "Actual:"
cat .env
echo "Expected:"
echo "$TEST"
exit 1
fi
- name: Cleanup
shell: bash
run: |
rm .env
- name: Test sorted envkeys works
uses: ./
with:
envkey_C: 'C'
envkey_A: 'A'
envkey_B: 'B'
sort_keys: true
- name: Verify envfile
shell: bash
run: |
TEST=$(cat <<-END
A=A
B=B
C=C
END
)
if [ "$TEST" != "$(cat .env)" ]
then
echo "Actual:"
cat .env
echo "Expected:"
echo "$TEST"
exit 1
fi
- name: Cleanup
shell: bash
run: |
rm .env
- name: Test should fail absolute path
uses: ./
with:
envkey_DEBUG: false
directory: /home
continue-on-error: true
- name: Test should fail bad secret
uses: ./
with:
fail_on_empty: true
envkey_SECRET_KEY: ${{ secrets.NON_EXISTENT_SECRET }}
continue-on-error: true
- name: Test should fail empty envkey
uses: ./
id: make_envfile
with:
envkey_SECRET_KEY: ''
fail_on_empty: true
continue-on-error: true