-
Notifications
You must be signed in to change notification settings - Fork 182
174 lines (156 loc) · 5.56 KB
/
ci.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
name: Run Tests
on:
push:
branches:
- '*'
pull_request:
env:
PKG_DEPS_UBUNTU: >-
libdb-dev
PKG_DEPS_DEBIAN: >-
libdb-dev
PERL_MIN_VERSION: '5.12'
jobs:
dist:
name: Make distribution using Dist::Zilla
runs-on: ubuntu-latest
steps:
# Build the dist using Dist::Zilla.
- name: Checkout code
uses: actions/checkout@v3
- name: Cache ~/perl5
uses: actions/cache@v3
with:
key: ${{ runner.os }}-dist-locallib
path: ~/perl5
- name: Perl version
run: |
perl -v
- name: Install cpanm
run: |
curl -L https://cpanmin.us | perl - --sudo App::cpanminus
- name: Install local::lib
run: |
cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
- name: Install Dist::Zilla
shell: bash
run: |
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
cpanm -n Dist::Zilla
dzil authordeps --missing | cpanm -n
- name: Make distribution
shell: bash
run: |
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
dzil build --in build-dir
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: ./build-dir
# Get Perl versions to test.
- uses: shogo82148/actions-setup-perl@v1
- id: set-perl-versions
name: Get Perl versions to test (minimum and median)
shell: perl {0}
run: |
use Actions::Core;
use List::Util qw(uniqstr first);
die 'Minimum version not specified as major version 5.xyz' unless $ENV{PERL_MIN_VERSION} =~ /^5\.[0-9]+$/;
my $min_perl = $ENV{PERL_MIN_VERSION};
info("Minimum Perl version is $min_perl");
set_output(min => $min_perl);
my @non_patch_versions = uniqstr map { /^(\d+\.\d+)/ } perl_versions( platform => 'linux' );
my $min_idx = first { $non_patch_versions[$_] eq $min_perl } 0..$#non_patch_versions;
my $median_perl = $non_patch_versions[int($min_idx/2)];
info("Median Perl version is $median_perl");
set_output(med => $median_perl );
outputs:
min-perl-version: ${{ steps.set-perl-versions.outputs.min }}
med-perl-version: ${{ steps.set-perl-versions.outputs.med }}
test:
needs: dist
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
perl: ['5']
author-testing: [false]
include:
- { os: 'ubuntu-latest', perl: "5" , author-testing: true , coverage: true }
- { os: 'ubuntu-latest', perl: "${{ needs.dist.outputs.med-perl-version }}" }
- { os: 'ubuntu-latest', perl: "${{ needs.dist.outputs.min-perl-version }}" }
name: Perl ${{ matrix.perl }} on ${{ matrix.os }}, author (${{ matrix.author-testing || 'false' }}), coverage (${{ matrix.coverage }})
steps:
- name: Get dist artifact
uses: actions/download-artifact@v3
with:
name: dist
# Setup system deps
- name: Setup system deps (apt)
if: runner.os == 'Linux' && env.PKG_DEPS_UBUNTU
run: |
sudo apt-get -y update && sudo apt-get install -y --no-install-recommends ${{ env.PKG_DEPS_UBUNTU }}
- name: Set up perl
uses: shogo82148/actions-setup-perl@v1
if: matrix.os != 'windows-latest'
with:
perl-version: ${{ matrix.perl }}
- name: Set up perl (Strawberry)
uses: shogo82148/actions-setup-perl@v1
if: matrix.os == 'windows-latest'
with:
distribution: 'strawberry'
- run: perl -V
- name: Install Perl deps
run: |
cpanm --notest --installdeps .
- name: Install Perl develop deps
if: matrix.author-testing
run: |
cpanm --notest --installdeps --with-develop .
- name: Install Perl coverage deps
if: matrix.coverage
run: |
cpanm --notest Devel::Cover::Report::Coveralls
- name: Set AUTHOR_TESTING
if: matrix.author-testing
shell: bash
run: |
echo "AUTHOR_TESTING=1" >> $GITHUB_ENV
- name: Run tests (no coverage)
if: ${{ ! matrix.coverage }}
run: |
cpanm --verbose --test-only .
- name: Run tests (with coverage)
if: matrix.coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HARNESS_PERL_SWITCHES: -MDevel::Cover
run: |
cpanm --verbose --test-only .
cover -report Coveralls
containers:
needs: dist
runs-on: ubuntu-latest
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
container: ['debian:bullseye', 'debian:bookworm']
steps:
- name: Get dist artifact
uses: actions/download-artifact@v3
with:
name: dist
- name: Setup system deps (apt)
if: ${{ startsWith(matrix.container, 'debian:') }}
run: |
apt-get -y update && apt-get install -y --no-install-recommends perl cpanminus make apt-file
apt-file update
apt-get install -y --no-install-recommends \
${{ env.PKG_DEPS_DEBIAN }} \
$( cpanm -q --showdeps . | perl -MConfig -MCwd=abs_path '-M5;@prefixes = map abs_path($_), @Config{qw(vendorlibexp vendorarchexp)}' -lpe 's,~.*$,,; s,::,/,g; $mod = $_; $_ = join qq{\n}, map { qq{$_/${mod}.pm} } @prefixes' | apt-file search -lFf - )
- name: Run tests
run: |
cpanm --verbose --test-only .