Skip to content

feat: enhance alias functionality and add QA tooling #3

feat: enhance alias functionality and add QA tooling

feat: enhance alias functionality and add QA tooling #3

Workflow file for this run

name: Quality Assurance
on:
push:
branches: [main, development, 'fix/**', 'feature/**']
pull_request:
branches: [main, development]
workflow_dispatch:
jobs:
# Linting and formatting checks
lint:
name: 'Lint & Format Check'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install ShellCheck
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Install shfmt
run: |
wget -O shfmt https://github.com/mvdan/sh/releases/latest/download/shfmt_v3.8.0_linux_amd64
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
- name: Run ShellCheck
run: |
echo "Running ShellCheck..."
shellcheck phpvm.sh install.sh || exit 1
- name: Check Code Formatting
run: |
echo "Checking code formatting..."
shfmt -d -i 4 -sr phpvm.sh install.sh || {
echo "Code formatting issues detected!"
echo "Run 'make format' locally to fix."
exit 1
}
- name: Check for Common Issues
run: |
echo "Checking for common issues..."
# Check for trailing whitespace
if grep -n '[[:space:]]$' phpvm.sh install.sh; then
echo "Trailing whitespace found (see above)"
exit 1
fi
# Check for tabs (should use spaces)
if grep -P '\t' phpvm.sh install.sh; then
echo "Tabs found - please use spaces for indentation"
exit 1
fi
echo "No common issues found!"
# BATS test suite
bats-tests:
name: 'BATS Tests (${{ matrix.os }})'
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install BATS
run: |
if [ "${{ matrix.os }}" = "macos-latest" ]; then
brew install bats-core
else
sudo apt-get update
sudo apt-get install -y bats
fi
- name: Run BATS Test Suite
run: |
echo "Running BATS tests..."
bats tests/ -t
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: bats-results-${{ matrix.os }}
path: test-results/
retention-days: 30
# Built-in phpvm tests
builtin-tests:
name: 'Built-in Tests (${{ matrix.os }})'
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Run phpvm Built-in Tests
run: |
echo "Running built-in tests..."
bash phpvm.sh test
# Integration tests - Test with actual PHP installations
integration-tests:
name: 'Integration Tests (${{ matrix.os }})'
runs-on: ${{ matrix.os }}
needs: [lint, bats-tests, builtin-tests]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Test Environment
run: |
export PHPVM_DIR="$HOME/.phpvm-test"
mkdir -p "$PHPVM_DIR"
./install.sh
- name: Test PHP Installation (macOS)
if: matrix.os == 'macos-latest'
run: |
source "$HOME/.phpvm-test/phpvm.sh"
# Test install
phpvm install 8.2 || echo "PHP 8.2 already installed"
# Test use
phpvm use 8.2
# Verify PHP version
php -v
# Test current
phpvm current
- name: Test PHP Installation (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
source "$HOME/.phpvm-test/phpvm.sh"
# Add repository
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
# Test install
phpvm install 8.2 || echo "PHP 8.2 installation attempted"
# Test current
phpvm current || echo "No active version yet"
- name: Cleanup
if: always()
run: |
rm -rf "$HOME/.phpvm-test"
# Quality gate - All checks must pass
quality-gate:
name: 'Quality Gate'
runs-on: ubuntu-latest
needs: [lint, bats-tests, builtin-tests]
if: always()
steps:
- name: Check All Jobs
run: |
if [ "${{ needs.lint.result }}" != "success" ]; then
echo "Linting failed!"
exit 1
fi
if [ "${{ needs.bats-tests.result }}" != "success" ]; then
echo "BATS tests failed!"
exit 1
fi
if [ "${{ needs.builtin-tests.result }}" != "success" ]; then
echo "Built-in tests failed!"
exit 1
fi
echo "All quality checks passed! βœ…"