-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
411 lines (396 loc) · 14.9 KB
/
action.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
name: Cross-platform CI for Perl dist
inputs:
path:
description: |
Path for root of dist to build.
required: false
default: '.'
target-all:
description: |
Flag for target that runs all steps.
required: true
default: false
target-setup-perl:
description: |
Flag for target that sets up a particular version of Perl.
required: true
default: false
target-install-dist-perl-deps:
description: |
Flag for target that installs Perl dependencies of distribution.
required: true
default: false
target-test-release-testing:
description: |
Flag for target that runs release tests.
required: true
default: false
target-test:
description: |
Flag for target that runs tests.
required: true
default: false
perl-version:
description: |
Version of Perl to setup. Passed on to to action shogo82148/actions-setup-perl@v1
as `perl-version` input.
Used by target-setup-perl.
required: false
default: '5'
perl-distribution:
description: |
Perl distribution to install. Passed on to to action
shogo82148/actions-setup-perl@v1 as `distribution` input. This does not
need to be set as it defaults to strawberry which is ignored on
non-Windows systems.
Used by target-setup-perl.
required: false
default: strawberry
perl-threaded:
description: |
Setting for running a threaded Perl. Passed on to to action
shogo82148/actions-setup-perl@v1 as `multi-thread` input.
Used by target-setup-perl.
required: false
default: false
perl-deps-enable-cache:
description: |
Setting for enabling a cache of Perl dependencies.
Used by target-setup-perl.
required: false
default: true
perl-deps-cache-version:
description: |
Setting for cache version for Perl dependencies. Increment this to
invalidate the existing cache.
Used by target-setup-perl.
required: false
default: '0'
ccache-enable-cache:
description: |
Setting for enabling a cache using ccache.
Used by target-setup-perl.
required: false
default: true
ccache-cache-version:
description: |
Setting for cache version of ccache. Increment this to invalidate the
existing cache.
Used by target-setup-perl.
required: false
default: '0'
dist-perl-deps-configure:
description: |
List of Perl configure-time dependencies to install.
Used by target-install-dist-perl-deps.
required: false
default: ''
build-enable-parallel:
description: |
Setting for building in parallel if possible.
required: false
default: true
build-enable-graphical-display:
description: |
Flag for enabling build with graphical display setup. On a Linux
system, this uses xvfb to set up an X11 display. This does not do
anything on macOS and Windows systems.
required: true
default: false
test-harness-options:
description: |
Sets env $HARNESS_OPTIONS.
Used in target-test.
required: true
default: 'j4'
test-enable-release-testing:
description: |
Flag for enabling release testing.
Used in target-test-release-testing.
required: true
default: false
test-enable-coverage:
description: |
Flag for enabling code coverage.
Used in target-test.
required: true
default: false
test-enable-graphical-display:
description: |
Flag for enabling testing with graphical display setup. On a Linux
system, this uses xvfb to set up an X11 display. This does not do
anything on macOS and Windows systems.
Used in target-test, target-test-release-testing.
required: true
default: false
github-token:
description: |
GitHub token passed in.
Used by target-test if the test-enable-coverage option is enabled.
required: false
default: null
runs:
using: "composite"
steps:
# Target: none
# Shared step to do initial set up
- name: initial setup
shell: bash
run: |
echo "::group::initial setup"
export SYSTEM_CORES=1;
if ${{ toJSON( runner.os == 'Linux' ) }}; then
export SYSTEM_CORES="$(grep -c ^processor /proc/cpuinfo 2>/dev/null || echo 1 )"
elif ${{ toJSON( runner.os == 'macOS' ) }}; then
export SYSTEM_CORES="$(sysctl -n hw.ncpu || echo 1)"
elif ${{ toJSON( runner.os == 'Windows' ) }}; then
export SYSTEM_CORES=$( powershell -NoProfile -Command "& { Get-WmiObject Win32_Processor | Select-Object -Property NumberOfCores }" | perl -0777 -ne 'print $1, "\n" while /(\d+)/g' );
fi
echo "SYSTEM_CORES=$SYSTEM_CORES" >> $GITHUB_ENV
if ${{ toJSON(
fromJSON(inputs.build-enable-parallel || 'true')
) }}; then
echo "MAKEFLAGS=-j$(( SYSTEM_CORES + 1))" >> $GITHUB_ENV
fi
#if ${{ toJSON( runner.os == 'Windows' ) }}; then
# # Set TEMP to full path instead of 8.3 short filenames.
# # See <https://github.com/actions/virtual-environments/issues/712>.
# # $USERPROFILE\\AppData\\Local\\Temp
# [ -d 'C:\tmp' ] || mkdir 'C:\tmp';
# echo 'TMP=C:\tmp' >> $GITHUB_ENV
# echo 'TEMP=C:\tmp' >> $GITHUB_ENV
#fi
# This is needed for Clang 12 due to
# <https://github.com/Perl/perl5/issues/18780>.
if ${{ toJSON( runner.os == 'macOS' ) }}; then
PATCH_EUMM_DIR=$HOME/build_aux
[ -d $PATCH_EUMM_DIR ] || mkdir $PATCH_EUMM_DIR
if [ ! -f $PATCH_EUMM_DIR/clang12_no_warnings.pm ]; then
echo 'package clang12_no_warnings; use ExtUtils::MakeMaker::Config; $Config{ccflags} = join " ", $Config{ccflags}, "-Wno-compound-token-split-by-macro"; 1;' > $PATCH_EUMM_DIR/clang12_no_warnings.pm
echo "PERL5OPT=${PERL5OPT:+${PERL5OPT} }-I$PATCH_EUMM_DIR -Mclang12_no_warnings" >> $GITHUB_ENV
fi
fi
echo "::endgroup::"
# Shared step for setting up graphical display.
- name: Set up graphical display
shell: bash
run: |
if ${{ toJSON(
(
fromJSON(inputs.build-enable-graphical-display || 'false')
||
fromJSON(inputs.test-enable-graphical-display || 'false')
)
) }}; then
if ${{ toJSON( runner.os == 'Linux' ) }}; then
echo "::group::Install xvfb (via apt-get)"
sudo apt-get install xvfb
mkdir /tmp/runtime-runner && chmod 0700 /tmp/runtime-runner
echo "XDG_RUNTIME_DIR=/tmp/runtime-runner" >> $GITHUB_ENV
if ${{ fromJSON(inputs.build-enable-graphical-display || 'false') }}; then
echo "BUILD_RUNNER_PREFIX=xvfb-run -a" >> $GITHUB_ENV
fi
if ${{ fromJSON(inputs.test-enable-graphical-display || 'false') }}; then
echo "TEST_RUNNER_PREFIX=xvfb-run -a" >> $GITHUB_ENV
fi
echo "::endgroup::"
fi
fi
# Target: target-setup-perl
- name: target-setup-perl (actions-setup-perl)
shell: bash
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-setup-perl)
)
) }}; then
echo "::group::setup-perl (actions-setup-perl)"
git clone \
https://github.com/shogo82148/actions-setup-perl.git \
-b v1 \
.github/actions/actions-setup-perl;
node .github/actions/actions-setup-perl/dist/index.js
echo "::endgroup::"
fi
env:
INPUT_DISTRIBUTION: ${{ inputs.perl-distribution }}
INPUT_PERL-VERSION: ${{ inputs.perl-version }}
INPUT_MULTI-THREAD: ${{ inputs.perl-threaded }}
INPUT_ENABLE-MODULES-CACHE: false
- name: target-setup-perl (perl -V)
shell: bash
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-setup-perl)
)
) }}; then
echo "::group::setup-perl (perl -V)"
export MYPERL=$(which -a perl | grep -m 1 hostedtoolcache)
echo "MYPERL=$MYPERL" >> $GITHUB_ENV
$MYPERL -V
$MYPERL -MDigest::MD5=md5_hex -e 'print "GHA_CACHE_PERL_V_HASH=", md5_hex(`$^X -V`), "\n"' >> $GITHUB_ENV
echo "::endgroup::"
fi
- name: target-setup-perl (cache ~/perl5)
if: |
fromJSON(inputs.perl-deps-enable-cache)
&&
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-setup-perl)
)
uses: actions/cache@v2
with:
key: locallib-v2.${{ inputs.perl-deps-cache-version }}-${{ runner.os }}-${{ env.GHA_CACHE_PERL_V_HASH }}
path: ~/perl5
- name: target-setup-perl (ccache)
# ccache support on Windows is not well-tested
if: |
fromJSON(inputs.ccache-enable-cache)
&&
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-setup-perl)
)
&&
(
runner.os != 'Windows'
)
uses: Chocobo1/setup-ccache-action@v1
with:
override_cache_key: ccache-v0.${{ inputs.ccache-cache-version }}-${{ runner.os }}-${{ env.GHA_CACHE_PERL_V_HASH }}
- name: target-setup-perl (setup local::lib)
shell: bash
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-setup-perl)
)
) }}; then
echo "::group::setup-perl (setup local::lib)"
# older Perls need this upgrade
$MYPERL -S cpanm -n --local-lib=~/perl5 ExtUtils::MakeMaker
$MYPERL -S cpanm -n --local-lib=~/perl5 local::lib
LOCALLIB_VARS="$($MYPERL -I ~/perl5/lib/perl5 -Mlocal::lib=--shelltype,bourne )"
eval $( echo "$LOCALLIB_VARS" | $MYPERL -MFile::Spec -pne '
$_ = "" if /^PATH=/;
s/; export.*$/;/;
s/^[^=]+=/echo -n "$&"; echo /;
my $sep = File::Spec->catfile("", "");
s,/perl5,${sep}perl5,g;' ) >> $GITHUB_ENV
if ${{ toJSON( runner.os == 'Windows' ) }}; then
pwsh -c 'echo "'$( cygpath -w $( realpath ~/perl5/bin ) )'" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append'
else
echo "$HOME/perl5/bin" >> $GITHUB_PATH
fi
echo "PERL_CPANM_OPT=-l ~/perl5" >> $GITHUB_ENV
echo "::endgroup::"
fi
# Target: target-install-dist-perl-deps
- name: target-install-dist-perl-deps (via cpanm)
shell: bash
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-install-dist-perl-deps)
)
) }}; then
echo "::group::install-dist-perl-deps (via cpanm)"
cd ${{ inputs.path }}
if [ -n "${{ inputs.dist-perl-deps-configure }}" ]; then
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm --dev -n ${{ inputs.dist-perl-deps-configure }} || ( cat ~/.cpanm/build.log && false )
fi
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n --installdeps --dev . || ( cat ~/.cpanm/build.log && false )
echo "::endgroup::"
fi
# Target: target-test-release-testing
# Run release tests, before others as may install useful stuff
- name: target-test-release-testing (via cpanm)
shell: bash
env:
AUTOMATED_TESTING: 1
RELEASE_TESTING: 1
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-test-release-testing)
)
&& fromJSON(inputs.test-enable-release-testing || 'false')
) }}; then
echo "::group::test-release-testing (via cpanm)"
cd ${{ inputs.path }}
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n --installdeps --with-develop . || cat ~/.cpanm/build.log
$BUILD_RUNNER_PREFIX $MYPERL -S cpanm -n CPAN::Changes || cat ~/.cpanm/build.log
if [ -d xt ]; then
$TEST_RUNNER_PREFIX $MYPERL -S prove -lr xt
else
echo "Warning: no directory xt/" >&2
fi
echo "::endgroup::"
fi
# Target: target-test
- name: target-test (prepare for testing)
shell: bash
env:
AUTOMATED_TESTING: 1
HARNESS_OPTIONS: ${{ inputs.test-harness-options }}
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-test)
)
) }}; then
echo "::group::test (prepare for testing)"
cd ${{ inputs.path }}
if [ -f Makefile.PL ]; then
( [ -f Makefile ] || $BUILD_RUNNER_PREFIX $MYPERL Makefile.PL )
elif [ -f Build.PL ]; then
( [ -f Build ] || $BUILD_RUNNER_PREFIX $MYPERL Build.PL )
else
echo "No file Makefile.PL or Build.PL" >&2
fi
echo "::endgroup::"
fi
- name: target-test (no coverage)
shell: bash
env:
AUTOMATED_TESTING: 1
HARNESS_OPTIONS: ${{ inputs.test-harness-options }}
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-test)
)
&& ! fromJSON(inputs.test-enable-coverage || 'false')
) }}; then
echo "::group::test (no coverage)"
cd ${{ inputs.path }}
if [ -f Makefile.PL ]; then
( $TEST_RUNNER_PREFIX make && $TEST_RUNNER_PREFIX make test ) || exit 1
elif [ -f Build.PL ]; then
( $TEST_RUNNER_PREFIX ./Build test ) || exit 1
else
echo "No file Makefile.PL or Build.PL" >&2
fi
echo "::endgroup::"
fi
- name: target-test (with coverage)
shell: bash
env:
AUTOMATED_TESTING: 1
HARNESS_OPTIONS: ${{ inputs.test-harness-options }}
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
if ${{ toJSON(
( fromJSON(inputs.target-all)
|| fromJSON(inputs.target-test)
)
&& fromJSON(inputs.test-enable-coverage || 'false')
) }}; then
echo "::group::test (with coverage)"
cd ${{ inputs.path }}
$MYPERL -S cpanm -n Devel::Cover::Report::Coveralls || cat ~/.cpanm/build.log
$MYPERL -S cpanm -n https://github.com/PDLPorters/Devel--Cover.git@patches || cat ~/.cpanm/build.log
$TEST_RUNNER_PREFIX $MYPERL -S cover -test -relative_only -gcov_chdir -report Coveralls
echo "::endgroup::"
fi