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
123 changes: 106 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,120 @@
name: Publish to PowerShell Gallery
name: Publish to PowerShell Gallery

# Build and release the PsLogicAppExtractor PowerShell module on every push to main.
# Validation jobs run in parallel with module caching; build-and-release runs after all pass.

on:
push:
branches:
- main

jobs:
build:
name: Push to Gallery
general-unit-tests:
name: Validate General Unit Tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache Powershell Modules
id: cache-powershell-modules
uses: actions/cache@v5
with:
path: ~\Documents\PowerShell\Modules
key: ps-modules-${{ runner.os }}-v1

- name: Install Prerequisites
if: steps.cache-powershell-modules.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
$modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake')
foreach ($module in $modules) {
Write-Host "Installing $module..."
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}

- name: Validate
shell: pwsh
run: build\vsts-validate.ps1 -TestGeneral $true -TestFunctions $false

individual-unit-tests:
name: Validate Individual Unit Tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
- uses: actions/checkout@v4
with:
path: "C:\\Users\\runneradmin\\Documents\\PowerShell\\Modules"
key: ${{ runner.os }}-PSFramework-PSScriptAnalyzer
fetch-depth: 1

- name: Cache Powershell Modules
id: cache-powershell-modules
uses: actions/cache@v5
with:
path: ~\Documents\PowerShell\Modules
key: ps-modules-${{ runner.os }}-v1

- name: Install Prerequisites
if: steps.cacher.outputs.cache-hit != 'true'
run: .\build\vsts-prerequisites.ps1
if: steps.cache-powershell-modules.outputs.cache-hit != 'true'
shell: pwsh
# - name: Validate
# run: .\build\vsts-validate.ps1
# shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
$modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake')
foreach ($module in $modules) {
Write-Host "Installing $module..."
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}

- name: Validate
shell: pwsh
run: build\vsts-validate.ps1 -TestGeneral $false -TestFunctions $true

build-and-release:
name: Build and Release
runs-on: windows-latest
needs: [general-unit-tests, individual-unit-tests]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache Powershell Modules
id: cache-powershell-modules
uses: actions/cache@v5
with:
path: ~\Documents\PowerShell\Modules
key: ps-modules-${{ runner.os }}-v1

- name: Install Prerequisites
if: steps.cache-powershell-modules.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
$modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake')
foreach ($module in $modules) {
Write-Host "Installing $module..."
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}

- name: Build
run: .\build\vsts-build.ps1 -ApiKey $env:APIKEY -AutoVersion
shell: pwsh
env:
APIKEY: ${{ secrets.ApiKey }}
run: .\build\vsts-build.ps1 -ApiKey ${{ secrets.ApiKey }} -AutoVersion:$true -SkipPublish:$false

- name: Get version
shell: pwsh
run: |
$publishDir = Get-Item -Path publish
[version]$version = (Import-PowerShellDataFile -Path "$($publishDir.FullName)\PsLogicAppExtractor\PsLogicAppExtractor.psd1").ModuleVersion
$githubReleaseVersion = "$($version.Major).$($version.Minor).$($version.Build)"
"VERSION=$githubReleaseVersion" >> $env:GITHUB_ENV

- name: Create GitHub release
uses: softprops/action-gh-release@v3
with:
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
draft: false
prerelease: true
generate_release_notes: true
30 changes: 30 additions & 0 deletions .github/workflows/cache-warm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Warm Module Cache

on:
push:
branches: [main, development]
schedule:
- cron: '0 6 * * 3,6' # Wednesday and Saturday 06:00 UTC
workflow_dispatch:

jobs:
warm-cache:
runs-on: windows-latest
steps:
- name: Cache PowerShell modules
id: cache-powershell-modules
uses: actions/cache@v5
with:
path: ~\Documents\PowerShell\Modules
key: ps-modules-${{ runner.os }}-v1

- name: Install modules
if: steps.cache-powershell-modules.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
$modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake')
foreach ($module in $modules) {
Write-Host "Installing $module..."
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}
76 changes: 54 additions & 22 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,64 @@
name: Validate Module (Unit Tests)
name: validate

on:
workflow_dispatch:
pull_request:
schedule:
- cron: '13 4 * * 1'
on: [pull_request]

jobs:
validate:
name: Run Pester Unit Tests
general-unit-tests:
name: Validate General Unit Tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache Powershell Modules
id: cache-powershell-modules
uses: actions/cache@v5
with:
path: ~\Documents\PowerShell\Modules
key: ps-modules-${{ runner.os }}-v1

- name: Install Prerequisites
if: steps.cache-powershell-modules.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
$modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake')
foreach ($module in $modules) {
Write-Host "Installing $module..."
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}

- name: Validate
shell: pwsh
run: build\vsts-validate.ps1 -TestGeneral $true -TestFunctions $false

individual-unit-tests:
name: Validate Individual Unit Tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache Powershell Modules
id: cache-powershell-modules
uses: actions/cache@v5
with:
path: "C:\\Users\\runneradmin\\Documents\\PowerShell\\Modules"
key: ${{ runner.os }}-PSFramework-PSScriptAnalyzer
restore-keys: |
${{ runner.os }}-PSFramework-
${{ runner.os }}-
${{ runner.os }}
path: ~\Documents\PowerShell\Modules
key: ps-modules-${{ runner.os }}-v1

- name: Install Prerequisites
if: steps.cacher.outputs.cache-hit != 'true'
run: .\build\vsts-prerequisites.ps1
if: steps.cache-powershell-modules.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
$modules = @('Pester','PSFramework','PSModuleDevelopment','PSScriptAnalyzer','psake')
foreach ($module in $modules) {
Write-Host "Installing $module..."
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}

- name: Validate
run: .\build\vsts-validate.ps1
shell: pwsh
shell: pwsh
run: build\vsts-validate.ps1 -TestGeneral $false -TestFunctions $true
12 changes: 11 additions & 1 deletion build/vsts-validate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@

# Needs to ensure things are Done Right and only legal commits to master get built

param (
$TestGeneral = $true,

$TestFunctions = $true,

$Include = "*",

$Exclude = "*.exclude.ps1"
)

# Run internal pester tests
& "$PSScriptRoot\..\PsLogicAppExtractor\tests\pester.ps1"
& "$PSScriptRoot\..\PsLogicAppExtractor\tests\pester.ps1" -TestGeneral $TestGeneral -TestFunctions $TestFunctions -Include $Include -Exclude $Exclude
Loading