Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
74a6ff6
Updating test cases to run properly on windows and linux and started …
kormic911 Sep 7, 2025
753d0ff
Adding unit tests for homebrew related tasks.
kormic911 Sep 7, 2025
3c064a1
Fixing some linting issues.
kormic911 Sep 7, 2025
f60e306
Adding install-modules to the runSecurity.ps1 file.
kormic911 Sep 7, 2025
0686ca9
Fixing changes made my psscriptanalyzer when it was trying to 'help'
kormic911 Sep 7, 2025
507703d
Fixes for linux?
kormic911 Sep 7, 2025
7aee387
Fixing some capitalization issues mac doesnt like.
kormic911 Sep 7, 2025
b84a1c8
Fixing some more things that psscriptanalyzer 'fixed'.
kormic911 Sep 7, 2025
05d0fba
FIxing a couple more issues with the pester tests
kormic911 Sep 7, 2025
bd12ae7
FIxing an errant output that was causing a problem
kormic911 Sep 7, 2025
a912932
Updating workflows to run on PR's to main and develop and also adding…
kormic911 Sep 7, 2025
7a1406a
Adding copilot suggested correction.
kormic911 Sep 7, 2025
3261c93
Merge pull request #10 from pwshdevs/1.0.9-Features
kormic911 Sep 7, 2025
5f005e5
Fixing workflow to work with new branch permissions.
kormic911 Sep 7, 2025
7b5abc7
Adding ability to trigger workflow manually.
kormic911 Sep 7, 2025
47a2b24
Merge pull request #12 from pwshdevs/update-workflow
kormic911 Sep 7, 2025
164dbd3
Updating permissions on workflow.
kormic911 Sep 7, 2025
9a1888e
adding name to workflow.
kormic911 Sep 7, 2025
294bd32
Merge pull request #13 from pwshdevs/update-workflow
kormic911 Sep 7, 2025
b8d13d9
Adding custom token to allow for PR creation.
kormic911 Sep 7, 2025
a024439
Merge pull request #14 from pwshdevs/update-workflow
kormic911 Sep 7, 2025
6f05329
Automated Release Tagging for 1.0.9 in DevSetup.psd1
kormic911 Sep 7, 2025
1114b60
Merge pull request #15 from pwshdevs/update-release-version-to-1.0.9
kormic911 Sep 7, 2025
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
30 changes: 30 additions & 0 deletions .github/workflows/run-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run PSScriptAnalyzer Tests
on:
pull_request:
branches:
- develop
- main
workflow_dispatch:

jobs:
psscriptanalyzer:
name: PSScriptAnalyzer
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
checks: write
pull-requests: write
security-events: write
steps:
- uses: actions/checkout@v4
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: |
.\runSecurity.ps1

- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
token: ${{ secrets.GITHUB_TOKEN }}
80 changes: 80 additions & 0 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Run Pester Tests
on:
pull_request:
branches:
- develop
- main
workflow_dispatch:

jobs:
pester-test-linux:
name: Pester test (On Linux)
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Execute runTests.ps1
shell: pwsh
run: |
.\runTests.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: (!cancelled())
with:
check_name: Pester test (On Linux) Results
files: testResults.xml

pester-test-windows:
name: Pester test (On Windows)
runs-on: windows-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Execute runTests.ps1
shell: pwsh
run: |
.\runTests.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: (!cancelled())
with:
check_name: Pester test (On Windows) Results
files: testResults.xml

pester-test-macos:
name: Pester test (On macOS)
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Execute runTests.ps1
shell: pwsh
run: |
.\runTests.ps1
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: (!cancelled())
with:
check_name: Pester test (On macOS) Results
files: testResults.xml
23 changes: 18 additions & 5 deletions .github/workflows/update-module-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ on:
push:
branches:
- develop # Trigger on pushes to the main branch
workflow_dispatch:

jobs:
update_module_version:
name: Update Module Version
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
contents: write
issues: read
checks: write
pull-requests: write

steps:
- name: checkout
Expand All @@ -29,8 +34,16 @@ jobs:
run: |
perl -pi -e 's/[0-9]\.[0-9]\.[0-9]/${{ steps.version_tracker.outputs.version }}/' DevSetup/DevSetup.psd1

- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
# - name: Commit and push changes
# uses: stefanzweifel/git-auto-commit-action@v5
# with:
# commit_message: "Automated Release Tagging for ${{ steps.version_tracker.outputs.version }} in DevSetup.psd1"
# branch:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit_message: "Automated Release Tagging for ${{ steps.version_tracker.outputs.version }} in DevSetup.psd1"
branch: develop
commit-message: Automated Release Tagging for ${{ steps.version_tracker.outputs.version }} in DevSetup.psd1
title: Automated Release Tagging for ${{ steps.version_tracker.outputs.version }} in DevSetup.psd1
body: Changing version to ${{ steps.version_tracker.outputs.version }}
branch: update-release-version-to-${{ steps.version_tracker.outputs.version }}
token: ${{ secrets.WORKFLOW_TOKEN }}
2 changes: 1 addition & 1 deletion DevSetup/DevSetup.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'DevSetup.psm1'

# Version number of this module.
ModuleVersion = '1.0.8'
ModuleVersion = '1.0.9'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ BeforeAll {
. $PSScriptRoot\ConvertFrom-3rdPartyInstall.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\3rdParty\VisualStudio\ConvertFrom-VisualStudioInstall.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\3rdParty\VisualStudioCode\ConvertFrom-VisualStudioCodeInstall.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\Utils\Test-OperatingSystem.ps1
Mock Write-Host { }
Mock Write-Warning { }
Mock ConvertFrom-VisualStudioInstall { $true }
Mock ConvertFrom-VisualStudioCodeInstall { $true }
Mock Test-OperatingSystem { $true }
}

Describe "ConvertFrom-3rdPartyInstall" {
Expand Down
20 changes: 11 additions & 9 deletions DevSetup/Private/3rdParty/ConvertFrom-3rdPartyInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ Function ConvertFrom-3rdPartyInstall {
[string]$Config
)

# Convert from Visual Studio installations
Write-Host "`nScanning Visual Studio installations..." -ForegroundColor Cyan
if (-not (ConvertFrom-VisualStudioInstall -Config $Config)) {
Write-Warning "Failed to convert Visual Studio installations, but continuing..."
}
if((Test-OperatingSystem -Windows)) {
# Convert from Visual Studio installations
Write-Host "`nScanning Visual Studio installations..." -ForegroundColor Cyan
if (-not (ConvertFrom-VisualStudioInstall -Config $Config)) {
Write-Warning "Failed to convert Visual Studio installations, but continuing..."
}

# Convert from Visual Studio Code installations
Write-Host "`nScanning Visual Studio Code installation..." -ForegroundColor Cyan
if (-not (ConvertFrom-VisualStudioCodeInstall -Config $Config)) {
Write-Warning "Failed to convert Visual Studio Code installation, but continuing..."
# Convert from Visual Studio Code installations
Write-Host "`nScanning Visual Studio Code installation..." -ForegroundColor Cyan
if (-not (ConvertFrom-VisualStudioCodeInstall -Config $Config)) {
Write-Warning "Failed to convert Visual Studio Code installation, but continuing..."
}
}
}
94 changes: 73 additions & 21 deletions DevSetup/Private/Commands/Export-DevSetupEnv.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,50 +1,102 @@
BeforeAll {
. $PSScriptRoot\Export-DevSetupEnv.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\Utils\Get-DevSetupEnvPath.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\Utils\Get-DevSetupLocalEnvPath.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\Utils\Get-DevSetupCommunityEnvPath.ps1
. $PSScriptRoot\..\..\..\DevSetup\Private\Utils\Write-NewConfig.ps1
Mock Get-DevSetupEnvPath { "TestDrive:\DevSetupEnvs" }
Mock Get-DevSetupLocalEnvPath { "TestDrive:\DevSetupEnvs\local"}
Mock Get-DevSetupCommunityEnvPath { "TestDrive:\DevSetupEnvs\community"}
. (Join-Path $PSScriptRoot "Export-DevSetupEnv.ps1")
. (Join-Path $PSScriptRoot "..\..\..\DevSetup\Private\Utils\Get-DevSetupEnvPath.ps1")
. (Join-Path $PSScriptRoot "..\..\..\DevSetup\Private\Utils\Get-DevSetupLocalEnvPath.ps1")
. (Join-Path $PSScriptRoot "..\..\..\DevSetup\Private\Utils\Get-DevSetupCommunityEnvPath.ps1")
. (Join-Path $PSScriptRoot "..\..\..\DevSetup\Private\Utils\Write-NewConfig.ps1")
. (Join-Path $PSScriptRoot "..\..\..\DevSetup\Private\Utils\Write-StatusMessage.ps1")
if ($PSVersionTable.PSVersion.Major -eq 5) {
Mock Get-DevSetupEnvPath { "$TestDrive\DevSetup\DevSetupEnvs" }
Mock Get-DevSetupLocalEnvPath { "$TestDrive\DevSetup\DevSetupEnvs\local" }
Mock Get-DevSetupCommunityEnvPath { "$TestDrive\DevSetup\DevSetupEnvs\community" }
} elseif ($PSVersionTable.PSVersion.Major -ge 6) {
if ($IsWindows) {
Mock Get-DevSetupEnvPath { "$TestDrive\DevSetup\DevSetupEnvs" }
Mock Get-DevSetupLocalEnvPath { "$TestDrive\DevSetup\DevSetupEnvs\local" }
Mock Get-DevSetupCommunityEnvPath { "$TestDrive\DevSetup\DevSetupEnvs\community" }
}
if ($IsLinux) {
Mock Get-DevSetupEnvPath { "$TestDrive/home/testuser/DevSetup/DevSetupEnvs" }
Mock Get-DevSetupLocalEnvPath { "$TestDrive/home/testuser/DevSetup/DevSetupEnvs/local" }
Mock Get-DevSetupCommunityEnvPath { "$TestDrive/home/testuser/DevSetup/DevSetupEnvs/community" }
}
if ($IsMacOS) {
Mock Get-DevSetupEnvPath { "$TestDrive/Users/TestUser/DevSetup/DevSetupEnvs" }
Mock Get-DevSetupLocalEnvPath { "$TestDrive/Users/TestUser/DevSetup/DevSetupEnvs/local" }
Mock Get-DevSetupCommunityEnvPath { "$TestDrive/Users/TestUser/DevSetup/DevSetupEnvs/community" }
}
}
Mock Write-NewConfig { param($OutFile) $OutFile }
Mock Write-Host { }
Mock Write-Error { }
Mock Write-StatusMessage { }
}

Describe "Export-DevSetupEnv" {

Context "When called with a valid name" {
It "Should create the config file and return its path" {
$result = Export-DevSetupEnv -Name "MyEnv"
$result | Should -Be "TestDrive:\DevSetupEnvs\local\MyEnv.devsetup"
Assert-MockCalled Write-NewConfig -Exactly 1 -Scope It -ParameterFilter { $OutFile -eq "TestDrive:\DevSetupEnvs\local\MyEnv.devsetup" }
Assert-MockCalled Write-Host -Scope It -ParameterFilter { $Object -match "exported to" -and $ForegroundColor -eq "Green" }
if ($PSVersionTable.PSVersion.Major -eq 5 -or ($PSVersionTable.PSVersion.Major -ge 6 -and $IsWindows)) {
$expectedPath = "$TestDrive\DevSetup\DevSetupEnvs\local\MyEnv.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsLinux) {
$expectedPath = "$TestDrive/home/testuser/DevSetup/DevSetupEnvs/local/MyEnv.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsMacOS) {
$expectedPath = "$TestDrive/Users/TestUser/DevSetup/DevSetupEnvs/local/MyEnv.devsetup"
}
$result | Should -Be $expectedPath
Assert-MockCalled Write-NewConfig -Exactly 1 -Scope It -ParameterFilter { $OutFile -eq $expectedPath }
Assert-MockCalled Write-StatusMessage -Scope It -ParameterFilter { $Message -match "exported to" -and $ForegroundColor -eq "Green" }
}
}

Context "When called with a valid path" {
It "Should create the config file and return its path" {
$result = Export-DevSetupEnv -Path "TestDrive:\MyCustomPath\MyEnv.devsetup"
$result | Should -Be "TestDrive:\MyCustomPath\MyEnv.devsetup"
Assert-MockCalled Write-NewConfig -Exactly 1 -Scope It -ParameterFilter { $OutFile -eq "TestDrive:\MyCustomPath\MyEnv.devsetup" }
Assert-MockCalled Write-Host -Scope It -ParameterFilter { $Object -match "exported to" -and $ForegroundColor -eq "Green" }
if ($PSVersionTable.PSVersion.Major -eq 5 -or ($PSVersionTable.PSVersion.Major -ge 6 -and $IsWindows)) {
$result = Export-DevSetupEnv -Path "$TestDrive\MyCustomPath\MyEnv.devsetup"
$expectedPath = "$TestDrive\MyCustomPath\MyEnv.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsLinux) {
$result = Export-DevSetupEnv -Path "$TestDrive/MyCustomPath/MyEnv.devsetup"
$expectedPath = "$TestDrive/MyCustomPath/MyEnv.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsMacOS) {
$result = Export-DevSetupEnv -Path "$TestDrive/MyCustomPath/MyEnv.devsetup"
$expectedPath = "$TestDrive/MyCustomPath/MyEnv.devsetup"
}
$result | Should -Be $expectedPath
Assert-MockCalled Write-NewConfig -Exactly 1 -Scope It -ParameterFilter { $OutFile -eq $expectedPath }
Assert-MockCalled Write-StatusMessage -Scope It -ParameterFilter { $Message -match "exported to" -and $ForegroundColor -eq "Green" }
}
}

Context "When called with a name that needs sanitization" {
It "Should sanitize the name and warn" {
$result = Export-DevSetupEnv -Name "Data Science Environment!"
$result | Should -Be "TestDrive:\DevSetupEnvs\local\DataScienceEnvironment.devsetup"
Assert-MockCalled Write-Host -Scope It -ParameterFilter { $Object -match "sanitized" -and $ForegroundColor -eq "Yellow" }
if ($PSVersionTable.PSVersion.Major -eq 5 -or ($PSVersionTable.PSVersion.Major -ge 6 -and $IsWindows)) {
$expectedPath = "$TestDrive\DevSetup\DevSetupEnvs\local\DataScienceEnvironment.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsLinux) {
$expectedPath = "$TestDrive/home/testuser/DevSetup/DevSetupEnvs/local/DataScienceEnvironment.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsMacOS) {
$expectedPath = "$TestDrive/Users/TestUser/DevSetup/DevSetupEnvs/local/DataScienceEnvironment.devsetup"
}
$result | Should -Be $expectedPath
Assert-MockCalled Write-StatusMessage -Scope It -ParameterFilter { $Message -match "sanitized" -and $ForegroundColor -eq "Yellow" }
}
}

Context "When called with a path that needs sanitization" {
It "Should sanitize the path and warn" {
$result = Export-DevSetupEnv -Path "TestDrive:\MyCustomPath\MyEnv!.devsetup"
$result | Should -Be "TestDrive:\MyCustomPath\MyEnv.devsetup"
Assert-MockCalled Write-Host -Scope It -ParameterFilter { $Object -match "sanitized" -and $ForegroundColor -eq "Yellow" }
if ($PSVersionTable.PSVersion.Major -eq 5 -or ($PSVersionTable.PSVersion.Major -ge 6 -and $IsWindows)) {
$result = Export-DevSetupEnv -Path "$TestDrive\MyCustomPath\MyEnv!.devsetup"
$expectedPath = "$TestDrive\MyCustomPath\MyEnv.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsLinux) {
$result = Export-DevSetupEnv -Path "$TestDrive/MyCustomPath/MyEnv!.devsetup"
$expectedPath = "$TestDrive/MyCustomPath/MyEnv.devsetup"
} elseif ($PSVersionTable.PSVersion.Major -ge 6 -and $IsMacOS) {
$result = Export-DevSetupEnv -Path "$TestDrive/MyCustomPath/MyEnv!.devsetup"
$expectedPath = "$TestDrive/MyCustomPath/MyEnv.devsetup"
}
$result | Should -Be $expectedPath
Assert-MockCalled Write-StatusMessage -Scope It -ParameterFilter { $Message -match "sanitized" -and $ForegroundColor -eq "Yellow" }
}
}

Expand All @@ -53,7 +105,7 @@ Describe "Export-DevSetupEnv" {
Mock Write-NewConfig { param($OutFile) $null }
$result = Export-DevSetupEnv -Name "FailEnv"
$result | Should -Be $null
Assert-MockCalled Write-Error -Exactly 1 -Scope It -ParameterFilter { $Message -match "Failed to create configuration file" }
Assert-MockCalled Write-StatusMessage -Exactly 1 -Scope It -ParameterFilter { $Message -match "Failed to create configuration file" -and $Verbosity -eq "Error" }
}
}
}
Loading
Loading