Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 25 additions & 221 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration Tests
name: Server Migration Tests

on:
push:
Expand All @@ -8,253 +8,57 @@ on:
- develop
paths:
- 'tests/**'
- 'ansible/files/*.psm1'
- 'ansible/**'
- 'scripts/**/*.ps1'
- '.github/workflows/integration-tests.yml'
pull_request:
paths:
- 'tests/**'
- 'ansible/files/*.psm1'
- 'ansible/**'
- 'scripts/**/*.ps1'
- '.github/workflows/integration-tests.yml'
workflow_dispatch:
inputs:
test_suite:
suite:
description: 'Test suite to run'
required: false
default: 'Fast'
default: 'Integration'
type: choice
options:
- All
- Unit
- Integration
- Fast
- Slow
generate_report:
description: 'Generate HTML report'
required: false
default: true
type: boolean

env:
PESTER_VERSION: '5.5.0'
- All

jobs:
unit-tests:
name: Unit Tests
run-tests:
name: Run Pester Tests
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PowerShell modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Pester -MinimumVersion ${{ env.PESTER_VERSION }} -Force -Scope CurrentUser
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser

- name: Run unit tests
shell: pwsh
run: |
cd tests
.\scripts\Invoke-AllTests.ps1 -TestSuite Unit -OutputPath TestResults -Verbosity Detailed

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: unit-test-results
path: tests/TestResults/*.xml

- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
files: 'tests/TestResults/Unit-results-*.xml'
check_name: 'Unit Test Results'

integration-tests:
name: Integration Tests
runs-on: windows-latest
needs: unit-tests

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PowerShell modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Pester -MinimumVersion ${{ env.PESTER_VERSION }} -Force -Scope CurrentUser

- name: Create test directories
shell: pwsh
run: |
New-Item -Path "C:\ADMT\Batches" -ItemType Directory -Force | Out-Null
New-Item -Path "C:\ADMT\Logs" -ItemType Directory -Force | Out-Null
New-Item -Path "C:\ADMT\Reports" -ItemType Directory -Force | Out-Null
New-Item -Path "C:\Temp\FileServerTest" -ItemType Directory -Force | Out-Null

- name: Run integration tests
shell: pwsh
run: |
cd tests
.\scripts\Invoke-AllTests.ps1 -TestSuite Integration -OutputPath TestResults -Verbosity Detailed

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: integration-test-results
path: tests/TestResults/*.xml

- name: Upload code coverage
uses: actions/upload-artifact@v3
if: always()
with:
name: code-coverage
path: tests/TestResults/*-coverage-*.xml

- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
files: 'tests/TestResults/Integration-results-*.xml'
check_name: 'Integration Test Results'

- name: Cleanup test environment
if: always()
shell: pwsh
run: |
cd tests
.\scripts\Reset-TestEnvironment.ps1 -Force

infrastructure-tests:
name: Infrastructure Tests
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'test-infrastructure')

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
continue-on-error: true

- name: Setup PowerShell
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
inlineScript: |
Install-Module -Name Pester -MinimumVersion ${{ env.PESTER_VERSION }} -Force -Scope CurrentUser

- name: Run infrastructure tests
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
inlineScript: |
cd tests
pwsh -File scripts/Invoke-AllTests.ps1 -TestSuite Infrastructure -OutputPath TestResults -Verbosity Detailed
continue-on-error: true

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: infrastructure-test-results
path: tests/TestResults/*.xml

fast-tests:
name: Fast Test Suite
runs-on: windows-latest
if: github.event.inputs.test_suite == 'Fast' || github.event.inputs.test_suite == ''

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PowerShell modules
- name: Install PowerShell modules
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module -Name Pester -MinimumVersion ${{ env.PESTER_VERSION }} -Force -Scope CurrentUser

- name: Create test directories
shell: pwsh
run: |
New-Item -Path "C:\ADMT\Batches" -ItemType Directory -Force | Out-Null
New-Item -Path "C:\Temp\FileServerTest" -ItemType Directory -Force | Out-Null

- name: Run fast tests
Install-Module -Name Pester -MinimumVersion 5.5.0 -Force -Scope CurrentUser

- name: Execute tests
shell: pwsh
run: |
cd tests
.\scripts\Invoke-AllTests.ps1 -TestSuite Fast -OutputPath TestResults -Verbosity Normal -GenerateReport:$${{ github.event.inputs.generate_report == 'true' }}

- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: fast-test-results
path: tests/TestResults/*

- name: Cleanup
$suite = if ('${{ github.event.inputs.suite }}') { '${{ github.event.inputs.suite }}' } else { 'Integration' }
Write-Host "Running server migration tests for suite: $suite"
Push-Location tests/scripts
./Invoke-Tests.ps1 -Suite $suite
Pop-Location
Add-Content -Path $env:GITHUB_ENV -Value "suite=$suite"

- name: Publish summary
if: always()
shell: pwsh
run: |
cd tests
.\scripts\Reset-TestEnvironment.ps1 -Force

summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [unit-tests, integration-tests]
if: always()

steps:
- name: Download all artifacts
uses: actions/download-artifact@v3

- name: Generate summary
run: |
echo "## 🧪 Integration Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ needs.unit-tests.result }}" == "success" ]; then
echo "✅ **Unit Tests**: Passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Unit Tests**: Failed" >> $GITHUB_STEP_SUMMARY
fi

if [ "${{ needs.integration-tests.result }}" == "success" ]; then
echo "✅ **Integration Tests**: Passed" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Integration Tests**: Failed" >> $GITHUB_STEP_SUMMARY
fi

if [ "${{ needs.infrastructure-tests.result }}" == "success" ]; then
echo "✅ **Infrastructure Tests**: Passed" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.infrastructure-tests.result }}" == "skipped" ]; then
echo "⏭️ **Infrastructure Tests**: Skipped" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Infrastructure Tests**: Failed" >> $GITHUB_STEP_SUMMARY
fi

echo "" >> $GITHUB_STEP_SUMMARY
echo "### Artifacts" >> $GITHUB_STEP_SUMMARY
echo "- Unit test results" >> $GITHUB_STEP_SUMMARY
echo "- Integration test results" >> $GITHUB_STEP_SUMMARY
echo "- Code coverage reports" >> $GITHUB_STEP_SUMMARY

- name: Check overall status
if: |
needs.unit-tests.result == 'failure' ||
needs.integration-tests.result == 'failure'
run: exit 1

Write-Host "## Server Migration Tests" >> $env:GITHUB_STEP_SUMMARY
Write-Host "" >> $env:GITHUB_STEP_SUMMARY
Write-Host "✅ Tests executed via Invoke-Tests.ps1" >> $env:GITHUB_STEP_SUMMARY
$suite = if ($env:suite) { $env:suite } else { 'Integration' }
Write-Host "Suite: $suite" >> $env:GITHUB_STEP_SUMMARY
36 changes: 18 additions & 18 deletions .github/workflows/terraform-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
strategy:
matrix:
tier:
- azure-free-tier
- azure-tier2
- azure-tier3
- aws-pilot
- azure-hub-lab
- gcp-sandbox

steps:
- name: Checkout code
Expand Down Expand Up @@ -60,9 +60,9 @@ jobs:
strategy:
matrix:
tier:
- azure-free-tier
- azure-tier2
- azure-tier3
- aws-pilot
- azure-hub-lab
- gcp-sandbox

steps:
- name: Checkout code
Expand Down Expand Up @@ -101,9 +101,9 @@ jobs:
strategy:
matrix:
tier:
- azure-free-tier
- azure-tier2
- azure-tier3
- aws-pilot
- azure-hub-lab
- gcp-sandbox

steps:
- name: Checkout code
Expand Down Expand Up @@ -139,9 +139,9 @@ jobs:
strategy:
matrix:
tier:
- azure-free-tier
- azure-tier2
- azure-tier3
- aws-pilot
- azure-hub-lab
- gcp-sandbox

steps:
- name: Checkout code
Expand Down Expand Up @@ -172,9 +172,9 @@ jobs:
strategy:
matrix:
tier:
- azure-free-tier
- azure-tier2
- azure-tier3
- aws-pilot
- azure-hub-lab
- gcp-sandbox

steps:
- name: Checkout code
Expand All @@ -201,9 +201,9 @@ jobs:
strategy:
matrix:
tier:
- azure-free-tier
- azure-tier2
- azure-tier3
- aws-pilot
- azure-hub-lab
- gcp-sandbox

steps:
- name: Checkout code
Expand Down
Loading
Loading