Skip to content

Commit 72018dc

Browse files
committed
feat: add alias management commands and remove built-in test command
1 parent 1dd2aff commit 72018dc

7 files changed

Lines changed: 269 additions & 839 deletions

File tree

.github/workflows/quality.yml

Lines changed: 170 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -1,195 +1,176 @@
11
name: Quality Assurance
22

33
on:
4-
push:
5-
branches: [main, development, 'fix/**', 'feature/**']
6-
pull_request:
7-
branches: [main, development]
8-
workflow_dispatch:
4+
push:
5+
branches: [main, development, 'fix/**', 'feature/**']
6+
pull_request:
7+
branches: [main, development]
8+
workflow_dispatch:
99

1010
jobs:
11-
# Linting and formatting checks
12-
lint:
13-
name: 'Lint & Format Check'
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout Repository
17-
uses: actions/checkout@v4
18-
19-
- name: Install ShellCheck
20-
run: |
21-
sudo apt-get update
22-
sudo apt-get install -y shellcheck
23-
24-
- name: Install shfmt
25-
run: |
26-
wget -O shfmt https://github.com/mvdan/sh/releases/download/v3.12.0/shfmt_v3.12.0_linux_amd64
27-
chmod +x shfmt
28-
sudo mv shfmt /usr/local/bin/
29-
30-
- name: Run ShellCheck
31-
run: |
32-
echo "Running ShellCheck..."
33-
shellcheck phpvm.sh install.sh || exit 1
34-
35-
- name: Check Code Formatting
36-
run: |
37-
echo "Checking code formatting..."
38-
shfmt -d -i 4 -sr phpvm.sh install.sh || {
39-
echo "Code formatting issues detected!"
40-
echo "Run 'make format' locally to fix."
41-
exit 1
42-
}
43-
44-
- name: Check for Common Issues
45-
run: |
46-
echo "Checking for common issues..."
47-
48-
# Check for trailing whitespace
49-
if grep -n '[[:space:]]$' phpvm.sh install.sh; then
50-
echo "Trailing whitespace found (see above)"
51-
exit 1
52-
fi
53-
54-
# Check for tabs (should use spaces)
55-
if grep -P '\t' phpvm.sh install.sh; then
56-
echo "Tabs found - please use spaces for indentation"
57-
exit 1
58-
fi
59-
60-
echo "No common issues found!"
61-
62-
# BATS test suite
63-
bats-tests:
64-
name: 'BATS Tests (${{ matrix.os }})'
65-
runs-on: ${{ matrix.os }}
66-
needs: lint
67-
strategy:
68-
fail-fast: false
69-
matrix:
70-
os: [ubuntu-latest, macos-latest]
71-
72-
steps:
73-
- name: Checkout Repository
74-
uses: actions/checkout@v4
75-
76-
- name: Install BATS
77-
run: |
78-
if [ "${{ matrix.os }}" = "macos-latest" ]; then
79-
brew install bats-core
80-
else
81-
sudo apt-get update
82-
sudo apt-get install -y bats
83-
fi
84-
85-
- name: Run BATS Test Suite
86-
run: |
87-
echo "Running BATS tests..."
88-
bats tests/ -t
89-
90-
- name: Upload Test Results
91-
if: always()
92-
uses: actions/upload-artifact@v4
93-
with:
94-
name: bats-results-${{ matrix.os }}
95-
path: test-results/
96-
retention-days: 30
97-
98-
# Built-in phpvm tests
99-
builtin-tests:
100-
name: 'Built-in Tests (${{ matrix.os }})'
101-
runs-on: ${{ matrix.os }}
102-
needs: lint
103-
strategy:
104-
fail-fast: false
105-
matrix:
106-
os: [ubuntu-latest, macos-latest]
107-
108-
steps:
109-
- name: Checkout Repository
110-
uses: actions/checkout@v4
111-
112-
- name: Run phpvm Built-in Tests
113-
run: |
114-
echo "Running built-in tests..."
115-
bash phpvm.sh test
116-
117-
# Integration tests - Test with actual PHP installations
118-
integration-tests:
119-
name: 'Integration Tests (${{ matrix.os }})'
120-
runs-on: ${{ matrix.os }}
121-
needs: [lint, bats-tests, builtin-tests]
122-
strategy:
123-
fail-fast: false
124-
matrix:
125-
os: [ubuntu-latest, macos-latest]
126-
127-
steps:
128-
- name: Checkout Repository
129-
uses: actions/checkout@v4
130-
131-
- name: Setup Test Environment
132-
run: |
133-
export PHPVM_DIR="$HOME/.phpvm-test"
134-
mkdir -p "$PHPVM_DIR"
135-
./install.sh
136-
137-
- name: Test PHP Installation (macOS)
138-
if: matrix.os == 'macos-latest'
139-
run: |
140-
source "$HOME/.phpvm-test/phpvm.sh"
141-
142-
# Test install
143-
phpvm install 8.2 || echo "PHP 8.2 already installed"
144-
145-
# Test use
146-
phpvm use 8.2
147-
148-
# Verify PHP version
149-
php -v
150-
151-
# Test current
152-
phpvm current
153-
154-
- name: Test PHP Installation (Ubuntu)
155-
if: matrix.os == 'ubuntu-latest'
156-
run: |
157-
source "$HOME/.phpvm-test/phpvm.sh"
158-
159-
# Add repository
160-
sudo add-apt-repository -y ppa:ondrej/php
161-
sudo apt-get update
162-
163-
# Test install
164-
phpvm install 8.2 || echo "PHP 8.2 installation attempted"
165-
166-
# Test current
167-
phpvm current || echo "No active version yet"
168-
169-
- name: Cleanup
170-
if: always()
171-
run: |
172-
rm -rf "$HOME/.phpvm-test"
173-
174-
# Quality gate - All checks must pass
175-
quality-gate:
176-
name: 'Quality Gate'
177-
runs-on: ubuntu-latest
178-
needs: [lint, bats-tests, builtin-tests]
11+
# Linting and formatting checks
12+
lint:
13+
name: 'Lint & Format Check'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
19+
- name: Install ShellCheck
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y shellcheck
23+
24+
- name: Install shfmt
25+
run: |
26+
wget -O shfmt https://github.com/mvdan/sh/releases/download/v3.12.0/shfmt_v3.12.0_linux_amd64
27+
chmod +x shfmt
28+
sudo mv shfmt /usr/local/bin/
29+
30+
- name: Run ShellCheck
31+
run: |
32+
echo "Running ShellCheck..."
33+
shellcheck phpvm.sh install.sh || exit 1
34+
35+
- name: Check Code Formatting
36+
run: |
37+
echo "Checking code formatting..."
38+
shfmt -d -i 4 -sr phpvm.sh install.sh || {
39+
echo "Code formatting issues detected!"
40+
echo "Run 'make format' locally to fix."
41+
exit 1
42+
}
43+
44+
- name: Check for Common Issues
45+
run: |
46+
echo "Checking for common issues..."
47+
48+
# Check for trailing whitespace
49+
if grep -n '[[:space:]]$' phpvm.sh install.sh; then
50+
echo "Trailing whitespace found (see above)"
51+
exit 1
52+
fi
53+
54+
# Check for tabs (should use spaces)
55+
if grep -P '\t' phpvm.sh install.sh; then
56+
echo "Tabs found - please use spaces for indentation"
57+
exit 1
58+
fi
59+
60+
echo "No common issues found!"
61+
62+
# BATS test suite
63+
bats-tests:
64+
name: 'BATS Tests (${{ matrix.os }})'
65+
runs-on: ${{ matrix.os }}
66+
needs: lint
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
os: [ubuntu-latest, macos-latest]
71+
72+
steps:
73+
- name: Checkout Repository
74+
uses: actions/checkout@v4
75+
76+
- name: Install BATS
77+
run: |
78+
if [ "${{ matrix.os }}" = "macos-latest" ]; then
79+
brew install bats-core
80+
else
81+
sudo apt-get update
82+
sudo apt-get install -y bats
83+
fi
84+
85+
- name: Run BATS Test Suite
86+
run: |
87+
echo "Running BATS tests..."
88+
bats tests/ -t
89+
90+
- name: Upload Test Results
17991
if: always()
180-
steps:
181-
- name: Check All Jobs
182-
run: |
183-
if [ "${{ needs.lint.result }}" != "success" ]; then
184-
echo "Linting failed!"
185-
exit 1
186-
fi
187-
if [ "${{ needs.bats-tests.result }}" != "success" ]; then
188-
echo "BATS tests failed!"
189-
exit 1
190-
fi
191-
if [ "${{ needs.builtin-tests.result }}" != "success" ]; then
192-
echo "Built-in tests failed!"
193-
exit 1
194-
fi
195-
echo "All quality checks passed! ✅"
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: bats-results-${{ matrix.os }}
95+
path: test-results/
96+
retention-days: 30
97+
98+
# Integration tests - Test with actual PHP installations
99+
integration-tests:
100+
name: 'Integration Tests (${{ matrix.os }})'
101+
runs-on: ${{ matrix.os }}
102+
needs: [lint, bats-tests, builtin-tests]
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
os: [ubuntu-latest, macos-latest]
107+
108+
steps:
109+
- name: Checkout Repository
110+
uses: actions/checkout@v4
111+
112+
- name: Setup Test Environment
113+
run: |
114+
export PHPVM_DIR="$HOME/.phpvm-test"
115+
mkdir -p "$PHPVM_DIR"
116+
./install.sh
117+
118+
- name: Test PHP Installation (macOS)
119+
if: matrix.os == 'macos-latest'
120+
run: |
121+
source "$HOME/.phpvm-test/phpvm.sh"
122+
123+
# Test install
124+
phpvm install 8.2 || echo "PHP 8.2 already installed"
125+
126+
# Test use
127+
phpvm use 8.2
128+
129+
# Verify PHP version
130+
php -v
131+
132+
# Test current
133+
phpvm current
134+
135+
- name: Test PHP Installation (Ubuntu)
136+
if: matrix.os == 'ubuntu-latest'
137+
run: |
138+
source "$HOME/.phpvm-test/phpvm.sh"
139+
140+
# Add repository
141+
sudo add-apt-repository -y ppa:ondrej/php
142+
sudo apt-get update
143+
144+
# Test install
145+
phpvm install 8.2 || echo "PHP 8.2 installation attempted"
146+
147+
# Test current
148+
phpvm current || echo "No active version yet"
149+
150+
- name: Cleanup
151+
if: always()
152+
run: |
153+
rm -rf "$HOME/.phpvm-test"
154+
155+
# Quality gate - All checks must pass
156+
quality-gate:
157+
name: 'Quality Gate'
158+
runs-on: ubuntu-latest
159+
needs: [lint, bats-tests, builtin-tests]
160+
if: always()
161+
steps:
162+
- name: Check All Jobs
163+
run: |
164+
if [ "${{ needs.lint.result }}" != "success" ]; then
165+
echo "Linting failed!"
166+
exit 1
167+
fi
168+
if [ "${{ needs.bats-tests.result }}" != "success" ]; then
169+
echo "BATS tests failed!"
170+
exit 1
171+
fi
172+
if [ "${{ needs.builtin-tests.result }}" != "success" ]; then
173+
echo "Built-in tests failed!"
174+
exit 1
175+
fi
176+
echo "All quality checks passed! ✅"

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
## [v1.8.0](https://github.com/Thavarshan/phpvm/compare/v1.7.0...v1.8.0) - 2026-01-12
6+
57
### Added
68

79
- **Alias management commands:** Added `phpvm alias` and `phpvm unalias` for version alias creation, listing, and removal.
@@ -18,10 +20,14 @@
1820

1921
- **Help output:** Promoted alias commands to the primary usage section.
2022

23+
### Removed
24+
25+
- **Built-in test command:** Removed `phpvm test` command in favor of BATS test suite only.
26+
2127
### Internal
2228

2329
- **Alias helper utilities:** Added alias listing helper and alias resolution logic.
24-
- **Test coverage:** Extended built-in test suite to cover alias functionality.
30+
- **Test coverage:** Extended BATS test suite to cover alias functionality and all core features.
2531

2632
## [v1.7.0](https://github.com/Thavarshan/phpvm/compare/v1.6.0...v1.7.0) - 2025-12-10
2733

0 commit comments

Comments
 (0)