Skip to content
Merged
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
35 changes: 15 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PowerShell CI
name: CI Pipeline

on:
push:
Expand All @@ -9,14 +9,14 @@ on:

jobs:
lint:
name: Lint and Style Check
name: Lint PowerShell Scripts
runs-on: ubuntu-latest

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

- name: Check for UTF-8 BOM
- name: Check UTF-8 BOM encoding
shell: pwsh
run: |
$invalidFiles = Get-ChildItem -Path . -Include *.ps1,*.psm1,*.psd1 -Recurse | Where-Object {
Expand All @@ -28,29 +28,28 @@ jobs:
foreach ($file in $invalidFiles) {
Write-Error "File '$($file.FullName)' is not encoded in UTF-8 BOM."
}
throw "Invalid file encoding found. All .ps1 files must be UTF-8 BOM."
throw "Invalid file encoding found."
} else {
Write-Host "::notice title=Encoding Check::All PowerShell files are UTF-8 BOM."
}

Write-Host "::notice title=Style Check::All PowerShell files are correctly encoded in UTF-8 BOM."

- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser
run: Install-Module PSScriptAnalyzer -Force -Scope CurrentUser

- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path . -Recurse -Severity Error,Warning
if ($results) {
$results | Format-Table
Write-Host "::notice title=Linting::PSScriptAnalyzer found issues."
throw "PSScriptAnalyzer found issues"
} else {
Write-Host "::notice title=Linting::No issues found."
}
Write-Host "::notice title=Linting::PSScriptAnalyzer passed with no errors or warnings."

test:
name: Pester Tests
name: Run Pester Tests
runs-on: ubuntu-latest
needs: lint

Expand All @@ -60,22 +59,18 @@ jobs:

- name: Install Pester
shell: pwsh
run: |
Install-Module Pester -Force -Scope CurrentUser -SkipPublisherCheck
run: Install-Module Pester -Force -Scope CurrentUser -SkipPublisherCheck

- name: Run Pester Tests
shell: pwsh
run: |
Import-Module Pester

if (Test-Path ./tests) {
Import-Module Pester
$config = New-PesterConfiguration
$config.Run.Path = "./tests"
$config.Run.Exit = $true
$config.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $config
}
else {
Write-Host "::notice title=Testing::No tests found in ./tests directory."
throw "Tests not found."
}
} else {
Write-Host "::notice title=Testing::No tests found."
}
62 changes: 38 additions & 24 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,71 @@ name: "CodeQL Analysis"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '0 0 * * 1' # Every Monday at midnight
workflow_dispatch:

jobs:
analyze:
name: Analyze
name: CodeQL JavaScript/TypeScript Scan
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript-typescript' ] # For node-based scripts in bin/
language: ['javascript-typescript']
timeout-minutes: 30

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-and-quality
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-and-quality

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: ${{ matrix.language }}

analyze-powershell:
name: PowerShell Security Scan
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
timeout-minutes: 20

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

- name: Run PSScriptAnalyzer (Security Only)
- name: Install PSScriptAnalyzer
shell: pwsh
run: Install-Module PSScriptAnalyzer -Force -Scope CurrentUser

- name: Run PowerShell Security Scan
shell: pwsh
run: |
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser
\$results = Invoke-ScriptAnalyzer -Path . -Recurse -Severity Error,Warning | Where-Object { \$_.RuleName -like "*Security*" }
if (\$results) {
\$results | Format-Table
Write-Host "::notice title=Security Scan::Potential security issues found in PowerShell scripts."
# Note: We might not want to fail the build on all warnings, but security is priority.
# Adjust folder path if needed, e.g., .\bin or .\src
$psFiles = Get-ChildItem -Path . -Include *.ps1,*.psm1 -Recurse
$results = Invoke-ScriptAnalyzer -Path $psFiles -Recurse -Severity Error,Warning |
Where-Object { $_.RuleName -like "*Security*" }

if ($results) {
$results | Format-Table
Write-Host "::error title=Security Scan::Potential security issues found in PowerShell scripts."
throw "Security issues detected by PSScriptAnalyzer"
} else {
Write-Host "::notice title=Security Scan::No common security issues found in PowerShell scripts."
}
}
42 changes: 0 additions & 42 deletions .github/workflows/deno.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/download-cert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Download TLS Certificate

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
download:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Download TLS Certificate
shell: pwsh
run: |
$certPath = ".\bin\checkScripts\download_ca_cert.pem"
if (Test-Path $certPath) {
$timestamp = Get-Date -Format yyyyMMddHHmmss
Rename-Item $certPath "$certPath.$timestamp.bak"
Write-Host "Existing certificate backed up."
}
node .\bin\checkScripts\runDownloadCert.js github.com
36 changes: 0 additions & 36 deletions .github/workflows/npm-publish-github-packages.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/powershell-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PowerShell CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
lint-and-test:
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Install PSScriptAnalyzer
shell: pwsh
run: Install-Module PSScriptAnalyzer -Force -Scope CurrentUser

- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path . -Recurse -Severity Error,Warning
if ($results) {
$results | Format-Table
throw "PSScriptAnalyzer found issues"
}

- name: Install Pester
shell: pwsh
run: Install-Module Pester -Force -Scope CurrentUser -SkipPublisherCheck

- name: Run Pester Tests
shell: pwsh
run: |
if (Test-Path ./tests) {
Import-Module Pester
Invoke-Pester -Path ./tests -Verbose
} else {
Write-Host "No Pester tests found."
}
28 changes: 0 additions & 28 deletions .github/workflows/webpack.yml

This file was deleted.

Loading
Loading