Skip to content

Commit

Permalink
Break up private functions & search menu bugfix (re-release) (#154)
Browse files Browse the repository at this point in the history
* Break up private functions & search menu bugfix (#152)

* copied functions into new directory

* Move Start Migration

* remove functions from start-migration

* move form

* Changes for Form

* move progress form

* process by owner changes

* progress forms changes

* Assets file for forms

* Get-ImageFromB64

* Function Names

* rename Build-Exe

* 2.7.11 version + build module functions

* change patch for new-admuTemplate

* pester tests

* CI changes for functions location

* functions tests

* update several variable names in test /ci

* paths for tests

* update Build tests

* Update VS Settings

* paths for tests

* Get-SID replace

* migration tests paths

* migration tests paths

* remove start-jcadmu.ps1 file

* escape $pid

* write out log content

* skip tests and validate log location in build runner

* not tail log lines

* Write-ToLog shouldn't terminate when writing an error

* order in error messages

* skip functions tests + why are we using silentlyContinue?

* can't skip functions tests

* write-error should be write-warnings until final throw message

* tail and validate local users

* version of artifact action

* add param to build [skip ci]

* write out additional debugging

* CUT-4541 - reinstall search/ start appx for all devices (not just windows 10)

* fixed migration tests by importing the module instead of calling start migration (which no longer contains any private functions)

* variable names and logging changes

* set systemKey in migration tests

* Variable names

* form elements, update to xaml form for MTP selection

* manual tests for uwp + selection form

* mtp selection form background + size

* form changes for selecting another MTP org, manual tests

* Form changes, test-button function updated to test various cases in helper functions

* automate tests for selection form Test-MigrationButton

* test the selection form in ci

* mock names

* Only show option to change ORG is MTP admin is returned

* CUT-4589 Test for selection form on non-valid SID users

* change placeholder text in progress form

* update form to declare form elements before submission

* Add focus controls to prevent checking the name each time a character is pressed (team to discuss)

* CUT-4589 Test-LocalUsername fix

* resolve changes with Get-MtpOrganization tests

* skip migration tests

* manual tests + changes to form, no default password

* updates for local-username tests

* test local username changes

* build date

* update start-migration for Get-MtpOrganization changes

* Update form changes/ test-localUsername

* remove throw in Test-LocalUserName, some devices might not have a user profile to validate like CI

* variable name

* update test-localUsernames after user is created

* temp password should show valid when first viewing the selection form

* incorrectly defined manual test

* show error for username matching hostname

* space in mtp selection

* comment out tests mocking for CI

* update build to run in PS5.1 environments

* build admu exe on windows hosts only

* 5.1 build exe on windows hosts

* update build tests now that we've moved the locations of all the function files

* release from PSD1 version if manual release

* re-validate exe file versions

* Test exe in build tests

* use artifact files for exe tests

* exe location
  • Loading branch information
jworkmanjc authored Jan 30, 2025
1 parent fde7a5d commit c6fc37c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/admu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ jobs:
${{ github.workspace }}/Jumpcloud-ADMU/PowerShell/Public/**/*.ps1
${{ github.workspace }}/Jumpcloud-ADMU/JumpCloud.ADMU.psd1
${{ github.workspace }}/Jumpcloud-ADMU/JumpCloud.ADMU.psm1
${{ github.workspace }}/Jumpcloud-ADMU/Exe/*.exe
retention-days: 1
Test-Module:
needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Build-Module"]
Expand All @@ -148,6 +149,8 @@ jobs:
uses: actions/download-artifact@v4
with:
name: jumpcloud-admu-build
- name: Display structure of downloaded files
run: ls -R
- uses: actions/cache@v4
with:
path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\'
Expand Down
2 changes: 1 addition & 1 deletion Deploy/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if ($ModuleVersionType -eq 'manual') {
# Create a new ADMU Template file in this directory for testing/ Building EXE (default hide debug pwsh window)
New-ADMUTemplate -ExportPath "$PSScriptRoot/admuTemplate.ps1" -hidePowerShellWindow $true
# Run Build-Exe On Windows Systems
if ($IsWindows) {
if ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
. $PSScriptRoot\New-ADMUExe.ps1
}
# Run Build-HelpFiles
Expand Down
45 changes: 31 additions & 14 deletions jumpcloud-ADMU/Powershell/Tests/Build.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ Describe "Module Validation Tests" {
Write-Error -Message "Failed to import function $($Import.FullName): $_"
}
}
# Get PSD1 Version:
if ($env:ModuleVersionType -eq "manual") {

$psd1Content = Get-Content -Path "$PSScriptRoot\..\..\JumpCloud.ADMU.psd1"
$psd1Regex = "ModuleVersion[\s\S]+(([0-9]+)\.([0-9]+)\.([0-9]+))"
$psd1VersionMatch = Select-String -InputObject:($psd1Content) -Pattern:($psd1Regex)
$psd1Version = [version]$psd1VersionMatch.Matches.Groups[1].value
write-host "psd1version $psd1Version"
}



}

Expand All @@ -35,13 +46,13 @@ Describe "Module Validation Tests" {
$progressFormCmd = Get-Command New-ProgressForm
$progressFormVersion = $progressFormCmd.Definition | Select-String -Pattern:($VersionRegex)
$branchProgressFormVersion = [version]$progressFormVersion.Matches.value
$masterProgressForm = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/ProgressForm.ps1 -useBasicParsing).ToString()
$masterProgressForm = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Private/DisplayForms/ProgressForm.ps1 -useBasicParsing).ToString()
$masterVersion = Select-String -InputObject:($masterProgressForm) -Pattern:($VersionRegex)
$masterProgressFormVersion = [version]$masterVersion.Matches.value
if ($env:ModuleVersionType -eq "manual") {
# Manual Versioning
# Given version should be greater than master
$branchProgressFormVersion | Should -BeGreaterThan $masterProgressFormVersion
$branchProgressFormVersion | Should -be $psd1Version
} else {
$branchProgressFormVersion | Should -BeGreaterThan $masterProgressFormVersion
$branchProgressFormVersion.$($env:ModuleVersionType) | Should -Be ($masterProgressFormVersion.$($env:ModuleVersionType) + 1)
Expand All @@ -53,13 +64,13 @@ Describe "Module Validation Tests" {
$formCmd = Get-Command Show-SelectionForm
$formVersion = $formCmd.Definition | Select-String -Pattern:($VersionRegex)
$branchFormVersion = [version]$formVersion.Matches.value
$masterForm = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Form.ps1 -useBasicParsing).ToString()
$masterForm = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Private/DisplayForms/Form.ps1 -useBasicParsing).ToString()
$masterVersion = Select-String -InputObject:($masterForm) -Pattern:($VersionRegex)
$masterFormVersion = [version]$masterVersion.Matches.value
if ($env:ModuleVersionType -eq "manual") {
# Manual Versioning
# Given version should be greater than master
$branchFormVersion | Should -BeGreaterThan $masterFormVersion
$branchFormVersion | Should -be $psd1Version
} else {
$branchFormVersion | Should -BeGreaterThan $masterFormVersion
$branchFormVersion.$($env:ModuleVersionType) | Should -Be ($masterFormVersion.$($env:ModuleVersionType) + 1)
Expand All @@ -72,28 +83,34 @@ Describe "Module Validation Tests" {
$startMigrationCmd = Get-Command Start-Migration
$admuVersion = $startMigrationCmd.Definition | Select-String -Pattern:($VersionRegex)
$branchStartMigrationVersion = [version]$admuVersion.Matches.value
$masterStartMigration = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Start-Migration.ps1 -useBasicParsing).ToString()
$masterStartMigration = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Public/Start-Migration.ps1 -useBasicParsing).ToString()
$masterVersion = Select-String -InputObject:($masterStartMigration) -Pattern:($VersionRegex)
$masterStartMigrationVersion = [version]$masterVersion.Matches.value
if ($env:ModuleVersionType -eq "manual") {
$branchStartMigrationVersion | Should -BeGreaterThan $masterStartMigrationVersion
$branchStartMigrationVersion | Should -be $psd1Version
} else {
$branchStartMigrationVersion | Should -BeGreaterThan $masterStartMigrationVersion
$branchStartMigrationVersion.$($env:ModuleVersionType) | Should -Be ($masterStartMigrationVersion.$($env:ModuleVersionType) + 1)
}
}

It 'gui_jcadmu.exe version' -skip {
It 'gui_jcadmu.exe/ uwp_jcadmu.exe versions' {
$VersionRegex = [regex]'(?<=Title="JumpCloud ADMU )([0-9]+)\.([0-9]+)\.([0-9]+)'
$masterForm = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Form.ps1 -useBasicParsing).ToString()
$masterForm = (Invoke-WebRequest https://raw.githubusercontent.com/TheJumpCloud/jumpcloud-ADMU/master/jumpcloud-ADMU/Powershell/Private/DisplayForms/Form.ps1 -useBasicParsing).ToString()
$masterVersion = Select-String -InputObject:($masterForm) -Pattern:($VersionRegex)
$masterFormVersion = [version]$masterVersion.Matches.value
$exeVersion = [version](Get-Item ("$PSScriptRoot\..\..\exe\gui_jcadmu.exe")).VersionInfo.FileVersion
$gui_exePathFromArtifact = "$PSScriptRoot\..\..\..\Exe\gui_jcadmu.exe"
$uwp_exePathFromArtifact = "$PSScriptRoot\..\..\..\Exe\uwp_jcadmu.exe"
$gui_exeVersion = [version](Get-Item ("$gui_exePathFromArtifact")).VersionInfo.FileVersion
$wup_exeVersion = [version](Get-Item ("$uwp_exePathFromArtifact")).VersionInfo.FileVersion
if ($env:ModuleVersionType -eq "manual") {
$exeVersion | Should -BeGreaterThan $masterFormVersion
$gui_exeVersion | Should -be $psd1Version
$wup_exeVersion | Should -be $psd1Version
} else {
$exeVersion | Should -BeGreaterThan $masterFormVersion
$exeVersion.$($env:ModuleVersionType) | Should -Be ($masterFormVersion.$($env:ModuleVersionType) + 1)
$gui_exeVersion | Should -BeGreaterThan $masterFormVersion
$gui_exeVersion.$($env:ModuleVersionType) | Should -Be ($masterFormVersion.$($env:ModuleVersionType) + 1)
$wup_exeVersion | Should -BeGreaterThan $masterFormVersion
$wup_exeVersion.$($env:ModuleVersionType) | Should -Be ($masterFormVersion.$($env:ModuleVersionType) + 1)
}
}
}
Expand All @@ -113,7 +130,7 @@ Describe "Module Validation Tests" {
Write-Host "Module Changelog Version: $ModuleChangelogVersion"
$latestVersion = [version]$latestModule.version
if ($env:ModuleVersionType -eq "manual") {
$ModuleChangelogVersion | Should -BeGreaterThan $latestVersion
$ModuleChangelogVersion | Should -be $psd1Version
} else {
([version]$ModuleChangelogVersion).$($env:ModuleVersionType) | Should -Be ($latestVersion.$($env:ModuleVersionType) + 1)
}
Expand All @@ -131,7 +148,7 @@ Describe "Module Validation Tests" {
$Docs = Get-ChildItem -Path $FolderPath_Docs -Filter "*.md"
Write-Host $Docs
foreach ($item in $Docs) {
Write-Host "testing ::::: $($item)"
Write-Host "Validating documentation for doc file: $($item)"
$diff = git diff -- $item.fullname
if ($diff) {
write-warning "diff found in file: $($item.fullname) when we expected none to exist; have you run build.ps1 and committed the resulting changes?"
Expand Down

0 comments on commit c6fc37c

Please sign in to comment.