Skip to content

Commit

Permalink
Merge branch 'SA-3610_GHA_Workflow_Migrations' into SA-3610_GHA_Workf…
Browse files Browse the repository at this point in the history
…low_Migrations_Ken
  • Loading branch information
jworkmanjc authored Nov 9, 2023
2 parents b1de6f7 + 39b8c02 commit 58bdd57
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 6 deletions.
143 changes: 138 additions & 5 deletions .github/workflows/jcapi-powershell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
Check-If-Merged:
# will be switched to true
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Check if Merged
run: echo {GITHUB_HEAD_REF} merged into master
Check-PR-Labels:
needs: ["Check-If-Merged"]
runs-on: ubuntu-latest
outputs:
RELEASE_TYPE: ${{ steps.validate.outputs.RELEASE_TYPE }}
Expand All @@ -18,6 +26,9 @@ jobs:
shell: pwsh
run: |
$PR_LABEL_LIST=$(curl -s "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels" | jq -r '.[].name')
if ("SDK" -in $PR_LABEL_LIST) {
write-host "Starting Build for PowerShell SDK Release"
}
# validate type from label list:
$types = @('major', 'minor', 'patch', 'manual')
$typeCount = 0
Expand All @@ -28,7 +39,6 @@ jobs:
$RELEASE_TYPE = $item
}
}
if ($typeCount -eq 1) {
echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT
} else {
Expand All @@ -48,8 +58,131 @@ jobs:
run: |
Install-Module -Name Pester
Invoke-Pester -Path /home/runner/work/jcapi-powershell/jcapi-powershell/Tools/ModuleValidation.Tests.ps1
Test-SDK-MTP:
needs: ["Setup-Build-Dependancies", "Build-SDK", "Invoke-Pester"]
runs-on: ubuntu-latest
timeout-minutes: 70
strategy:
fail-fast: false
matrix:
SDKName: ['JumpCloud.SDK.V1', 'JumpCloud.SDK.V2']
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: "/home/runner/.local/share/powershell/Modules/"
key: PS-Dependancies
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.SDKName }}
path: /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/
- name: Unzip ${{ matrix.SDKName }} module
shell: pwsh
run: |
Expand-Archive -Path /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/${{ matrix.SDKName }}.zip -DestinationPath /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/ -Force
- uses: actions/download-artifact@v3
with:
name: build-JumpCloud.SDK.V1
path: /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/
if: matrix.SDKName == 'JumpCloud.SDK.V2'
- name: Unzip V1 module for V2 Tests
shell: pwsh
run: |
Expand-Archive -Path /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.V1.zip -DestinationPath /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/ -Force
if: matrix.SDKName == 'JumpCloud.SDK.V2'
- name: Test MTP ${{ matrix.SDKName }}
shell: pwsh
env:
PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }}
PESTER_ORGID: ${{ secrets.PESTER_ORGID }}
PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }}
PESTER_PROVIDERID: ${{ secrets.PESTER_PROVIDERID }}
run: |
$ErrorActionnPreference = 'Stop'
./Test-Module.ps1 -JCApiKey:($env:PESTER_APIKEY) -JCOrgId:($env:PESTER_ORGID) -JCApiKeyMTP:($env:PESTER_MSP_APIKEY) -JCProviderId:($env:PESTER_PROVIDERID) -ExcludeTagList:("None") -IncludeTagList:("MTP") -testModulePath:("./SDKs/PowerShell/${{ matrix.SDKName }}/test-module.ps1")
Invoke-Pester:
needs: ["Setup-Build-Dependancies", "Build-SDK"]
runs-on: ubuntu-latest
timeout-minutes: 70
steps:
- uses: actions/checkout@v4
- name: Checkout Support Repo
uses: actions/checkout@v4
with:
repository: TheJumpCloud/support
path: './support'
- uses: actions/cache@v3
with:
path: "/home/runner/.local/share/powershell/Modules/"
key: PS-Dependancies
- uses: actions/download-artifact@v3
with:
name: build-JumpCloud.SDK.DirectoryInsights
path: /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/
- uses: actions/download-artifact@v3
with:
name: build-JumpCloud.SDK.V1
path: /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/
- uses: actions/download-artifact@v3
with:
name: build-JumpCloud.SDK.V2
path: /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/
- name: Unzip artifacts
shell: pwsh
run: |
Expand-Archive -Path /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights.zip -DestinationPath /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/ -Force
Expand-Archive -Path /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.V1.zip -DestinationPath /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/ -Force
Expand-Archive -Path /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.V2.zip -DestinationPath /home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/ -Force
- name: Invoke Pester
shell: pwsh
env:
PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }}
PESTER_ORGID: ${{ secrets.PESTER_ORGID }}
PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }}
PESTER_PROVIDERID: ${{ secrets.PESTER_PROVIDERID }}
run: |
$ErrorActionPreference = 'stop'
# Import all the SDKs
$sdks = @('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2')
foreach ($sdk in $sdks){
Import-Module "/home/runner/work/jcapi-powershell/jcapi-powershell/SDKs/PowerShell/$sdk/$sdk.psd1" -force
}
# list JumpCloud Modules Imported
Get-Module -Name Jumpcloud*
# Get functions from module:
$pathList = @('Private', 'Public')
# Get matching functions
$functions = $pathList | ForEach-Object {
Get-ChildItem "./support/PowerShell/JumpCloud Module/$($_)/*.ps1" -Recurse
}
# Get Tags with SDK functions:
$testTags = @()
# For each function file
foreach ($file in $functions) {
$regex = [regex]'jcsdk'
if (Select-String -path $file.FullName -Pattern $regex){
# If 'jcsdk' is used in the function file continue
# get test file
$testFile = ($file.FullName -replace "JumpCloud Module", "JumpCloud Module/Tests") -replace ".ps1", ".Tests.ps1"
$tagRegex = [regex]'-Tag:\(.(\w+).\)'
$testTag = Select-String -path $testFile -Pattern $tagRegex
# "$test"
if ($testTag.matches) {
# If tag found in test file add to testTags list:
$testTags += $testTag.matches.Groups[1].Value
}
}
}
# return found tags
$tags = ($testTags | Select-Object -Unique)
# Manually add tags that we can't automatically add with script above:
# At this time only associations need to be added:
$tags += 'JCAssociation'
# setup org:
$orgVars = . "./support/PowerShell/JumpCloud Module/Tests/SetupOrg.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY"
# Invoke Pester
Import-Module "./support/PowerShell/JumpCloud Module/JumpCloud.psd1"
# disable parallel tests:
Set-JCSettingsFile -parallelOverride $true
. "./support/PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey $env:PESTER_APIKEY -ExcludeTagList:('MSP', 'JCDeployment', 'JCOnline') -IncludeTagList:($tags) -RequiredModulesRepo:('PSGallery')
32 changes: 32 additions & 0 deletions JumpCloud.SDK.DirectoryInsights.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## JumpCloud.SDK.DirectoryInsights-0.0.24
Release Date: November 08, 2023
#### RELEASE NOTES
```
{{Fill in the Release Notes}}
```
#### FEATURES:
{{Fill in the Features}}
#### IMPROVEMENTS:
{{Fill in the Improvements}}
#### BUG FIXES:
{{Fill in the Bug Fixes}}
#### Generated Changes:

<details>
<summary>Functions Added</summary>

No changes
</details>

<details>
<summary>Functions Modified</summary>

No changes
</details>

<details>
<summary>Functions Removed</summary>

No changes
</details>

## JumpCloud.SDK.DirectoryInsights-0.0.23
Release Date: June 07, 2023
#### RELEASE NOTES
Expand Down
35 changes: 35 additions & 0 deletions JumpCloud.SDK.V1.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
## JumpCloud.SDK.V1-0.0.36
Release Date: November 08, 2023
#### RELEASE NOTES
```
{{Fill in the Release Notes}}
```
#### FEATURES:
{{Fill in the Features}}
#### IMPROVEMENTS:
{{Fill in the Improvements}}
#### BUG FIXES:
{{Fill in the Bug Fixes}}
#### Generated Changes:

<details>
<summary>Functions Added</summary>

No changes
</details>

<details>
<summary>Functions Modified</summary>

* New-JcSdkApplication.ps1
* Set-JcSdkAdministratorUser.ps1
* Set-JcSdkApplication.ps1

</details>

<details>
<summary>Functions Removed</summary>

No changes
</details>

## JumpCloud.SDK.V1-0.0.35
Release Date: June 07, 2023
#### RELEASE NOTES
Expand Down
43 changes: 43 additions & 0 deletions JumpCloud.SDK.V2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
## JumpCloud.SDK.V2-0.0.40
Release Date: November 08, 2023
#### RELEASE NOTES
```
{{Fill in the Release Notes}}
```
#### FEATURES:
{{Fill in the Features}}
#### IMPROVEMENTS:
{{Fill in the Improvements}}
#### BUG FIXES:
{{Fill in the Bug Fixes}}
#### Generated Changes:

<details>
<summary>Functions Added</summary>

No changes
</details>

<details>
<summary>Functions Modified</summary>

* Get-JcSdkAppleMdm.ps1
* Get-JcSdkProvidersInvoice.ps1
* New-JcSdkProviderAdministrator.ps1
* New-JcSdkSoftwareApp.ps1
* New-JcSdkSystemGroup.ps1
* New-JcSdkUserGroup.ps1
* Set-JcSdkSoftwareApp.ps1
* Set-JcSdkSystemGroup.ps1
* Set-JcSdkUserGroup.ps1
* Update-JcSdkGSuite.ps1

</details>

<details>
<summary>Functions Removed</summary>

* Get-JcSdkGsuiteUsersToImportFormated.ps1

</details>

## JumpCloud.SDK.V2-0.0.39
Release Date: June 07, 2023
#### RELEASE NOTES
Expand Down
53 changes: 52 additions & 1 deletion Tools/ModuleValidation.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Describe 'Validate Module versions' -Tag:("Module_Version"){

Describe -Tag:('ModuleValidation') 'Module Manifest Tests' {
It ('Validates Module Versions'){
[version]$v1GalleryVersion = Find-Module -name JumpCloud.SDK.V1 | Select-Object -Property Version | ForEach-Object { $_.Version }
# Compare the versions to SDKs/PowerShell/JumpCloud.SDK.V1/JumpCloud.SDK.V1.psd1
Expand Down Expand Up @@ -45,6 +45,57 @@ Describe 'Validate Module versions' -Tag:("Module_Version"){


}
It 'The data on the current version of the Module Changelog should be todays date' {
if ($env:RELEASE_TYPE) {
@('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2')| ForEach-Object {
$latestModule = Find-Module -Name $_
$rootPath = "$PSScriptRoot/../"
$moduleChangelogPath = "$rootPath/$_.md"
$moduleChangelogContent = Get-Content ("$moduleChangelogPath") -TotalCount 3
# latest from changelog
$stringMatch = Select-String -InputObject $moduleChangelogContent -Pattern "## $_-([0-9]+.[0-9]+.[0-9]+)"
$latestChangelogVersion = $stringMatch.matches.groups[1].value
$stringMatch = Select-String -InputObject $moduleChangelogContent -Pattern "Release Date: (.*) ####"
$latestReleaseDate = $stringMatch.matches.groups[1].value
switch ($env:RELEASE_TYPE) {
'major' {
$versionString = "$($(([version]$latestModule.Version).Major) + 1).0.0"
Write-Host "[Module Validation Tests] Development Version Major Changelog Version: $($latestChangelogVersion) Should be $versionString"
([Version]$latestChangelogVersion).Major | Should -Be (([version]$latestModule.Version).Major + 1)
([Version]$latestChangelogVersion) | Should -BeGreaterThan (([version]$latestModule.Version))
}
'minor' {
$versionString = "$($(([version]$latestModule.Version).Major)).$(([version]$latestModule.Version).minor + 1).0"
Write-Host "[Module Validation Tests] Development Version Minor Changelog Version: $($latestChangelogVersion) Should be $versionString"
([Version]$latestChangelogVersion).Minor | Should -Be (([version]$latestModule.Version).Minor + 1)
([Version]$latestChangelogVersion) | Should -BeGreaterThan (([version]$latestModule.Version))
}
'patch' {
$versionString = "$($(([version]$latestModule.Version).Major)).$(([version]$latestModule.Version).minor).$(([version]$latestModule.Version).Build + 1)"
Write-Host "[Module Validation Tests] Development Version Build Changelog Version: $($latestChangelogVersion) Should be $versionString"
([Version]$latestChangelogVersion).Build | Should -Be (([version]$latestModule.Version).Build + 1)
([Version]$latestChangelogVersion) | Should -BeGreaterThan (([version]$latestModule.Version))
}
'manual' {
Write-Host "[Module Validation Tests] Development Version Changelog Version: $($latestChangelogVersion) is going to be manually released to PowerShell Gallery"
([Version]$latestChangelogVersion) | Should -BeGreaterThan (([version]$latestModule.Version))
}
}
$todayDate = Get-Date -UFormat "%B %d, %Y"
# if ($todayDate | Select-String -Pattern "0\d,") {
# $todayDate = "$(Get-Date -UFormat %B) $($(Get-Date -Uformat %d) -replace '0', ''), $(Get-Date -UFormat %Y)"
# }
$latestReleaseDate | Should -Be $todayDate
}

}
}
It 'The ModuleChangeLog Congent should not contain placeholder content'{
@('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') | ForEach-Object {
$rootPath = "$PSScriptRoot/../"
$moduleChangelogPath = "$rootPath/$_.md"
$moduleChangelogContent = Get-Content ("$moduleChangelogPath")
$moduleChangelogContent | Should -Not -Match "{{Fill in the"
}
}
}

0 comments on commit 58bdd57

Please sign in to comment.