Skip to content

Commit 2a62ded

Browse files
committed
feat: Add GitHub Actions CI and author tests
1 parent e36b8c6 commit 2a62ded

File tree

7 files changed

+219
-14
lines changed

7 files changed

+219
-14
lines changed

.github/workflows/ci.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# .github/workflows/ci.yml
2+
name: CI/CD for Inline-Lua
3+
4+
# IMPORTANT:
5+
# Sets default permissions to be read-only for security
6+
permissions:
7+
contents: read
8+
9+
on:
10+
push:
11+
branches: [ master, main, develop ]
12+
pull_request:
13+
branches: [ master, main, develop ]
14+
workflow_dispatch: # Allow manual runs
15+
16+
jobs:
17+
test:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false # Don't cancel other jobs if one fails
21+
matrix:
22+
os: [ubuntu-latest, macos-latest, windows-latest]
23+
perl:
24+
- 5.8
25+
- 5.16
26+
- 5.22
27+
- 5.30
28+
- 5.36
29+
- 5.38
30+
include:
31+
# Also test bleeding edge on Ubuntu for forward-compatibility
32+
- os: ubuntu-latest
33+
perl: devel
34+
exclude:
35+
# Older Perls can be problematic on Windows, so, we'll be selective
36+
- os: windows-latest
37+
perl: 5.8
38+
- os: windows-latest
39+
perl: 5.16
40+
41+
name: Perl ${{ matrix.perl }} on ${{ matrix.os }}
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Perl
48+
uses: shogo82148/actions-setup-perl@v1
49+
with:
50+
perl-version: ${{ matrix.perl }}
51+
distribution: strawberry # for windows latest
52+
53+
- name: Cache CPAN modules
54+
uses: actions/cache@v4
55+
with:
56+
path: |
57+
~/perl5
58+
~/.cpanm
59+
key: ${{ runner.os }}-perl${{ matrix.perl }}-${{ hashFiles('**/cpanfile', '**/Makefile.PL', '**/META.json') }}
60+
restore-keys: |
61+
${{ runner.os }}-perl${{ matrix.perl }}-
62+
63+
- name: Install system dependencies (Lua)
64+
run: |
65+
if [ "$RUNNER_OS" == "Linux" ]; then
66+
sudo apt-get update
67+
sudo apt-get install -y liblua5.3-dev
68+
elif [ "$RUNNER_OS" == "macOS" ]; then
69+
brew install lua
70+
elif [ "$RUNNER_OS" == "Windows" ]; then
71+
# Using scoop to install Lua on Windows
72+
scoop install lua
73+
# Add Lua paths to the environment for Makefile.PL
74+
echo "LUA_LIB_PATH=C:\Users\runneradmin\scoop\apps\lua\current\lib" >> $env:GITHUB_ENV
75+
echo "LUA_INC_PATH=C:\Users\runneradmin\scoop\apps\lua\current\include" >> $env:GITHUB_ENV
76+
echo "PATH=C:\Users\runneradmin\scoop\apps\lua\current\bin;${env:PATH}" >> $env:GITHUB_ENV
77+
fi
78+
shell: bash
79+
80+
- name: Install Perl Dependencies
81+
run: cpanm --notest --installdeps .
82+
83+
- name: Build and Test
84+
run: |
85+
# Provide hints to Makefile.PL on Windows if env vars are set
86+
if [ "$RUNNER_OS" == "Windows" ]; then
87+
perl Makefile.PL INC="-I$env:LUA_INC_PATH" LIBS="-L$env:LUA_LIB_PATH -llua53"
88+
else
89+
perl Makefile.PL
90+
fi
91+
make
92+
make test TEST_VERBOSE=1
93+
94+
- name: Run Author/Extended Tests (if they exist)
95+
continue-on-error: true
96+
run: |
97+
if [ -d "xt" ]; then
98+
if [ -f "xt/cpanfile" ]; then
99+
cpanm --installdeps xt/
100+
fi
101+
prove -lv -r xt
102+
else
103+
echo "No xt/ directory found, skipping author tests."
104+
fi
105+
106+
dist-test:
107+
runs-on: ubuntu-latest
108+
needs: test
109+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
110+
111+
steps:
112+
- uses: actions/checkout@v4
113+
114+
- name: Set up Perl
115+
uses: shogo82148/actions-setup-perl@v1
116+
with:
117+
perl-version: 5.38
118+
119+
- name: Install Release Tools
120+
run: cpanm --notest Test::CPAN::Meta
121+
122+
- name: Build and Test Distribution
123+
run: |
124+
cpanm --notest --installdeps .
125+
perl Makefile.PL
126+
make
127+
make test
128+
make dist
129+
cpan-meta-json --file $(ls *.tar.gz | head -1) --validate
130+
131+
- name: Archive distribution
132+
# REMINDER: This step requires write permissions for actions to upload artifacts
133+
uses: actions/upload-artifact@v4
134+
with:
135+
name: perl-distribution
136+
path: "*.tar.gz"
137+
retention-days: 30

.gitignore

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
Lua.bs
2-
Lua.o
3-
Lua.c
4-
t/test.out
5-
pm_to_blib
6-
const-c.inc
7-
const-xs.inc
8-
a.out
1+
.build/
2+
Inline-Lua-*.tar.gz
93
blib/
4+
pm_to_blib
105
Makefile
116
Makefile.old
12-
MYMETA.*
7+
MYMETA.yml
8+
MYMETA.json
9+
*.bs
10+
*.o
11+
Lua.c
12+
*.so
1313
_Inline/
14-
.build
15-
/Inline-Lua-*
14+
.cpanm/
15+
cpanfile.snapshot
16+
.trunk/plugins/
17+
.trunk/results/
18+
.vscode/
19+
*.swp
20+
*~
21+
.#*
22+
.idea/
23+
.DS_Store
24+
Thumbs.db

Changes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Revision history for Perl extension Inline::Lua.
22

33
{{$NEXT}}
4-
4+
- Add GitHub Actions CI for automated testing.
5+
- Add xt/ author tests for POD and code quality.
6+
- Modernize development environment setup.
57
0.17 October 25 2020
68
- Fix memory freeing problem for booleans (#31)
79

README.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Inline::Lua - Perl extension for embedding Lua scripts into Perl code
88

99
=head1 VERSION
1010

11-
version 0.17
11+
version 0.01
1212

1313
=head1 SYNOPSIS
1414

@@ -539,7 +539,7 @@ the same terms as the Perl 5 programming language system itself.
539539
=head1 BUGS
540540

541541
Please report any bugs or feature requests on the bugtracker website
542-
L<https://github.com/hoelzro/inline-lua/issues>
542+
L<https://github.com/ItsMeForLua/Inline-Lua/issues>
543543

544544
When submitting a bug or request, please include a test-file or a
545545
patch to an existing test-file that illustrates the bug or desired

dist.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,26 @@ copyright_year = 2014
88
perl = 5.8.8
99
Inline = 0
1010
Test::Exception = 0
11+
1112
[Prereqs / TestRequires]
1213
Test::More = 0
14+
15+
; Author-side dependencies for testing.
16+
; The author bundle will automatically discover and run
17+
; tests in xt/ if the necessary testing modules are available.
18+
[Prereqs / DevelopRequires]
19+
Test::Perl::Critic = 0
20+
Test::Pod = 1.41
21+
Test::Pod::Coverage = 1.08
22+
23+
; The original author's bundle.
1324
[@Author::RHOELZ]
1425
:version = 0.05
1526
-omit=ModuleBuild
1627
-omit=UploadToCPAN
28+
1729
[MakeMaker::Custom]
30+
1831
[UploadToCPAN]
32+
1933
[MetaJSON]

xt/author/critic.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# xt/author/critic.t
2+
use strict;
3+
use warnings;
4+
use Test::More;
5+
6+
eval "use Test::Perl::Critic";
7+
if ($@) {
8+
plan skip_all => "Test::Perl::Critic required for testing PBP compliance";
9+
}
10+
11+
all_critic_ok('lib/');
12+
13+
done_testing();

xt/author/pod.t

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# xt/author/pod.t
2+
# This test ensures that all of our POD is syntactically valid.
3+
use strict;
4+
use warnings;
5+
use Test::More;
6+
7+
eval "use Test::Pod 1.41";
8+
plan skip_all => "Test::Pod 1.41 required for testing POD" if $@;
9+
10+
all_pod_files_ok();
11+
12+
done_testing();
13+
14+
# --------------------------------------------------------------------
15+
16+
# xt/author/pod-coverage.t
17+
# This test checks that we have documentation for all your public subroutines.
18+
use strict;
19+
use warnings;
20+
use Test::More;
21+
22+
eval "use Test::Pod::Coverage 1.08";
23+
plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@;
24+
25+
# REMINDER: The also_private key can list regexes for functions that are okay to be undocumented.
26+
all_pod_coverage_ok( "Inline::Lua", {
27+
also_private => [ qr/^(?:main_returns|register_undef|interpreter|destroy|compile|call)$/ ],
28+
} );
29+
30+
done_testing();

0 commit comments

Comments
 (0)