Skip to content

Commit 76373be

Browse files
committed
more if: in PDLPorters ci-dist
1 parent f7448b6 commit 76373be

File tree

1 file changed

+64
-109
lines changed

1 file changed

+64
-109
lines changed

github-actions/ci-dist/action.yml

Lines changed: 64 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -179,54 +179,40 @@ runs:
179179
# Shared step for setting up graphical display.
180180
- name: Set up graphical display (via apt-get)
181181
shell: bash
182-
if: runner.os == 'Linux' && (fromJSON(inputs.build-enable-graphical-display || 'false') || fromJSON(inputs.test-enable-graphical-display || 'false'))
182+
if: runner.os == 'Linux' && (fromJSON(inputs.build-enable-graphical-display) || fromJSON(inputs.test-enable-graphical-display))
183183
run: |
184184
sudo apt-get install --no-install-recommends -y xvfb
185185
mkdir /tmp/runtime-runner && chmod 0700 /tmp/runtime-runner
186186
echo "XDG_RUNTIME_DIR=/tmp/runtime-runner" >> $GITHUB_ENV
187-
if ${{ fromJSON(inputs.build-enable-graphical-display || 'false') }}; then
187+
if ${{ fromJSON(inputs.build-enable-graphical-display) }}; then
188188
echo "BUILD_RUNNER_PREFIX=xvfb-run -a" >> $GITHUB_ENV
189189
fi
190-
if ${{ fromJSON(inputs.test-enable-graphical-display || 'false') }}; then
190+
if ${{ fromJSON(inputs.test-enable-graphical-display) }}; then
191191
echo "TEST_RUNNER_PREFIX=xvfb-run -a" >> $GITHUB_ENV
192192
fi
193193
# Target: target-setup-perl
194194
- name: target-setup-perl (actions-setup-perl)
195195
shell: bash
196+
if: fromJSON(inputs.target-all) || fromJSON(inputs.target-setup-perl)
196197
run: |
197-
if ${{ toJSON(
198-
( fromJSON(inputs.target-all)
199-
|| fromJSON(inputs.target-setup-perl)
200-
)
201-
) }}; then
202-
echo "::group::setup-perl (actions-setup-perl)"
203-
git clone \
204-
https://github.com/shogo82148/actions-setup-perl.git \
205-
-b v1 \
206-
.github/actions/actions-setup-perl;
207-
node .github/actions/actions-setup-perl/dist/setup/index.js
208-
echo "::endgroup::"
209-
fi
198+
git clone \
199+
https://github.com/shogo82148/actions-setup-perl.git \
200+
-b v1 \
201+
.github/actions/actions-setup-perl;
202+
node .github/actions/actions-setup-perl/dist/setup/index.js
210203
env:
211204
INPUT_DISTRIBUTION: ${{ inputs.perl-distribution }}
212205
INPUT_PERL-VERSION: ${{ inputs.perl-version }}
213206
INPUT_MULTI-THREAD: ${{ inputs.perl-threaded }}
214207
INPUT_ENABLE-MODULES-CACHE: false
215208
- name: target-setup-perl (perl -V)
216209
shell: bash
210+
if: fromJSON(inputs.target-all) || fromJSON(inputs.target-setup-perl)
217211
run: |
218-
if ${{ toJSON(
219-
( fromJSON(inputs.target-all)
220-
|| fromJSON(inputs.target-setup-perl)
221-
)
222-
) }}; then
223-
echo "::group::setup-perl (perl -V)"
224-
export MYPERL=$(which -a perl | grep -m 1 hostedtoolcache)
225-
echo "MYPERL=$MYPERL" >> $GITHUB_ENV
226-
$MYPERL -V
227-
$MYPERL -MDigest::MD5=md5_hex -e 'print "GHA_CACHE_PERL_V_HASH=", md5_hex(`$^X -V`), "\n"' >> $GITHUB_ENV
228-
echo "::endgroup::"
229-
fi
212+
export MYPERL=$(which -a perl | grep -m 1 hostedtoolcache)
213+
echo "MYPERL=$MYPERL" >> $GITHUB_ENV
214+
$MYPERL -V
215+
$MYPERL -MDigest::MD5=md5_hex -e 'print "GHA_CACHE_PERL_V_HASH=", md5_hex(`$^X -V`), "\n"' >> $GITHUB_ENV
230216
- name: target-setup-perl (cache ~/perl5)
231217
if: |
232218
fromJSON(inputs.perl-deps-enable-cache)
@@ -241,118 +227,87 @@ runs:
241227
- name: target-setup-perl (ccache)
242228
# ccache support on Windows is not well-tested
243229
if: |
244-
fromJSON(inputs.ccache-enable-cache)
245-
&&
246-
( fromJSON(inputs.target-all)
247-
|| fromJSON(inputs.target-setup-perl)
248-
)
249-
&&
250-
(
251-
runner.os != 'Windows'
252-
)
230+
runner.os != 'Windows' &&
231+
fromJSON(inputs.ccache-enable-cache) &&
232+
( fromJSON(inputs.target-all) ||
233+
fromJSON(inputs.target-setup-perl)
234+
)
253235
uses: Chocobo1/setup-ccache-action@v1
254236
with:
255237
override_cache_key: ccache-v0.${{ inputs.ccache-cache-version }}-${{ runner.os }}-${{ env.GHA_CACHE_PERL_V_HASH }}
256238
- name: target-setup-perl (setup local::lib)
257239
shell: bash
240+
if: fromJSON(inputs.target-all) || fromJSON(inputs.target-setup-perl)
258241
run: |
259-
if ${{ toJSON(
260-
( fromJSON(inputs.target-all)
261-
|| fromJSON(inputs.target-setup-perl)
262-
)
263-
) }}; then
264-
echo "::group::setup-perl (setup local::lib)"
265-
# older Perls need this upgrade
266-
$MYPERL -S cpanm -n --local-lib=~/perl5 ExtUtils::MakeMaker || ( cat ~/.cpanm/build.log && false )
267-
$MYPERL -S cpanm -n --local-lib=~/perl5 local::lib || ( cat ~/.cpanm/build.log && false )
268-
LOCALLIB_VARS="$($MYPERL -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,bourne )"
269-
eval $( echo "$LOCALLIB_VARS" | $MYPERL -MFile::Spec -pne '
270-
$_ = "" if /^PATH=/;
271-
s/; export.*$/;/;
272-
s/^[^=]+=/echo -n "$&"; echo /;
273-
my $sep = File::Spec->catfile("", "");
274-
s,/perl5,${sep}perl5,g;' ) >> $GITHUB_ENV
275-
if ${{ toJSON( runner.os == 'Windows' ) }}; then
276-
pwsh -c 'echo "'$( cygpath -w $( realpath ~/perl5/bin ) )'" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append'
277-
else
278-
echo "$HOME/perl5/bin" >> $GITHUB_PATH
279-
fi
280-
echo "PERL_CPANM_OPT=-l ~/perl5" >> $GITHUB_ENV
281-
echo "::endgroup::"
282-
fi
242+
# older Perls need this upgrade
243+
$MYPERL -S cpanm -n --local-lib=~/perl5 ExtUtils::MakeMaker || ( cat ~/.cpanm/build.log && false )
244+
$MYPERL -S cpanm -n --local-lib=~/perl5 local::lib || ( cat ~/.cpanm/build.log && false )
245+
LOCALLIB_VARS="$($MYPERL -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,bourne )"
246+
eval $( echo "$LOCALLIB_VARS" | $MYPERL -MFile::Spec -pne '
247+
$_ = "" if /^PATH=/;
248+
s/; export.*$/;/;
249+
s/^[^=]+=/echo -n "$&"; echo /;
250+
my $sep = File::Spec->catfile("", "");
251+
s,/perl5,${sep}perl5,g;' ) >> $GITHUB_ENV
252+
if ${{ toJSON( runner.os == 'Windows' ) }}; then
253+
pwsh -c 'echo "'$( cygpath -w $( realpath ~/perl5/bin ) )'" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append'
254+
else
255+
echo "$HOME/perl5/bin" >> $GITHUB_PATH
256+
fi
257+
echo "PERL_CPANM_OPT=-l ~/perl5" >> $GITHUB_ENV
283258
# Target: target-install-dist-perl-deps
284259
- name: target-install-dist-perl-deps (via cpanm)
285260
shell: bash
261+
if: fromJSON(inputs.target-all) || fromJSON(inputs.target-install-dist-perl-deps)
286262
run: |
287-
if ${{ toJSON(
288-
( fromJSON(inputs.target-all)
289-
|| fromJSON(inputs.target-install-dist-perl-deps)
290-
)
291-
) }}; then
292-
echo "::group::install-dist-perl-deps (via cpanm)"
293-
cd ${{ inputs.path }}
294-
if [ -n "${{ inputs.dist-perl-deps-configure }}" ]; then
295-
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm --dev -n ${{ inputs.dist-perl-deps-configure }} || ( cat ~/.cpanm/build.log && false )
296-
fi
297-
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n --installdeps --dev . || ( cat ~/.cpanm/build.log && false )
298-
echo "::endgroup::"
299-
fi
263+
cd ${{ inputs.path }}
264+
if [ -n "${{ inputs.dist-perl-deps-configure }}" ]; then
265+
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm --dev -n ${{ inputs.dist-perl-deps-configure }} || ( cat ~/.cpanm/build.log && false )
266+
fi
267+
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n --installdeps --dev . || ( cat ~/.cpanm/build.log && false )
300268
# Target: target-test-release-testing
301269
# Run release tests, before others as may install useful stuff
302270
- name: target-test-release-testing (via cpanm)
303271
shell: bash
272+
if: |
273+
(fromJSON(inputs.target-all) || fromJSON(inputs.target-test-release-testing)) &&
274+
fromJSON(inputs.test-enable-release-testing)
304275
env:
305276
AUTOMATED_TESTING: 1
306277
RELEASE_TESTING: 1
307278
run: |
308-
if ${{ toJSON(
309-
( fromJSON(inputs.target-all)
310-
|| fromJSON(inputs.target-test-release-testing)
311-
)
312-
&& fromJSON(inputs.test-enable-release-testing || 'false')
313-
) }}; then
314-
echo "::group::test-release-testing (via cpanm)"
315-
cd ${{ inputs.path }}
316-
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n --installdeps --with-develop . || ( cat ~/.cpanm/build.log && false )
317-
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n CPAN::Changes || ( cat ~/.cpanm/build.log && false )
318-
if [ -d xt ]; then
319-
$TEST_RUNNER_PREFIX $MYPERL -S prove -lr xt
320-
else
321-
echo "Warning: no directory xt/" >&2
322-
fi
323-
echo "::endgroup::"
324-
fi
279+
cd ${{ inputs.path }}
280+
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n --installdeps --with-develop . || ( cat ~/.cpanm/build.log && false )
281+
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n CPAN::Changes || ( cat ~/.cpanm/build.log && false )
282+
if [ -d xt ]; then
283+
$TEST_RUNNER_PREFIX $MYPERL -S prove -lr xt
284+
else
285+
echo "Warning: no directory xt/" >&2
286+
fi
325287
# Target: target-test
326288
- name: target-test (prepare for testing)
327289
shell: bash
290+
if: fromJSON(inputs.target-all) || fromJSON(inputs.target-test)
328291
env:
329292
AUTOMATED_TESTING: 1
330293
HARNESS_OPTIONS: ${{ inputs.test-harness-options }}
331294
run: |
332-
if ${{ toJSON(
333-
( fromJSON(inputs.target-all)
334-
|| fromJSON(inputs.target-test)
335-
)
336-
) }}; then
337-
echo "::group::test (prepare for testing)"
338-
cd ${{ inputs.path }}
339-
if [ -f Makefile.PL ]; then
340-
( [ -f Makefile ] || $BUILD_RUNNER_PREFIX $MYPERL Makefile.PL )
341-
elif [ -f Build.PL ]; then
342-
( [ -f Build ] || $BUILD_RUNNER_PREFIX $MYPERL Build.PL )
343-
else
344-
echo "No file Makefile.PL or Build.PL" >&2
345-
fi
346-
echo "::endgroup::"
347-
fi
295+
cd ${{ inputs.path }}
296+
if [ -f Makefile.PL ]; then
297+
( [ -f Makefile ] || $BUILD_RUNNER_PREFIX $MYPERL Makefile.PL )
298+
elif [ -f Build.PL ]; then
299+
( [ -f Build ] || $BUILD_RUNNER_PREFIX $MYPERL Build.PL )
300+
else
301+
echo "No file Makefile.PL or Build.PL" >&2
302+
fi
348303
- name: GNU make for Windows
349304
shell: bash
350305
if: matrix.os == 'windows-latest'
351306
run: |
352307
choco install --verbose make
353308
- name: target-test (no coverage)
354309
shell: bash
355-
if: ${{ fromJSON(inputs.target-all || 'false') || fromJSON(inputs.target-test || 'false') && !fromJSON(inputs.test-enable-coverage) }}
310+
if: ${{ fromJSON(inputs.target-all) || fromJSON(inputs.target-test) && !fromJSON(inputs.test-enable-coverage) }}
356311
env:
357312
AUTOMATED_TESTING: 1
358313
HARNESS_OPTIONS: ${{ inputs.test-harness-options }}
@@ -367,7 +322,7 @@ runs:
367322
fi
368323
- name: target-test (with coverage)
369324
shell: bash
370-
if: ${{ fromJSON(inputs.target-all || 'false') || fromJSON(inputs.target-test || 'false') && fromJSON(inputs.test-enable-coverage) }}
325+
if: ${{ fromJSON(inputs.target-all) || fromJSON(inputs.target-test) && fromJSON(inputs.test-enable-coverage) }}
371326
env:
372327
AUTOMATED_TESTING: 1
373328
HARNESS_OPTIONS: ${{ inputs.test-harness-options }}

0 commit comments

Comments
 (0)