Skip to content

Add comprehensive e2e testing for install/uninstall scripts across platforms and Helm scenarios #10

Add comprehensive e2e testing for install/uninstall scripts across platforms and Helm scenarios

Add comprehensive e2e testing for install/uninstall scripts across platforms and Helm scenarios #10

name: E2E Sequential Tests with Validation
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
validation:
name: "Script Validation & Linting"
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Make Scripts Executable"
run: |
cd scripts
chmod +x *.sh
- name: "Script Validation - Shell Script Syntax Check"
run: |
echo "Validating shell script syntax..."
cd scripts
bash -n install.sh
bash -n uninstall.sh
bash -n helm-utils.sh
bash -n helm-container.sh
echo "Shell script syntax validation passed"
- name: "Script Validation - PowerShell Script Syntax Check"
shell: pwsh
run: |
Write-Host "Validating PowerShell script syntax..."
Set-Location scripts
try {
Get-Content ./install.ps1 | Out-Null
Get-Content ./uninstall.ps1 | Out-Null
Get-Content ./helm-utils.ps1 | Out-Null
Get-Content ./helm-container.ps1 | Out-Null
Write-Host "PowerShell script syntax validation passed" -ForegroundColor Green
} catch {
Write-Host "PowerShell script syntax validation failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
- name: "Script Validation - Shellcheck Linting"
run: |
echo "Running shellcheck on shell scripts..."
sudo apt-get update && sudo apt-get install -y shellcheck
cd scripts
echo "Analyzing shell scripts with shellcheck..."
shellcheck -x install.sh uninstall.sh helm-utils.sh helm-container.sh
echo "Shellcheck linting completed successfully - no issues found"
- name: "Script Validation - PSScriptAnalyzer Linting"
shell: pwsh
run: |
Write-Host "Installing and running PSScriptAnalyzer..."
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
Set-Location scripts
$scripts = @('install.ps1', 'uninstall.ps1', 'helm-utils.ps1', 'helm-container.ps1')
foreach ($script in $scripts) {
Write-Host "Analyzing ${script}..."
$errorResults = Invoke-ScriptAnalyzer -Path $script -Severity Error
$warningResults = Invoke-ScriptAnalyzer -Path $script -Severity Warning
if ($errorResults) {
Write-Host "Errors found in ${script}:" -ForegroundColor Red
$errorResults | Format-Table -AutoSize
exit 1
} elseif ($warningResults) {
Write-Host "Warnings found in ${script} (non-blocking):" -ForegroundColor Yellow
$warningResults | Format-Table -AutoSize
} else {
Write-Host "No issues found in ${script}" -ForegroundColor Green
}
}
Write-Host "PSScriptAnalyzer linting completed"
- name: "YAML Validation"
run: |
echo "Validating YAML files..."
cd values
python3 -c "import yaml; yaml.safe_load(open('kubernetes-dashboards-configmap.yaml'))"
echo "YAML validation completed successfully"
local-helm-tests:
name: "Local Helm Tests (Dry-Run)"
runs-on: ubuntu-latest
timeout-minutes: 30
needs: validation
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Create kind cluster config"
run: |
cat > kind-config.yaml << EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30080
hostPort: 3000
protocol: TCP
- containerPort: 30081
hostPort: 9090
protocol: TCP
- containerPort: 30082
hostPort: 3100
protocol: TCP
- containerPort: 30083
hostPort: 3200
protocol: TCP
EOF
- name: "Setup Kubernetes (kind)"
uses: helm/kind-action@v1.10.0
with:
cluster_name: lgtm-local-helm-cluster
config: kind-config.yaml
- name: "Install Helm and Required Tools"
run: |
echo "Installing required tools..."
# Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Add Helm repositories
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add minio https://charts.min.io/
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Verify tools
kubectl version --client
helm version
docker --version
- name: "Make Scripts Executable"
run: |
cd scripts
chmod +x *.sh
- name: "Test - Shell Scripts + Local Helm - Dry-Run Validation"
run: |
echo "Starting Shell Scripts with Local Helm (Dry-Run)"
cd scripts
export NAMESPACE=lgtm-test-shell
export RELEASE_PREFIX=shell-test
export DRY_RUN=true
./install.sh
- name: "Test - PowerShell Scripts + Local Helm - Dry-Run Validation"
shell: pwsh
run: |
Write-Host "Starting PowerShell Scripts with Local Helm (Dry-Run)"
cd scripts
.\install.ps1 -Namespace "lgtm-test-ps" -ReleasePrefix "ps-test" -DryRun
- name: "Local Helm Tests Summary"
run: |
echo "========================================"
echo " LOCAL HELM TESTS COMPLETED"
echo "========================================"
echo ""
echo "Tests completed successfully:"
echo "- Shell Scripts + Local Helm (Dry-Run)"
echo "- PowerShell Scripts + Local Helm (Dry-Run)"
echo ""
echo "All dry-run validations passed!"
containerized-helm-tests:
name: "Containerized Helm Tests (Dry-Run)"
runs-on: ubuntu-latest
timeout-minutes: 30
needs: validation
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Create kind cluster config"
run: |
cat > kind-config.yaml << EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30080
hostPort: 3000
protocol: TCP
- containerPort: 30081
hostPort: 9090
protocol: TCP
- containerPort: 30082
hostPort: 3100
protocol: TCP
- containerPort: 30083
hostPort: 3200
protocol: TCP
EOF
- name: "Setup Kubernetes (kind)"
uses: helm/kind-action@v1.10.0
with:
cluster_name: lgtm-containerized-helm-cluster
config: kind-config.yaml
- name: "Setup Docker and kubectl (No Helm Installation)"
run: |
echo "Setting up environment for containerized Helm tests..."
# Verify tools (no Helm installation)
kubectl version --client
docker --version
# Ensure no local Helm is available
which helm && echo "ERROR: Local Helm found, removing..." && sudo rm -f $(which helm) || echo "Good: No local Helm found"
- name: "Make Scripts Executable"
run: |
cd scripts
chmod +x *.sh
- name: "Test - Shell Scripts + Containerized Helm - Dry-Run Validation"
run: |
echo "Starting Shell Scripts with Containerized Helm (Dry-Run)"
cd scripts
export NAMESPACE=lgtm-test-shell-container
export RELEASE_PREFIX=shell-container-test
export DRY_RUN=true
./install.sh
- name: "Test - PowerShell Scripts + Containerized Helm - Dry-Run Validation"
shell: pwsh
run: |
Write-Host "Starting PowerShell Scripts with Containerized Helm (Dry-Run)"
cd scripts
.\install.ps1 -Namespace "lgtm-test-ps-container" -ReleasePrefix "ps-container-test" -DryRun
- name: "Containerized Helm Tests Summary"
run: |
echo "========================================"
echo " CONTAINERIZED HELM TESTS COMPLETED"
echo "========================================"
echo ""
echo "Tests completed successfully:"
echo "- Shell Scripts + Containerized Helm (Dry-Run)"
echo "- PowerShell Scripts + Containerized Helm (Dry-Run)"
echo ""
echo "All containerized dry-run validations passed!"
final-summary:
name: "Final Test Summary"
runs-on: ubuntu-latest
needs: [validation, local-helm-tests, containerized-helm-tests]
if: always()
steps:
- name: "Overall Test Results"
run: |
echo "========================================"
echo " ALL E2E TESTS COMPLETED"
echo "========================================"
echo ""
echo "Job Results:"
echo "- Validation Job: ${{ needs.validation.result }}"
echo "- Local Helm Tests: ${{ needs.local-helm-tests.result }}"
echo "- Containerized Helm Tests: ${{ needs.containerized-helm-tests.result }}"
echo ""
if [[ "${{ needs.validation.result }}" == "success" && "${{ needs.local-helm-tests.result }}" == "success" && "${{ needs.containerized-helm-tests.result }}" == "success" ]]; then
echo "πŸŽ‰ ALL TESTS PASSED! πŸŽ‰"
echo ""
echo "The LGTM stack configuration is fully validated:"
echo "βœ… Script syntax and linting"
echo "βœ… Local Helm dry-run validation"
echo "βœ… Containerized Helm dry-run validation"
echo ""
echo "Ready for deployment!"
else
echo "❌ Some tests failed. Check the job results above."
exit 1
fi