Skip to content

Fix Scorecard alerts: add SAST workflow, AGENTS.md, and branch protection #77

Fix Scorecard alerts: add SAST workflow, AGENTS.md, and branch protection

Fix Scorecard alerts: add SAST workflow, AGENTS.md, and branch protection #77

Workflow file for this run

name: Run Pester Tests
on:
pull_request:
branches: [ main ]
workflow_dispatch:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
if: 1 == 2 # the dockercommand needs to gets fixed and execute the test
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@6c3c2f2c1c457b00c10c4848d6f5491db3b629df # v2.18.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
- name: Build Docker image
run: docker build . -f .devcontainer/Dockerfile -t unittest-image
- name: Run Pester tests in the container
run: |
# run the container with the source code mounted as a volume
docker run --name unittest-container -v ${{ github.workspace }}:/workspace -d unittest-image
echo "Running a test command"
docker exec unittest-container pwsh -Command { Write-Host "Hi" }
echo "Running the tests"
docker exec unittest-container pwsh -Command {
try {
Write-Host "Running Pester tests inside the container"
ls
cd workspace
ls
cd ..
Invoke-Pester -Path workspace
Write-Host "Pester tests completed"
} catch {
Write-Host "Error: $_"
exit 1
}
}
- name: Output Docker logs
if: ${{ failure() }}
run: docker logs unittest-container
test-direct:
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@6c3c2f2c1c457b00c10c4848d6f5491db3b629df # v2.18.0
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
- name: Run Pester tests
run: |
try {
Write-Host "Running Pester tests"
Invoke-Pester -Path . -OutputFormat NUnitXml -OutputFile TestResults.xml
Write-Host "Pester tests completed"
} catch {
Write-Host "Error: $_"
exit 1
}
- name: Set GITHUB_STEP_SUMMARY
run: |
[xml]$testResults = Get-Content -Path TestResults.xml
Write-Host $testResults
$markdownTableRows = $testResults.'test-results'.'test-suite'.results.'test-suite' | ForEach-Object {
"| $($_.name) | $($_.executed) | $($_.result) | $($_.success) |"
}
$markdownTableLines = $markdownTableRows -join "`n"
$markdownTable = "| Test Name | Executed | Result | Success |`n| --- | --- | --- | --- |`n $markdownTableLines"
echo "$markdownTable" >> $env:GITHUB_STEP_SUMMARY