From ed18c80793be2ca178e9e6cde73d88266b7e1715 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 6 Oct 2023 11:09:40 -0600 Subject: [PATCH] Revert "ci branch filter test" This reverts commit dd3f788fca8785c2f60e0ae7cadfcd6cd8a56dd7. --- .github/workflows/powershell-module-ci.yml | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 78ef8779a..962b51634 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -23,3 +23,150 @@ jobs: - name: Filter if: ${{contains(github.base_ref, 'PowerShellModule_**')}} run: exit 0 + + # Check-Filepath-Changes: + # needs: Filter-Branch + # runs-on: ubuntu-latest + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # - name: Check Changes in Directory + # shell: pwsh + # run: | + # # Define List of PWSH directories: + # $list = @( + # "/PowerShell/Deploy/", + # "/PowerShell/JumpCloud Module/", + # "/PowerShell/ModuleChangelog.md" + # ) + # # Loop through each file in the list then do git diff + # $difCount = 0 # Diff Counter + # git fetch origin $env:GITHUB_BASE_REF + # $gitDiff = git diff origin/$env:GITHUB_BASE_REF..HEAD . ':!.github/workflows/powershell-module-ci.yml' + # foreach ($path in $list) { + # # Check if the path exists in the Git diff + # if ($gitDiff -match [regex]::Escape($path)) { + # Write-Host "Path found in Git diff: $path" + # $difCount++ + # } + # } + # $gitdiff + # # If difcount = 0 then no changes were made to the files in the list, throw exit 1 + # if ($difCount -eq 0) { + # Write-Host "No changes were made to the files in the list, exiting with code 1" + # exit 1 + # } else { + # Write-Host "Changes were made to the files in the list" + # exit 0 + # } + Validate-Env-Variables: + needs: Filter-Branch + runs-on: ubuntu-latest + steps: + - shell: pwsh + run: | + # validate release type variables + $env:OVERRIDE_VERSION | Should -BeIn @('true', 'false') + $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch') + Validate-Module: + needs: Setup-Build-Dependancies + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - shell: pwsh + run: | + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + Test-Module: + needs: [Setup-Build-Dependancies, Validate-Module] + runs-on: ubuntu-latest + timeout-minutes: 75 + name: Run Pester Tests and Upload Results + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - name: Test PWSH Module + shell: pwsh + env: + PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} + run: | + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule", "JCAssociation" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" + if: ${{ always() }} + Test-Module-MSP: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - shell: pwsh + env: + PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} + PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }} + run: | + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ExcludeTagList "None" -IncludeTagList "MSP" -RequiredModulesRepo "PSGallery" + needs: [Test-Module] + + Setup-Build-Dependancies: + needs: Filter-Branch + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Setup PowerShell Module Cache + id: cacher + uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - name: Install dependencies + if: steps.cacher.outputs.cache-hit != 'true' + shell: pwsh + run: | + Set-PSRepository PSGallery -InstallationPolicy Trusted + + If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { + Write-Host ('[status]Installing package provider NuGet'); + Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force + } + + $PSDependencies = @{ + 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } + 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } + 'PSScriptAnalyzer' = @{Repository = 'PSGallery'; RequiredVersion = '1.19.1' } + 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } + 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } + 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } + 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.35'} + 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.39'} + 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.23'} + } + + foreach ($RequiredModule in $PSDependencies.Keys) { + If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { + Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + } + }