Skip to content

Commit 75e2701

Browse files
committed
refactor: unify test execution scripts with single test command
- Replace individual test scripts (test-unit, test-integration, test-e2e, test-all) with unified script/test - Support arguments: unit, integration, e2e, all with flexible combinations - Update GitHub workflow to use new test command and exclude e2e tests from CI - Optimize workflow by setting up Perl environment once with persistent env vars - Add documentation about virtualization requirements for e2e tests - Update copilot instructions with new pre-commit test command The new unified script provides better flexibility while the workflow optimization reduces redundant environment setup across CI steps. E2E tests are excluded from CI due to virtualization requirements but can be run locally with full support.
1 parent fe90722 commit 75e2701

File tree

7 files changed

+103
-29
lines changed

7 files changed

+103
-29
lines changed

.github/copilot-instructions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ Follow [perlstyle](https://perldoc.perl.org/5.42.0/perlstyle) conventions for co
144144
ALWAYS run the tests suite before committing any changes:
145145

146146
```bash
147-
carmel exec -- prove -l t/
147+
./script/test unit integration
148148
```
149149

150+
Note: E2E tests are excluded from pre-commit checks as they are slow and require virtualization. Run them manually when needed with `./script/test e2e` or `./script/test all`.
151+
150152
ALWAYS run the linting suite before committing any changes:
151153

152154
```bash

.github/workflows/testing.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
test:
3131
runs-on: ubuntu-latest
3232
name: Test
33+
env:
34+
PERL5LIB: ~/perl5/lib/perl5
35+
PERL_LOCAL_LIB_ROOT: ~/perl5
36+
PERL_MB_OPT: --install_base ~/perl5
37+
PERL_MM_OPT: INSTALL_BASE=~/perl5
3338

3439
steps:
3540
- name: Checkout code
@@ -47,24 +52,28 @@ jobs:
4752
export PATH="$HOME/perl5/bin:$PATH"
4853
echo "$HOME/perl5/bin" >> $GITHUB_PATH
4954
50-
# Setup local::lib
55+
# Setup local::lib environment (will be inherited by subsequent steps)
5156
cpanm --local-lib=~/perl5 local::lib
5257
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
5358
59+
# Export environment variables for subsequent steps
60+
echo "PERL5LIB=$PERL5LIB" >> $GITHUB_ENV
61+
echo "PERL_LOCAL_LIB_ROOT=$PERL_LOCAL_LIB_ROOT" >> $GITHUB_ENV
62+
echo "PERL_MB_OPT=$PERL_MB_OPT" >> $GITHUB_ENV
63+
echo "PERL_MM_OPT=$PERL_MM_OPT" >> $GITHUB_ENV
64+
5465
# Install Carmel
5566
cpanm Carmel
5667
5768
- name: Install project dependencies
58-
run: |
59-
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
60-
carmel install
69+
run: carmel install
6170

62-
- name: Run unit tests
71+
- name: Run tests
6372
run: |
64-
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
65-
./script/test-unit
66-
67-
- name: Run integration tests
68-
run: |
69-
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
70-
./script/test-integration
73+
# Note: E2E tests are excluded from CI as they require virtualization (KVM/QEMU)
74+
# which is not available in GitHub Actions runners. To run E2E tests locally
75+
# on your development machine with virtualization support, use:
76+
# ./script/test e2e
77+
# or
78+
# ./script/test all
79+
./script/test unit integration

script/test

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
# Unified test script for running different test suites
4+
# Usage: ./script/test [e2e] [integration] [unit] [all]
5+
# Note: E2E tests require virtualization (KVM/QEMU) to be available on the host
6+
# Examples:
7+
# ./script/test all # Run all tests
8+
# ./script/test unit integration # Run unit and integration tests only
9+
# ./script/test e2e # Run e2e tests only (requires virtualization)
10+
11+
set -e
12+
13+
# Default to no tests selected
14+
run_unit=false
15+
run_integration=false
16+
run_e2e=false
17+
18+
# If no arguments provided, show usage
19+
if [ $# -eq 0 ]; then
20+
echo "Usage: $0 [e2e] [integration] [unit] [all]"
21+
echo ""
22+
echo "Note: E2E tests require virtualization (KVM/QEMU) to be available on the host"
23+
echo ""
24+
echo "Examples:"
25+
echo " $0 all # Run all tests"
26+
echo " $0 unit integration # Run unit and integration tests only"
27+
echo " $0 e2e # Run e2e tests only (requires virtualization)"
28+
exit 1
29+
fi
30+
31+
# Parse arguments
32+
for arg in "$@"; do
33+
case $arg in
34+
all)
35+
run_unit=true
36+
run_integration=true
37+
run_e2e=true
38+
break # If 'all' is specified, no need to check other args
39+
;;
40+
unit)
41+
run_unit=true
42+
;;
43+
integration)
44+
run_integration=true
45+
;;
46+
e2e)
47+
run_e2e=true
48+
;;
49+
*)
50+
echo "Error: Unknown argument '$arg'"
51+
echo "Valid arguments are: e2e, integration, unit, all"
52+
exit 1
53+
;;
54+
esac
55+
done
56+
57+
# Build test directories array
58+
test_dirs=()
59+
60+
if [ "$run_unit" = true ]; then
61+
test_dirs+=("t/unit/")
62+
fi
63+
64+
if [ "$run_integration" = true ]; then
65+
test_dirs+=("t/integration/")
66+
fi
67+
68+
if [ "$run_e2e" = true ]; then
69+
test_dirs+=("t/e2e/")
70+
fi
71+
72+
# Run tests if any directories are selected
73+
if [ ${#test_dirs[@]} -gt 0 ]; then
74+
echo "Running tests in: ${test_dirs[*]}"
75+
exec carmel exec -- prove -l "${test_dirs[@]}" --ext .t --recurse
76+
else
77+
echo "No test suites selected"
78+
exit 1
79+
fi

script/test-all

Lines changed: 0 additions & 4 deletions
This file was deleted.

script/test-e2e

Lines changed: 0 additions & 4 deletions
This file was deleted.

script/test-integration

Lines changed: 0 additions & 4 deletions
This file was deleted.

script/test-unit

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)