-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (125 loc) · 3.89 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
name: ci
on:
push:
branches: ['**']
paths:
- "lib/**"
- "t/**"
- "testdata/**"
- "Makefile.PL"
- ".github/workflows/ci.yml"
pull_request:
branches: [main]
paths:
- "lib/**"
- "t/**"
- "testdata/**"
- "Makefile.PL"
workflow_dispatch:
inputs:
perl-version:
required: false
type: string
workflow_call:
inputs:
perl-version:
required: false
type: string
event-type:
required: true
type: string
jobs:
setup:
runs-on: ubuntu-latest
outputs:
perl-version: ${{ steps.vars.outputs.perl-version }}
steps:
- name: Checkout code to determine the minimum supported perl version
if: ${{ inputs.perl-version == '' }}
uses: actions/checkout@v4
with:
repository: pkgcraft/pkgcraft-perl
- name: Set perl versions to test against
id: vars
run: |
if [[ -n "${{ inputs.perl-version }}" ]]; then
echo "perl-version=$(jq 'split(",")' -Rc <(echo '${{ inputs.perl-version }}'))" >> $GITHUB_OUTPUT
else
min_ver=$(sed -rn "/^\s*MIN_PERL_VERSION / s/.*=> '([0-9](.[0-9]+)*)',/\1/p" Makefile.PL)
if [[ -n ${min_ver} ]]; then
echo "perl-version=['${min_ver}', '5']" >> $GITHUB_OUTPUT
else
exit 1
fi
fi
test:
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
perl-version: ${{ fromJson(needs.setup.outputs.perl-version) }}
steps:
- name: Set up environment
run: echo pkgcraft_dir=~/pkgcraft >> $GITHUB_ENV
- name: Download pkgcraft-c library from most recent run
if: ${{ inputs.event-type == '' }}
uses: dawidd6/action-download-artifact@v6
with:
github_token: ${{ secrets.PKGCRAFT_CI_TOKEN }}
repo: pkgcraft/pkgcraft
branch: main
workflow: pkgcraft-c.yml
workflow_conclusion: ""
search_artifacts: true
name: pkgcraft-c-${{ runner.os }}
- name: Download pkgcraft-c library from running workflow
if: ${{ inputs.event-type != '' }}
uses: actions/download-artifact@v4
with:
name: pkgcraft-c-${{ runner.os }}
- name: Unpack library
run: |
mkdir -p "${pkgcraft_dir}"
tar -Jxf pkgcraft-c.tar.xz -C "${pkgcraft_dir}"
- name: Checkout code
uses: actions/checkout@v4
with:
repository: pkgcraft/pkgcraft-perl
submodules: true
- name: Set up Perl ${{ matrix.perl-version }}
uses: shogo82148/actions-setup-perl@v1
id: perl
with:
perl-version: ${{ matrix.perl-version }}
enable-modules-cache: false
- name: Set up cache
uses: actions/cache@v4
with:
path: local
key: ${{ github.job }}-${{ runner.os }}-perl-${{ steps.perl.outputs.perl-version }}-${{ hashFiles('Makefile.PL') }}
restore-keys: ${{ github.job }}-${{ runner.os }}-perl-${{ steps.perl.outputs.perl-version }}-
- name: Install modules
run: |
cpanm -L local -n --installdeps .
cpanm -L local -n Devel::Cover
# required for `cover` command to be found
echo local/bin >> $GITHUB_PATH
- name: Override build variables
run: |
echo "PKG_CONFIG_PATH=${pkgcraft_dir}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${pkgcraft_dir}" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${pkgcraft_dir}" >> $GITHUB_ENV
- name: Build and test module
env:
PERL5LIB: 'perllib:local/lib/perl5'
run: |
perl Makefile.PL
make
cover -test -ignore_re "local" -report codecov
- name: Upload coverage to Codecov
if: ${{ inputs.event-type == '' && github.ref_name == 'main' && matrix.perl-version == '5' }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.json