Skip to content

Commit

Permalink
Merge pull request Azure#382 from jfaurskov/fix-arm-ttk
Browse files Browse the repository at this point in the history
Fix ARM-ttk issue
  • Loading branch information
JoeyBarnes authored Oct 22, 2024
2 parents fe29ac8 + 05ed201 commit 9b599cf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 74 deletions.
72 changes: 0 additions & 72 deletions .github/actions-pester/Test-ArmTemplates.Tests.ps1

This file was deleted.

51 changes: 49 additions & 2 deletions .github/workflows/unit-test-arm-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,60 @@ jobs:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Get all changed ARM files
id: changed-arm-files
uses: tj-actions/changed-files@v45
with:
files: |
services/**/**/templates/arm/**.json
- name: List all changed ARM files
if: steps.changed-arm-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-arm-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "File changed: $file"
done
- name: Clone ARM-TTK repo
uses: GuillaumeFalourd/clone-github-repo-action@v3
with:
owner: 'Azure'
repository: 'arm-ttk'
- name: Test Modified ARM templates
id: run_tests
if: steps.changed-arm-files.outputs.any_changed == 'true'
shell: pwsh
run: |
$changedFiles = "${{ steps.changed-arm-files.outputs.all_changed_files }}"
$changedFiles = $changedFiles -split ' '
# Initialize a counter for the number of failed tests
$NumberOfFailedTests = 0
If ($changedFiles -ne $null) {
Import-Module ./arm-ttk/arm-ttk/arm-ttk.psd1
$changedFiles | ForEach-Object {
$armFile = $PSItem
write-output "Testing $armFile"
Test-AzTemplate -TemplatePath $armFile -Test deploymentTemplate -ErrorAction Continue
$testResults = Test-AzTemplate -TemplatePath $armFile -Test deploymentTemplate -ErrorAction Continue
# Filter the test results to find any failed tests
$failedTests = $testResults | Where-Object { $PSItem.Passed -ne $True }
# If there are failed tests, increment the failed tests counter
if ($failedTests -ne $null) {
$failedTests | ForEach-Object {
$NumberOfFailedTests++
}
}
}
}
echo "failtests=$NumberOfFailedTests"
Add-Content -Path $env:GITHUB_ENV -Value "failtests=$NumberOfFailedTests"
continue-on-error: true
- name: Check for failed tests
id: check_fail
shell: pwsh
run: |
Import-Module ./arm-ttk/arm-ttk/arm-ttk.psd1
./.github/actions-pester/Test-ArmTemplates.Tests.ps1
echo "Number of failed tests: ${{ env.failtests }}"
If (${{ env.failtests }} -gt 0) {
echo "Failed tests found, see previous step for details"
exit 1
}

0 comments on commit 9b599cf

Please sign in to comment.