@@ -81,6 +81,23 @@ inputs:
81
81
description : " Bats-file: clean temp files"
82
82
required : false
83
83
default : true
84
+ outputs :
85
+ bats-installed :
86
+ description : " True/False if bats has been installed"
87
+ value : ${{ (steps.bats-install.outputs.bats-installed != '') }}
88
+ support-installed :
89
+ description : " True/False if bats-support has been installed"
90
+ value : ${{ (steps.support-install.outputs.support-installed != '') }}
91
+ assert-installed :
92
+ description : " True/False if bats-assert has been installed"
93
+ value : ${{ (steps.assert-install.outputs.assert-installed != '') }}
94
+ detik-installed :
95
+ description : " True/False if bats-detik has been installed"
96
+ value : ${{ (steps.detik-install.outputs.detik-installed != '') }}
97
+ file-installed :
98
+ description : " True/False if bats-file has been installed"
99
+ value : ${{ (steps.file-install.outputs.file-installed != '') }}
100
+
84
101
runs :
85
102
using : composite
86
103
steps :
@@ -93,12 +110,14 @@ runs:
93
110
path : |
94
111
~/.local/share/bats
95
112
~/.local/bin/bats
96
- key : ${{ runner.os }}-bats
113
+ key : ${{ runner.os }}-bats-${{ inputs.bats-version }}
114
+
97
115
- name : " Download and install Bats"
98
116
if : inputs.bats-install == 'true' && steps.bats-cache.outputs.cache-hit != 'true'
117
+ id : bats-install
99
118
shell : bash
100
119
run : |
101
- # In $HOME to avoid sudo requirements that eventually will be removed for the library as well
120
+ # In $HOME to avoid sudo requirements
102
121
VERSION=${{ inputs.bats-version }}
103
122
DESTDIR="$HOME/.local/bin"
104
123
LIBDIR="$HOME/.local/share/bats"
@@ -131,12 +150,21 @@ runs:
131
150
install -Dm755 lib/bats-core/* -t "${LIBDIR}"
132
151
133
152
echo "Bats v$VERSION installed in $DESTDIR"
153
+ echo "$DESTDIR" >> "$GITHUB_PATH"
154
+ echo "bats-installed=true" >> $GITHUB_OUTPUT
134
155
rm -rf ${TEMPDIR} || exit 0
135
156
136
- echo "$DESTDIR" >> "$GITHUB_PATH"
157
+ - name : " Set cache for Bats-support"
158
+ uses : actions/cache@v3
159
+ if : inputs.support-install == 'true'
160
+ id : support-cache
161
+ with :
162
+ path : ${{ inputs.support-path }}
163
+ key : ${{ runner.os }}-bats-support-${{ inputs.support-version }}
137
164
138
165
- name : " Download and install Bats-support"
139
- if : inputs.support-install == 'true'
166
+ if : inputs.support-install == 'true' && steps.support-cache.outputs.cache-hit != 'true'
167
+ id : support-install
140
168
shell : bash
141
169
run : |
142
170
VERSION=${{ inputs.support-version }}
@@ -145,19 +173,31 @@ runs:
145
173
url="https://github.com/bats-core/bats-support/archive/refs/tags/v${VERSION}.tar.gz"
146
174
147
175
mkdir -p ${TEMPDIR}
148
- sudo mkdir -p ${DESTDIR}/src/
176
+ [[ "${DESTDIR}" == "$HOME"* ]] && CMD="" || CMD="sudo"
177
+ ${CMD} mkdir -p ${DESTDIR}/src/
149
178
curl -sL ${url} | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
150
- # Archlinux style, except that we are not in a fakeroot env so we need to use sudo
151
- sudo install -Dm755 load.bash ${DESTDIR}/load.bash
179
+ # Archlinux style, except that we are not in a fakeroot env
180
+ ${CMD} install -Dm755 load.bash ${DESTDIR}/load.bash
152
181
for fn in src/*.bash; do
153
- sudo install -Dm755 $fn \
182
+ ${CMD} install -Dm755 $fn \
154
183
${DESTDIR}/src/$(basename $fn)
155
184
done
156
185
echo "Bats Support v$VERSION installed in $DESTDIR"
186
+ echo "support-installed=true" >> $GITHUB_OUTPUT
157
187
# Cleanup bats-support if required
158
188
[[ "${{ inputs.support-clean }}" = "true" ]] && rm -rf ${TEMPDIR} || exit 0
159
- - name : " Download and install Bats-assert"
189
+
190
+ - name : " Set cache for Bats-assert"
191
+ uses : actions/cache@v3
160
192
if : inputs.assert-install == 'true'
193
+ id : assert-cache
194
+ with :
195
+ path : ${{ inputs.assert-path }}
196
+ key : ${{ runner.os }}-bats-assert-${{ inputs.assert-version }}
197
+
198
+ - name : " Download and install Bats-assert"
199
+ if : inputs.assert-install == 'true' && steps.assert-cache.outputs.cache-hit != 'true'
200
+ id : assert-install
161
201
shell : bash
162
202
run : |
163
203
VERSION=${{ inputs.assert-version }}
@@ -166,19 +206,31 @@ runs:
166
206
url="https://github.com/bats-core/bats-assert/archive/refs/tags/v${VERSION}.tar.gz"
167
207
168
208
mkdir -p ${TEMPDIR}
169
- sudo mkdir -p ${DESTDIR}/src/
209
+ [[ "${DESTDIR}" == "$HOME"* ]] && CMD="" || CMD="sudo"
210
+ ${CMD} mkdir -p ${DESTDIR}/src/
170
211
curl -sL ${url} | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
171
- # Archlinux style, except that we are not in a fakeroot env so we need to use sudo
172
- sudo install -Dm755 load.bash ${DESTDIR}/load.bash
212
+ # Archlinux style, except that we are not in a fakeroot env
213
+ ${CMD} install -Dm755 load.bash ${DESTDIR}/load.bash
173
214
for fn in src/*.bash; do
174
- sudo install -Dm755 $fn \
215
+ ${CMD} install -Dm755 $fn \
175
216
${DESTDIR}/src/$(basename $fn)
176
217
done
177
218
echo "Bats Assert v$VERSION installed in $DESTDIR"
219
+ echo "assert-installed=true" >> "$GITHUB_OUTPUT"
178
220
# Cleanup bats-support if required
179
221
[[ "${{ inputs.assert-clean }}" = "true" ]] && rm -rf ${TEMPDIR} || exit 0
180
- - name : " Download and install Bats-detik"
222
+
223
+ - name : " Set cache for Bats-detik"
224
+ uses : actions/cache@v3
181
225
if : inputs.detik-install == 'true'
226
+ id : detik-cache
227
+ with :
228
+ path : ${{ inputs.detik-path }}
229
+ key : ${{ runner.os }}-bats-detik-${{ inputs.detik-version }}
230
+
231
+ - name : " Download and install Bats-detik"
232
+ if : inputs.detik-install == 'true' && steps.detik-cache.outputs.cache-hit != 'true'
233
+ id : detik-install
182
234
shell : bash
183
235
run : |
184
236
VERSION=${{ inputs.detik-version }}
@@ -187,18 +239,30 @@ runs:
187
239
url="https://github.com/bats-core/bats-detik/archive/refs/tags/v${VERSION}.tar.gz"
188
240
189
241
mkdir -p ${TEMPDIR}
190
- sudo mkdir -p ${DESTDIR}/src/
242
+ [[ "${DESTDIR}" == "$HOME"* ]] && CMD="" || CMD="sudo"
243
+ ${CMD} mkdir -p ${DESTDIR}/src/
191
244
curl -sL ${url} | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
192
245
# Archlinux style, except that we are not in a fakeroot env so we need to use sudo
193
246
for fn in lib/*.bash; do
194
- sudo install -Dm755 $fn \
247
+ ${CMD} install -Dm755 $fn \
195
248
${DESTDIR}/$(basename $fn)
196
249
done
197
250
echo "Bats Detik v$VERSION installed in $DESTDIR"
251
+ echo "detik-installed=true" >> "$GITHUB_OUTPUT"
198
252
# Cleanup bats-support if required
199
253
[[ "${{ inputs.detik-clean }}" = "true" ]] && rm -rf ${TEMPDIR} || exit 0
200
- - name : " Download and install Bats-file"
254
+
255
+ - name : " Set cache for Bats-file"
256
+ uses : actions/cache@v3
201
257
if : inputs.file-install == 'true'
258
+ id : file-cache
259
+ with :
260
+ path : ${{ inputs.file-path }}
261
+ key : ${{ runner.os }}-bats-file-${{ inputs.file-version }}
262
+
263
+ - name : " Download and install Bats-file"
264
+ if : inputs.file-install == 'true' && steps.file-cache.outputs.cache-hit != 'true'
265
+ id : file-install
202
266
shell : bash
203
267
run : |
204
268
VERSION=${{ inputs.file-version }}
@@ -207,14 +271,26 @@ runs:
207
271
url="https://github.com/bats-core/bats-file/archive/refs/tags/v${VERSION}.tar.gz"
208
272
209
273
mkdir -p ${TEMPDIR}
210
- sudo mkdir -p ${DESTDIR}/src/
274
+ [[ "${DESTDIR}" == "$HOME"* ]] && CMD="" || CMD="sudo"
275
+ ${CMD} mkdir -p ${DESTDIR}/src/
211
276
curl -sL ${url} | tar xz -C ${TEMPDIR} --strip-components 1 && cd ${TEMPDIR}
212
- # Archlinux style, except that we are not in a fakeroot env so we need to use sudo
213
- sudo install -Dm755 load.bash ${DESTDIR}/load.bash
277
+ # Archlinux style, except that we are not in a fakeroot env
278
+ ${CMD} install -Dm755 load.bash ${DESTDIR}/load.bash
214
279
for fn in src/*.bash; do
215
- sudo install -Dm755 $fn \
280
+ ${CMD} install -Dm755 $fn \
216
281
${DESTDIR}/src/$(basename $fn)
217
282
done
218
283
echo "Bats File v$VERSION installed in $DESTDIR"
284
+ echo "file-installed=true" >> "$GITHUB_OUTPUT"
219
285
# Cleanup bats-support if required
220
286
[[ "${{ inputs.file-clean }}" = "true" ]] && rm -rf ${TEMPDIR} || exit 0
287
+
288
+ - name : " Debug print if installed"
289
+ if : runner.debug == '1'
290
+ shell : bash
291
+ run : |
292
+ echo "Bats installed: ${{ (steps.bats-install.outputs.bats-installed != '') }}"
293
+ echo "Support installed: ${{ (steps.support-install.outputs.support-installed != '') }}"
294
+ echo "Assert installed: ${{ (steps.assert-install.outputs.assert-installed != '') }}"
295
+ echo "Detik installed: ${{ (steps.detik-install.outputs.detik-installed != '') }}"
296
+ echo "File installed: ${{ (steps.file-install.outputs.file-installed != '') }}"
0 commit comments