Skip to content

Commit b97c682

Browse files
committed
feat: update testing workflow to use BATS and validate core commands
1 parent 608fca3 commit b97c682

2 files changed

Lines changed: 59 additions & 45 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jobs:
4242
./phpvm.sh version
4343
./phpvm.sh help
4444
./phpvm.sh list
45-
./phpvm.sh test
45+
./phpvm.sh current || echo "Current command validated"
46+
./phpvm.sh which || echo "Which command validated"
4647
4748
echo "All core commands work"
4849

.github/workflows/test.yml

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
jobs:
1414
# Syntax and Static Analysis
1515
syntax-check:
16-
name: "Syntax & Static Analysis"
16+
name: 'Syntax & Static Analysis'
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout Repository
@@ -35,7 +35,7 @@ jobs:
3535

3636
# Core Functionality Testing
3737
core-functionality-test:
38-
name: "Core Functionality (${{ matrix.os }})"
38+
name: 'Core Functionality (${{ matrix.os }})'
3939
runs-on: ${{ matrix.os }}
4040
needs: syntax-check
4141
strategy:
@@ -87,12 +87,21 @@ jobs:
8787
./phpvm.sh list || echo "List command executed (may show no versions initially)"
8888
echo "Basic commands work"
8989
90-
# Run the integrated self-tests
91-
- name: Run Integrated Self-Tests
90+
# Install and run BATS tests
91+
- name: Install BATS
9292
run: |
93-
echo "=== Running Integrated Self-Tests ==="
94-
./phpvm.sh test
95-
echo "Self-tests completed"
93+
if [ "${{ runner.os }}" = "macOS" ]; then
94+
brew install bats-core
95+
else
96+
sudo apt-get update
97+
sudo apt-get install -y bats
98+
fi
99+
100+
- name: Run BATS Test Suite
101+
run: |
102+
echo "=== Running BATS Test Suite ==="
103+
bats tests/
104+
echo "Tests completed"
96105
97106
# Test error handling
98107
- name: Test Error Handling
@@ -144,7 +153,7 @@ jobs:
144153
145154
# PHP Installation and Usage Testing
146155
php-usage-test:
147-
name: "PHP Installation & Usage (${{ matrix.os }})"
156+
name: 'PHP Installation & Usage (${{ matrix.os }})'
148157
runs-on: ${{ matrix.os }}
149158
needs: syntax-check
150159
strategy:
@@ -200,7 +209,7 @@ jobs:
200209
201210
# Multi-Distribution Compatibility Testing
202211
multi-distribution-test:
203-
name: "Multi-Distribution Test (${{ matrix.scenario }})"
212+
name: 'Multi-Distribution Test (${{ matrix.scenario }})'
204213
runs-on: ubuntu-latest
205214
needs: syntax-check
206215
strategy:
@@ -209,69 +218,69 @@ jobs:
209218
include:
210219
# Ubuntu versions
211220
- distro: ubuntu:20.04
212-
scenario: "Ubuntu 20.04 LTS"
221+
scenario: 'Ubuntu 20.04 LTS'
213222
package_manager: apt
214-
test_php_versions: "7.4 8.0 8.1"
223+
test_php_versions: '7.4 8.0 8.1'
215224
- distro: ubuntu:22.04
216-
scenario: "Ubuntu 22.04 LTS"
225+
scenario: 'Ubuntu 22.04 LTS'
217226
package_manager: apt
218-
test_php_versions: "8.0 8.1 8.2"
227+
test_php_versions: '8.0 8.1 8.2'
219228
- distro: ubuntu:24.04
220-
scenario: "Ubuntu 24.04 LTS"
229+
scenario: 'Ubuntu 24.04 LTS'
221230
package_manager: apt
222-
test_php_versions: "8.1 8.2 8.3"
231+
test_php_versions: '8.1 8.2 8.3'
223232

224233
# Debian versions
225234
- distro: debian:11
226-
scenario: "Debian Bullseye"
235+
scenario: 'Debian Bullseye'
227236
package_manager: apt
228-
test_php_versions: "7.4 8.0"
237+
test_php_versions: '7.4 8.0'
229238
- distro: debian:12
230-
scenario: "Debian Bookworm"
239+
scenario: 'Debian Bookworm'
231240
package_manager: apt
232-
test_php_versions: "8.1 8.2"
241+
test_php_versions: '8.1 8.2'
233242

234243
# RHEL/CentOS family
235244
- distro: fedora:38
236-
scenario: "Fedora 38"
245+
scenario: 'Fedora 38'
237246
package_manager: dnf
238-
test_php_versions: "8.1 8.2"
247+
test_php_versions: '8.1 8.2'
239248
- distro: fedora:39
240-
scenario: "Fedora 39"
249+
scenario: 'Fedora 39'
241250
package_manager: dnf
242-
test_php_versions: "8.2 8.3"
251+
test_php_versions: '8.2 8.3'
243252
- distro: rockylinux:8
244-
scenario: "Rocky Linux 8"
253+
scenario: 'Rocky Linux 8'
245254
package_manager: dnf
246-
test_php_versions: "7.4 8.0"
255+
test_php_versions: '7.4 8.0'
247256
- distro: rockylinux:9
248-
scenario: "Rocky Linux 9"
257+
scenario: 'Rocky Linux 9'
249258
package_manager: dnf
250-
test_php_versions: "8.0 8.1"
259+
test_php_versions: '8.0 8.1'
251260
- distro: almalinux:8
252-
scenario: "AlmaLinux 8"
261+
scenario: 'AlmaLinux 8'
253262
package_manager: dnf
254-
test_php_versions: "7.4 8.0"
263+
test_php_versions: '7.4 8.0'
255264
- distro: almalinux:9
256-
scenario: "AlmaLinux 9"
265+
scenario: 'AlmaLinux 9'
257266
package_manager: dnf
258-
test_php_versions: "8.0 8.1"
267+
test_php_versions: '8.0 8.1'
259268

260269
# Arch Linux
261270
- distro: archlinux:latest
262-
scenario: "Arch Linux"
271+
scenario: 'Arch Linux'
263272
package_manager: pacman
264-
test_php_versions: "8.2 8.3"
273+
test_php_versions: '8.2 8.3'
265274

266275
# Alpine Linux
267276
- distro: alpine:3.18
268-
scenario: "Alpine 3.18"
277+
scenario: 'Alpine 3.18'
269278
package_manager: apk
270-
test_php_versions: "8.1 8.2"
279+
test_php_versions: '8.1 8.2'
271280
- distro: alpine:3.19
272-
scenario: "Alpine 3.19"
281+
scenario: 'Alpine 3.19'
273282
package_manager: apk
274-
test_php_versions: "8.2 8.3"
283+
test_php_versions: '8.2 8.3'
275284

276285
steps:
277286
- name: Checkout Repository
@@ -323,8 +332,11 @@ jobs:
323332
./phpvm.sh help
324333
./phpvm.sh list || echo 'List command completed'
325334
326-
echo '=== Running Self-Tests ==='
327-
./phpvm.sh test
335+
echo '=== Testing Basic Commands ==='
336+
# Built-in test command has been removed in favor of BATS
337+
# Basic command validation is sufficient for container tests
338+
./phpvm.sh version >/dev/null
339+
./phpvm.sh help >/dev/null
328340
329341
echo '=== Testing Input Validation ==='
330342
# Test invalid version formats
@@ -370,7 +382,7 @@ jobs:
370382
371383
# Performance and Load Testing
372384
performance-test:
373-
name: "Performance & Load Testing"
385+
name: 'Performance & Load Testing'
374386
runs-on: ubuntu-latest
375387
needs: syntax-check
376388
steps:
@@ -400,7 +412,7 @@ jobs:
400412
401413
# End-to-End Integration Testing
402414
integration-test:
403-
name: "End-to-End Integration (${{ matrix.os }})"
415+
name: 'End-to-End Integration (${{ matrix.os }})'
404416
runs-on: ${{ matrix.os }}
405417
needs: syntax-check
406418
strategy:
@@ -545,7 +557,7 @@ jobs:
545557
help_output=$(./phpvm.sh help)
546558
547559
# Check if help includes all commands
548-
commands=("install" "use" "system" "auto" "list" "help" "test" "info" "version")
560+
commands=("install" "use" "system" "auto" "list" "help" "info" "version" "alias" "unalias" "current" "which" "deactivate")
549561
550562
for cmd in "${commands[@]}"; do
551563
if echo "$help_output" | grep -q "$cmd"; then
@@ -651,8 +663,9 @@ jobs:
651663
echo -e "\n4. List functionality:"
652664
./phpvm.sh list >/dev/null && echo "List command successful"
653665
654-
echo -e "\n5. Self-tests:"
655-
./phpvm.sh test >/dev/null && echo "Self-tests successful"
666+
echo -e "\n5. Command validation:"
667+
./phpvm.sh current >/dev/null || echo "Current command validated"
668+
./phpvm.sh which >/dev/null || echo "Which command validated"
656669
657670
echo -e "\n6. Input validation:"
658671
./phpvm.sh install "invalid" 2>/dev/null || echo "Input validation working"

0 commit comments

Comments
 (0)