Skip to content

Commit a5cefc8

Browse files
authored
Merge pull request #48 from fadwen/ci/linux-analysis
ci(help): analyze a folder of fixtures with Test-IntuneScript on Linux
2 parents dcee2b2 + ea8c541 commit a5cefc8

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎.github/workflows/quality-gates.yml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,40 @@ jobs:
362362
throw 'MAML help was not served on a case-sensitive filesystem.'
363363
}
364364
Write-Host 'All commands served full help from MAML.'
365+
366+
# The static analysis is the one part of the module a Linux host can use: it needs the
367+
# file and nothing else. This step keeps that true. The script type is inferred from
368+
# folder names, so the fixtures use the layouts the suite template describes, with the
369+
# separators this host writes; the harness and the log readers stay Windows-only.
370+
- name: Analyze scripts on Linux
371+
shell: pwsh
372+
run: |
373+
$ErrorActionPreference = 'Stop'
374+
Import-Module ./IntuneScriptLab.psd1 -Force
375+
376+
$root = Join-Path ([System.IO.Path]::GetTempPath()) "isl-linux-$([guid]::NewGuid().ToString('N'))"
377+
$remediation = Join-Path $root 'Remediations/Widget'
378+
$win32 = Join-Path $root 'Win32/Widget'
379+
New-Item -ItemType Directory -Path $remediation, $win32 -Force | Out-Null
380+
# return before exit 1: the remediation never runs (IslExitCodeIssue, Error)
381+
Set-Content -Path (Join-Path $remediation 'Detect.ps1') -Value "if (Test-Path /tmp/x) { return 'ok' }`nexit 1"
382+
# exit 0 with nothing on stdout: the app is never detected (IslOutputIssue, Error)
383+
Set-Content -Path (Join-Path $win32 'Detect.ps1') -Value "if (Test-Path /tmp/x) { exit 0 }`nexit 1"
384+
385+
$findings = @(Test-IntuneScript -Path $root)
386+
$findings | Format-Table Severity, RuleName, Line, @{ n = 'Script'; e = { Split-Path (Split-Path $_.ScriptPath) -Leaf } } -AutoSize | Out-String | Write-Host
387+
388+
$failed = @()
389+
$exit = @($findings | Where-Object { $_.RuleName -eq 'IslExitCodeIssue' -and $_.Severity -eq 'Error' -and $_.ScriptPath -like '*Remediations*' })
390+
if (-not $exit) { $failed += 'the return-before-exit detection was not reported' }
391+
$output = @($findings | Where-Object { $_.RuleName -eq 'IslOutputIssue' -and $_.Severity -eq 'Error' -and $_.ScriptPath -like '*Win32*' })
392+
if (-not $output) { $failed += 'the silent Win32 detection was not reported' }
393+
$context = @($findings | Where-Object { $_.RuleName -eq 'IslAssumedContext' -and $_.Message -like '*Win32Detection*' })
394+
if (-not $context) { $failed += 'the Win32 folder did not set the script type' }
395+
Remove-Item -Path $root -Recurse -Force
396+
397+
if ($failed) {
398+
$failed | ForEach-Object { Write-Host "FAILED: $_" }
399+
throw 'Test-IntuneScript did not analyze the fixtures on Linux.'
400+
}
401+
Write-Host 'Test-IntuneScript analyzed both fixtures on Linux with the expected findings.'

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ release notes.
1313

1414
### Changed
1515

16+
- The `help` job in `quality-gates.yml`, the one that runs on Linux, also analyzes a folder of two
17+
fixture scripts with `Test-IntuneScript` and fails unless the return-before-exit detection and the
18+
silent Win32 detection are reported with the script type taken from the folder names. The static
19+
analysis needs only the file, and that is now tested where it is claimed.
1620
- `Validation/Findings.md` records an enrollment of the Windows 11 Home ARM64 device: in 75 minutes
1721
and 11 syncs the service never sent the Intune Management Extension, so the agent's behaviour on
1822
ARM64 stays a host survey until a Pro or Enterprise ARM64 device is available. The LAPS

‎CLAUDE.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ backslash entry names (build zips entry by entry with forward slashes).
6868

6969
The harness launches `powershell.exe` hosts by architecture, reads the registry and registers
7070
scheduled tasks, so the suites run on Windows only: the `desktop` job under 5.1 and the `arm64`
71-
job on Windows on ARM. The `help` job proves the module imports on Linux; nothing else there runs.
71+
job on Windows on ARM. The `help` job proves the module imports on Linux and that
72+
`Test-IntuneScript` analyzes a folder there, with the script type inferred from forward-slash
73+
paths; no suite and no harness run there.
7274

7375
### Variable names are case-insensitive, and nested functions have their own `$PSBoundParameters`
7476

0 commit comments

Comments
 (0)