11# brian's standard GitHub Actions Ubuntu config for Perl 5 modules
2- # version 20250126.002
2+ # version 20250811.001
33# https://github.com/briandfoy/github_workflows
44# https://github.com/features/actions
55# This file is licensed under the Artistic License 2.0
@@ -38,6 +38,10 @@ concurrency:
3838 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
3939 cancel-in-progress : true
4040
41+ permissions :
42+ actions : write
43+ contents : read
44+
4145on :
4246 push :
4347 branches :
7074 pull_request :
7175 # weekly build on the master branch just to see what CPAN is doing
7276 schedule :
73- - cron : " 37 3 * * 0 "
77+ - cron : " 34 4 * * 5 "
7478jobs :
7579 perl :
7680 environment : automated_testing
7781 runs-on : ${{ matrix.os }}
7882 strategy :
7983 matrix :
8084 os :
81- - ubuntu-22.04
85+ - ubuntu-latest
8286 perl-version :
83- - ' 5.8-buster'
84- - ' 5.10-buster'
85- - ' 5.12-buster'
86- - ' 5.14-buster'
87- - ' 5.16-buster'
88- - ' 5.18-buster'
89- - ' 5.20-buster'
90- - ' 5.22-buster'
91- - ' 5.24-buster'
92- - ' 5.26-buster'
93- - ' 5.28-buster'
9487 - ' 5.30-bullseye'
9588 - ' 5.32-bullseye'
9689 - ' 5.34-bullseye'
@@ -100,13 +93,28 @@ jobs:
10093 container :
10194 image : perl:${{ matrix.perl-version }}
10295 steps :
103- - uses : actions/checkout@v3
96+ - uses : actions/checkout@v5
97+ - name : git corrections
98+ run : |
99+ git config --global --add safe.directory "$(pwd)"
104100 - name : Platform check
105101 run : uname -a
106102 - name : setup platform
107103 run : |
108- apt-get upgrade
109- apt-get -y install curl ${{ vars.UBUNTU_EXTRA_APT_GET }}
104+ apt-get -y update
105+ apt-get -y upgrade
106+ apt-get -y install \
107+ curl \
108+ jq \
109+ ${{ vars.UBUNTU_EXTRA_APT_GET }}
110+
111+ curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg --output /usr/share/keyrings/githubcli-archive-keyring.gpg
112+ chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
113+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
114+ apt update
115+ apt-get -y install gh
116+
117+ git config --global --add safe.directory $(pwd)
110118 - name : Perl version check
111119 run : |
112120 perl -V
@@ -140,6 +148,31 @@ jobs:
140148 pwd
141149 ls
142150 rm -rfv HTML-Tagset-*
151+ # Restore the last module installation for this OS/perl combination. This
152+ # saves several minutes in some cases. When cpan installs updates, the
153+ # 'save' counterpart for 'restore' will update the cache.
154+ - name : Restore Perl modules
155+ id : perl-modules-cache-restore
156+ uses : actions/cache/restore@v4
157+ with :
158+ key : ${{ runner.os }}-${{ matrix.perl-version }}-modules
159+ path : |
160+ /usr/local/lib/perl5
161+ /usr/local/bin/cover
162+ /usr/local/bin/cpan
163+ # We cannot reuse cache keys, so we'll delete it and then save it again
164+ # There are various hacks for this, but GitHub has so far declined to
165+ # do what so many people want. This seems like a long way to go to do
166+ # this, but most of the problem is translating the unique cache key name
167+ # to another hidden ID value. This is pervasive in the GitHub API.
168+ - name : Delete cache
169+ id : delete-cache
170+ env :
171+ GH_TOKEN : ${{ github.token }}
172+ run : |
173+ gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/actions/caches \
174+ | jq -r '.actions_caches[] | select(.key == "${{ steps.perl-modules-cache-restore.outputs.cache-primary-key }}") | .id' \
175+ | xargs -I{} gh api --method DELETE -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/actions/caches/{}
143176# I had some problems with openssl on Ubuntu, so I punted by installing
144177# cpanm first, which is easy. I can install IO::Socket::SSL with that,
145178# then switch back to cpan. I didn't explore this further, but what you
@@ -194,9 +227,21 @@ jobs:
194227# Devel::Cover 1.39
195228 - name : Run coverage tests
196229 if : env.PERL_VERSION != 'v5.8' && env.PERL_VERSION != 'v5.10'
230+ continue-on-error : true
197231 env :
198232 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
199233 run : |
200234 cpanm --notest Devel::Cover Devel::Cover::Report::Coveralls
201235 perl Makefile.PL
202- cover -test -report coveralls
236+ cover -test +ignore 'Makefile.PL' -report coveralls
237+ # Now always save the Perl modules in case we updated some versions
238+ - name : Save Perl modules
239+ id : perl-modules-cache-save
240+ uses : actions/cache/save@v4
241+ if : always()
242+ with :
243+ key : ${{ steps.perl-modules-cache-restore.outputs.cache-primary-key }}
244+ path : |
245+ /usr/local/lib/perl5
246+ /usr/local/bin/cover
247+ /usr/local/bin/cpan
0 commit comments