Skip to content

Commit ab63ca8

Browse files
committed
Add GitHub workflow
Create a GitHub workflow to test CommonMark against all supported versions of Perl and cmark on Linux, macOS, and Windows. Include tests for the system default Perl and and package-supplied cmark on Linux (Apt) and macOS (Homewbrew), as well. Each version of cmark has two steps: one for macOS and Linux using `build.sh`, and one for Windows using `build.ps1`. Just add new steps to test new versions. Perls: 5.38, 5.36, 5.34, 5.32, 5.30, 5.28, 5.26, 5.24, 5.22, 5.20, 5.18, 5.16, 5.14, 5.12, 5.10, 5.8, macOS system, Linux System. cmarks: 0.30.3, 0.29.0, 0.28.3, 0.27.1, 0.26.1, 0.25.2, 0.24.1, 0.20.0, apt-get, Homebrew. All tests pass on Linux and macOS, though the latter requires an updated version of ExtUtils::MakeMaker that includes Perl-Toolchain-Gang/ExtUtils-MakeMaker#402 so that it always finds cmark at runtime the same place it found it at compile time. Windows tests do not currently pass at all: 5.32 compiles but then `CommonMark->parse_file` dies without any error output in `t/02_accessors.t` and `t/10_wrappers.t` (I thought the issue might be the path, but use of File::Spec does not fix it). 5.38 doesn't get past `perl Makefile.PL`, saying it cannot find the cmark library, even though INC and LIBS are set. Also: update `.gitignore` to ignore additional files, and to specify root-level files and directories, and add some diagnostic output to `t/01_memory.t` to show the versions of cmark.
1 parent 4e0aa28 commit ab63ca8

File tree

7 files changed

+189
-4
lines changed

7 files changed

+189
-4
lines changed

.github/bin/build.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Param (
2+
$VERSION
3+
)
4+
5+
$BASENAME = "cmark-${VERSION}"
6+
$PREFIX = "$env:GITHUB_WORKSPACE/${BASENAME}"
7+
8+
if (Test-Path "Makefile") {
9+
make realclean
10+
}
11+
12+
echo "Building ${BASENAME} in ${PREFIX}";
13+
C:\msys64\usr\bin\wget.exe -q "https://github.com/jgm/cmark/archive/${VERSION}.tar.gz"
14+
tar -zxf "${VERSION}.tar.gz"
15+
cd "${BASENAME}"
16+
nmake /nologo /f Makefile.nmake INSTALLDIR="${PREFIX}" install
17+
cd ..
18+
19+
echo "Building and testing CommonMark"
20+
$env:PATH += ";${PREFIX}/bin"
21+
perl Makefile.PL INC="-I${PREFIX}/include" LIBS="-L${PREFIX}/lib -lcmark"
22+
make test TEST_VERBOSE=1

.github/bin/build.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# exit and report the failure if any command fails
4+
exit_trap () {
5+
local lc="$BASH_COMMAND" rc=$?
6+
echo "Command [$lc] exited with code [$rc]"
7+
}
8+
9+
trap exit_trap EXIT
10+
set -ex
11+
12+
VERSION=${CMARK_VERSION:=0.29.0}
13+
BASENAME="cmark-${VERSION}"
14+
PREFIX="${PWD}/${BASENAME}"
15+
16+
[ -e Makefile ] && make realclean
17+
18+
printf "Building %s in %s\n" "${BASENAME}" "${PREFIX}"
19+
curl -sL "https://github.com/jgm/cmark/archive/${VERSION}.tar.gz" | tar xz
20+
(cd "${BASENAME}" && make INSTALL_PREFIX="${PREFIX}" install)
21+
22+
printf "Building and testing CommonMark\n"
23+
perl Makefile.PL INC=-I"${PREFIX}/include" LIBS=-L"${PREFIX}/lib -lcmark"
24+
make
25+
make test TEST_VERBOSE=1

.github/workflows/ci.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: ✅ CI
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
strategy:
6+
matrix:
7+
os:
8+
- { icon: 🐧, name: ubuntu }
9+
- { icon: 🍎, name: macos }
10+
- { icon: 🪟, name: windows }
11+
perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12', '5.10', '5.8' ]
12+
name: 🐪 Perl ${{ matrix.perl }} on ${{ matrix.os.icon }}
13+
runs-on: ${{ matrix.os.name }}-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Perl
18+
uses: shogo82148/actions-setup-perl@v1
19+
with:
20+
perl-version: ${{ matrix.perl }}
21+
22+
# CommonMark depends on Devel::CheckLib, and install the latest EU::MM
23+
# to get builds to work consistently on macOS as fixed here:
24+
# https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/pull/403
25+
- name: Install Dependencies
26+
run: |
27+
perl -V
28+
cpanm -v --notest --no-man-pages Devel::CheckLib ExtUtils::MakeMaker
29+
30+
- name: Add MSVC
31+
uses: ilammy/msvc-dev-cmd@v1
32+
if: runner.os == 'Windows'
33+
34+
- name: Test With cmark-0.30.3
35+
if: runner.os != 'Windows'
36+
run: ./.github/bin/build.sh 0.30.3
37+
38+
- name: Windows Test With cmark-0.30.3
39+
if: runner.os == 'Windows'
40+
run: ./.github/bin/build.ps1 -VERSION 0.30.3
41+
42+
- name: Test With cmark-0.29.0
43+
if: runner.os != 'Windows'
44+
run: ./.github/bin/build.sh 0.29.0
45+
46+
- name: Windows Test With cmark-0.29.0
47+
if: runner.os == 'Windows'
48+
run: ./.github/bin/build.ps1 -VERSION 0.29.0
49+
50+
- name: Test With cmark-0.28.3
51+
if: runner.os != 'Windows'
52+
run: ./.github/bin/build.sh 0.28.3
53+
54+
- name: Windows Test With cmark-0.28.3
55+
if: runner.os == 'Windows'
56+
run: ./.github/bin/build.ps1 -VERSION 0.28.3
57+
58+
- name: Test With cmark-0.27.1
59+
if: runner.os != 'Windows'
60+
run: ./.github/bin/build.sh 0.27.1
61+
62+
- name: Windows Test With cmark-0.27.1
63+
if: runner.os == 'Windows'
64+
run: ./.github/bin/build.ps1 -VERSION 0.27.1
65+
66+
- name: Test With cmark-0.26.1
67+
if: runner.os != 'Windows'
68+
run: ./.github/bin/build.sh 0.26.1
69+
70+
- name: Windows Test With cmark-0.26.1
71+
if: runner.os == 'Windows'
72+
run: ./.github/bin/build.ps1 -VERSION 0.26.1
73+
74+
- name: Test With cmark-0.25.2
75+
if: runner.os != 'Windows'
76+
run: ./.github/bin/build.sh 0.25.2
77+
78+
- name: Windows Test With cmark-0.25.2
79+
if: runner.os == 'Windows'
80+
run: ./.github/bin/build.ps1 -VERSION 0.25.2
81+
82+
- name: Test With cmark-0.24.1
83+
if: runner.os != 'Windows'
84+
run: ./.github/bin/build.sh 0.24.1
85+
86+
- name: Windows Test With cmark-0.24.1
87+
if: runner.os == 'Windows'
88+
run: ./.github/bin/build.ps1 -VERSION 0.24.1
89+
90+
- name: Test With cmark-0.20.0
91+
if: runner.os != 'Windows'
92+
run: ./.github/bin/build.sh 0.20.0
93+
94+
- name: Windows Test With cmark-0.20.0
95+
if: runner.os == 'Windows'
96+
run: ./.github/bin/build.ps1 -VERSION 0.20.0
97+
98+
apt:
99+
name: 📦 cmark on 🐧
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@v4
103+
104+
- name: Apt-Get
105+
run: sudo apt-get update && sudo apt-get install -y libcmark-dev libdevel-checklib-perl
106+
107+
- name: Build and Test
108+
run: |
109+
perl -V
110+
[ -e Makefile ] && make realclean
111+
perl Makefile.PL && make test
112+
113+
brew:
114+
name: 📦 cmark on 🍎
115+
runs-on: macos-latest
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Brew Install
120+
run: brew install cmark cpanm && cpanm -v --notest --no-man-pages Devel::CheckLib
121+
122+
- name: Build and Test
123+
run: |
124+
perl -V
125+
[ -e Makefile ] && make realclean
126+
perl Makefile.PL INC="-I$(brew --prefix)/include" LIBS="-L$(brew --prefix)/lib -lcmark"

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
/.build/
1+
/_build/
22
/CommonMark-*/
3-
/CommonMark-*.tar.gz
3+
/blib
4+
/MANIFEST.bak
5+
/*META.*
6+
/Makefile*
7+
/pm_to_blib
8+
/CommonMark.bs
9+
/CommonMark.c
10+
/CommonMark.o

t/01_memory.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ BEGIN {
77
use_ok('CommonMark');
88
}
99

10+
diag 'cmark compile time version: ', CommonMark->compile_time_version_string;
11+
diag 'cmark runtime version: ', CommonMark->version_string;
12+
1013
my $md = <<EOF;
1114
# Header
1215

t/02_accessors.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use strict;
22
use warnings;
3+
use File::Spec::Functions qw(catfile);
34

45
use Test::More tests => 28;
56

67
BEGIN {
78
use_ok('CommonMark', ':all');
89
}
910

10-
my $filename = 't/files/test.md';
11+
my $filename = catfile(qw(t files test.md));
1112
open(my $file, '<', $filename)
1213
or die("$filename: $!");
1314
my $doc = CommonMark->parse_file($file);

t/10_wrappers.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use strict;
22
use warnings;
3+
use File::Spec::Functions qw(catfile);
34

45
use Test::More tests => 11;
56

@@ -8,7 +9,7 @@ BEGIN {
89
}
910

1011
{
11-
my $filename = 't/files/test.md';
12+
my $filename = catfile(qw(t files test.md));
1213
my $file;
1314

1415
open($file, '<', $filename) or die("$filename: $!");

0 commit comments

Comments
 (0)