Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing GitHub Actions CI #475

Open
wants to merge 92 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
2d3c784
Fix failing GitHub Actions CI
beau-witter Jan 29, 2023
7881167
Remove dependency on pester info file
beau-witter Feb 6, 2023
066dd19
Correct referenced step id
beau-witter Feb 6, 2023
ef87911
Add format.ps1xml file back to complete manifest
beau-witter Feb 6, 2023
e15f030
Add sanity output check
beau-witter Feb 6, 2023
b7dffdb
Move sanity test to build job
beau-witter Feb 6, 2023
1cd0fcd
Switch from github_output to github_env
beau-witter Feb 6, 2023
0818688
Change back to Output according to documentation
beau-witter Feb 6, 2023
3347b8c
Use GITHUB_ENV based on documentation
beau-witter Feb 6, 2023
4fd8501
Switch to using proper Powershell
beau-witter Feb 6, 2023
0a1ab8c
Propogate proper pwsh env var setting
beau-witter Feb 6, 2023
9206937
Add setting for GitHub actions in Initialize-Environment
beau-witter Feb 6, 2023
d4c4913
Add -Force for copying PSKoans path
beau-witter Feb 6, 2023
6e1597b
Find out exact location of BuiltModule Path
beau-witter Feb 6, 2023
9b1e741
Access BuiltModulePath from env
beau-witter Feb 6, 2023
8c677d9
Forgot to delete upper portion
beau-witter Feb 6, 2023
6d5a5cf
Fix reference to GITHUB_WORKSPACE env var
beau-witter Feb 6, 2023
5e6dac3
More debugging potential ways of getting var
beau-witter Feb 6, 2023
feb5630
Pass in vars into pwsh env
beau-witter Feb 6, 2023
887e1e6
Remove auto-filled variable from being set
beau-witter Feb 6, 2023
d2e0797
Fix reference to env variable being passed in
beau-witter Feb 6, 2023
3c56d9c
Add another env variable to script
beau-witter Feb 6, 2023
b6e9378
Expand variable within variable
beau-witter Feb 6, 2023
53f564b
Pass in another env variable
beau-witter Feb 6, 2023
62dc635
Determine the value for PROJECTROOT
beau-witter Feb 6, 2023
30e63b8
Remove debugging and fully qualify env variables
beau-witter Feb 6, 2023
d9804aa
Expand variable within variable for generating NuGet pkg
beau-witter Feb 6, 2023
8bc0245
Attempt to fix invalid workspace
beau-witter Feb 6, 2023
71b9b64
Properly expand github env variable
beau-witter Feb 6, 2023
9fbead6
Expand variable at creation
beau-witter Feb 6, 2023
8cd7897
Fix workspace issues by assigned env vars to script
beau-witter Feb 6, 2023
218c575
Made RequiredVersion accessible
beau-witter Feb 6, 2023
ce0fc64
Remove debug remnant
beau-witter Feb 6, 2023
af95d8c
Attempt to prove the caching works properly
beau-witter Feb 6, 2023
e1bf744
Update workflow file again
beau-witter Feb 6, 2023
4e53a20
Move test from test job to build job
beau-witter Feb 6, 2023
30c5d29
Add Pester to output
beau-witter Feb 6, 2023
492df63
Temporarily remove module cacher
beau-witter Feb 6, 2023
4570179
Use correct install-module syntax for versions
beau-witter Feb 6, 2023
2b4b6ed
Fix syntax error
beau-witter Feb 6, 2023
17a9f4c
Fix reference to env variable in test job
beau-witter Feb 6, 2023
d7b99a0
More explicit environment access
beau-witter Feb 6, 2023
6a670e1
Fix failing workflow due to incorrect syntax
beau-witter Feb 6, 2023
ff59daa
Adjust path var reference
beau-witter Feb 6, 2023
458cc95
Adjust path var reference
beau-witter Feb 6, 2023
04bb82e
Remove usage of outputs and needs from build job
beau-witter Feb 6, 2023
81efe4c
Remove residual file access
beau-witter Feb 6, 2023
0c0eebb
Revert back to caching ps modules
beau-witter Feb 15, 2023
6bb1876
Fix for tests executed from ModuleHelp.tests
beau-witter Feb 15, 2023
5c3d2c3
Update Measure-Koan for first-time execution
beau-witter Feb 15, 2023
cff5e26
Fix for Update-PSKoanFile.tests
beau-witter Feb 15, 2023
5144398
Update tests to use -ModuleName
beau-witter Feb 15, 2023
eff73b2
Update tests to use ModuleName splatting
beau-witter Feb 15, 2023
cdc448d
Update tests to Pester v5+
beau-witter Feb 17, 2023
3ff95b4
Update Invoke-Pester to v5 syntax
beau-witter Feb 17, 2023
52961af
Update Test steps
beau-witter Feb 17, 2023
264ed7b
Adjust nunit report version
beau-witter Feb 17, 2023
4cc08ea
Specify exact action versions
beau-witter Feb 17, 2023
2cd21e9
Small change to location variable for test files
beau-witter Feb 17, 2023
43e69b6
Fix environment variable naming
beau-witter Feb 17, 2023
83e1d7e
Replace missing var
beau-witter Feb 17, 2023
7167723
Try switching to different test reporter
beau-witter Feb 18, 2023
356c8bc
Move publish test results to publish job
beau-witter Feb 18, 2023
4db86ba
Fix variables in pipeline
beau-witter Feb 18, 2023
d45e00e
Update upload artifact to v3
beau-witter Feb 18, 2023
9132753
Fix artifact name
beau-witter Feb 18, 2023
26365da
Switch to use github.workspace for any non-powershell workspace ref
beau-witter Feb 18, 2023
1f9de59
Move test reporting to its own job
beau-witter Feb 18, 2023
202651b
Fix typo in action name
beau-witter Feb 18, 2023
f0dd08c
Change CI to better support test results
beau-witter Feb 18, 2023
82fb5ac
Fix action typo
beau-witter Feb 18, 2023
aa33ffe
Use correct source folder
beau-witter Feb 18, 2023
ec1ec3c
Revert to original test result reporting
beau-witter Feb 18, 2023
405b8fb
Update to latest of MirageNet
beau-witter Feb 18, 2023
81020ba
Revert "Update to latest of MirageNet"
beau-witter Feb 18, 2023
f6c153f
Revert "Revert to original test result reporting"
beau-witter Feb 18, 2023
69d700a
Fix to give Code Coverage access to files
beau-witter Feb 19, 2023
41efda7
Fix naming collision
beau-witter Feb 19, 2023
f33e55f
Add CodeCoverage Path
beau-witter Feb 19, 2023
6e233a7
Specify folders for Invoke-Pester
beau-witter Feb 19, 2023
7b684a5
Adjust Folder structure
beau-witter Feb 19, 2023
93a9460
Specify only PSKoans files for coverage, not Koans
beau-witter Feb 19, 2023
5424930
Comment out install of PSKoans
beau-witter Feb 19, 2023
146a507
Add ability to import PSKoans from local
beau-witter Feb 19, 2023
7665ec2
Remove unneeded environment variable set
beau-witter Feb 19, 2023
8261cff
Comment out more potentially unused steps
beau-witter Feb 19, 2023
160008f
Bump Pester to version 5.4.0
beau-witter Feb 19, 2023
279eb79
Add in sanity debug for file location and contents
beau-witter Feb 19, 2023
d937df8
Add in proper PSModulePath setting
beau-witter Feb 19, 2023
e13ca21
Add docs to test run path
beau-witter Feb 19, 2023
6564d35
Generate Help as required by tests
beau-witter Feb 19, 2023
becd594
Lower output back down to normal
beau-witter Feb 19, 2023
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
275 changes: 145 additions & 130 deletions .github/workflows/github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ on:
env:
NupkgArtifactName: 'PSKoans.nupkg'
ModuleArtifactName: 'PSKoans'
PesterInfoFileName: 'PesterVersion.txt'
PesterInfoFilePath: '$GITHUB_WORKSPACE/PesterVersion.txt'

jobs:

Expand All @@ -33,17 +31,17 @@ jobs:
runs-on: ubuntu-latest

env:
FilePath: '$GITHUB_WORKSPACE/Changelog.md'
FilePath: '${{github.workspace}}/Changelog.md'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Generate Changelog
shell: pwsh
run: ./Build/New-Changelog.ps1 -Path "${{ env.FilePath }}" -ApiKey "${{ secrets.GITHUB_TOKEN }}"

- name: Upload Changelog
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v3
with:
name: Changelog.md
path: $FilePath
Expand All @@ -53,74 +51,64 @@ jobs:
runs-on: ubuntu-latest

env:
FileSystemDeploymentPath: '$GITHUB_WORKSPACE/Deploy/FileSystem'
BuiltModulePath: '$GITHUB_WORKSPACE/Deploy/PSKoans'
FileSystemDeploymentPath: Deploy/FileSystem
BuiltModulePath: Deploy/PSKoans
# This needs to be set by the script which creates the nupkg
NupkgPath: ''

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Dependencies
- name: Get Pester min version
id: pestermin
shell: pwsh
run: |
$Params = @{
Scope = 'CurrentUser'
Force = $true
}

Write-Host "Installing Modules"
$Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' )
$Params | Out-String | Write-Host
Install-Module @Params

$Params.Name = 'Pester'
$Params.SkipPublisherCheck = $true
$Params.MinimumVersion = $Params.MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version
$Params | Out-String | Write-Host
Install-Module @Params

$Params.MinimumVersion | Set-Content -Path "${{ env.PesterInfoFilePath }}"

$Params.Remove('SkipPublisherCheck')
$Params.Remove('MinimumVersion')

$Params.Name = 'EZOut'
$Params.AllowClobber = $true
$Params | Out-String | Write-Host
Install-Module @Params
$MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version.ToString()
Write-Output "pester_min_version=$MinimumVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Minimum Pester Version: $MinimumVersion"

- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: PSDeploy, BuildHelpers, platyPS, Pester:${{ env.pester_min_version }}, EZOut
shell: pwsh

- name: Setup Environment
shell: pwsh
run: ./Build/Initialize-Environment.ps1
env:
BUILD_SOURCEBRANCHNAME: ${{ env.GITHUB_REF_NAME }}
BUILD_SOURCEBRANCH: ${{ env.GITHUB_REF }}

- name: Build Module
shell: pwsh
run: ./Build/Build-Module.ps1
env:
PROJECTROOT: ${{ env.PROJECTROOT }}
BUILTMODULEPATH: ${{ env.BuiltModulePath }}
GITHUB_WORKSPACE: ${{github.workspace}}

- name: Upload Module Artifact
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v3
with:
name: $ModuleArtifactName
path: $BuiltModulePath

- name: Upload Pester Version Artifact
uses: actions/[email protected]
with:
name: $PesterInfoFileName
path: $PesterInfoFilePath
name: ${{ env.ModuleArtifactName }}
path: ${{ github.workspace }}/${{ env.BuiltModulePath }}

- name: Generate Nupkg
shell: pwsh
run: |
./Build/Register-FileSystemRepository.ps1 -Path '${{ env.FileSystemDeploymentPath }}' -Name 'FileSystem'
./Deploy/Publish.ps1 -Key 'filesystem' -Path '${{ env.FileSystemDeploymentPath }}' -OutputDirectory '${{ env.FileSystemDeploymentPath }}'
$FileSystemDeploymentPath = "$env:GITHUB_WORKSPACE/$env:FileSystemDeploymentPath"
./Build/Register-FileSystemRepository.ps1 -Path $FileSystemDeploymentPath -Name 'FileSystem'
./Deploy/Publish.ps1 -Key 'filesystem' -Path $FileSystemDeploymentPath -OutputDirectory $FileSystemDeploymentPath
env:
GITHUB_WORKSPACE: ${{github.workspace}}
FileSystemDeploymentPath: ${{ env.FileSystemDeploymentPath }}

- name: Upload Nupkg Artifact
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v3
with:
name: $NupkgArtifactName
path: $NupkgPath
name: ${{ env.NupkgArtifactName }}
path: ${{ env.NupkgPath }}

test:
name: "Test Module"
Expand All @@ -136,142 +124,169 @@ jobs:
runs-on: ${{ matrix.os }}

env:
PackageDownloadPath: '$GITHUB_WORKSPACE/Module'
PackageDownloadPath: 'Module'
PSRepositoryName: 'FileSystem'
# The following variables MUST be set in Invoke-ModuleTests.ps1
TestFile: ''
CodeCoverageFile: ''
ModuleFolders: ''

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Dependencies
- name: Get Pester min version
id: pestermin
shell: pwsh
run: |
$Params = @{
Scope = 'CurrentUser'
Force = $true
}

Write-Host "Installing Modules"
$Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' )
$Params | Out-String | Write-Host
Install-Module @Params

$Params.Name = 'Pester'
$Params.SkipPublisherCheck = $true
$Params.MinimumVersion = $Params.MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version
$Params | Out-String | Write-Host
Install-Module @Params

$Params.Remove('SkipPublisherCheck')
$Params.Remove('MinimumVersion')

$Params.Name = 'EZOut'
$Params.AllowClobber = $true
$Params | Out-String | Write-Host
Install-Module @Params
$MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version.ToString()
Write-Output "pester_min_version=$MinimumVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Minimum Pester Version: $MinimumVersion"

- name: Install and cache PowerShell modules
uses: potatoqualitee/[email protected]
with:
modules-to-cache: PSDeploy, BuildHelpers, platyPS, Pester:${{ env.pester_min_version }}, EZOut
shell: pwsh

- name: Setup Environment
shell: pwsh
run: ./Build/Initialize-Environment.ps1

- name: Register FileSystem Repository
- name: Generate help.xml
shell: pwsh
run: ./Build/Register-FileSystemRepository.ps1 -Path '${{ env.PackageDownloadPath }}' -Name '${{ env.PSRepositoryName }}'
run: New-ExternalHelp -Path "${{env.PROJECTROOT}}/docs/" -OutputPath "${{env.PROJECTROOT}}/PSKoans/en"

# - name: Register FileSystem Repository
# shell: pwsh
# run: |
# $PackageDownloadPath = "$env:GITHUB_WORKSPACE/$env:PackageDownloadPath"
# ./Build/Register-FileSystemRepository.ps1 -Path $PackageDownloadPath -Name ${{ env.PSRepositoryName }}
# env:
# GITHUB_WORKSPACE: ${{github.workspace}}
# PackageDownloadPath: ${{ env.PackageDownloadPath }}

- name: Download Module Nupkg
uses: actions/[email protected]
with:
name: $NupkgArtifactName
path: $PackageDownloadPath

- name: Download Pester Version Information
uses: actions/[email protected]
with:
name: $PesterInfoFileName
path: $PesterInfoFilePath
# - name: Download Module Nupkg
# uses: actions/[email protected]
# with:
# name: ${{ env.NupkgArtifactName }}
# path: "${{ github.workspace }}/${{ env.PackageDownloadPath }}"

- name: Install Module from Nupkg
shell: pwsh
run: |
$pesterParams = @{
Name = 'Pester'
MinimumVersion = Get-Content -Path "${{ env.PesterInfoFilePath }}"
ProviderName = 'NuGet'
Path = '${{ env.PackageDownloadPath }}'
Force = $true
Source = 'PSGallery'
}
Register-PackageSource -Name PSGallery -ProviderName NuGet -Location https://www.powershellgallery.com/api/v2 -Force
Save-Package @pesterParams | Select-Object -Property Name, Version, Status, Source
Install-Module PSKoans -Repository ${{ env.PSRepositoryName }} -Force -Scope CurrentUser
# - name: Install Module from Nupkg
# shell: pwsh
# run: |
# $PackageDownloadPath = "$env:GITHUB_WORKSPACE/$env:PackageDownloadPath"
# $pesterParams = @{
# Name = 'Pester'
# MinimumVersion = $env:pester_min_version
# ProviderName = 'NuGet'
# Path = $PackageDownloadPath
# Force = $true
# Source = 'PSGallery'
# }
# Register-PackageSource -Name PSGallery -ProviderName NuGet -Location https://www.powershellgallery.com/api/v2 -Force
# Save-Package @pesterParams | Select-Object -Property Name, Version, Status, Source
# Install-Module PSKoans -Repository $env:PSRepositoryName -Force -Scope CurrentUser
# env:
# GITHUB_WORKSPACE: ${{github.workspace}}
# PackageDownloadPath: ${{ env.PackageDownloadPath }}
# PSRepositoryName: ${{ env.PSRepositoryName }}
# pester_min_version: ${{ env.pester_min_version }}

- name: Run Pester Tests
shell: pwsh
run: ./Build/Invoke-ModuleTests.ps1

- name: Publish Test Results
if: ${{ always() }}
uses: MirageNet/[email protected]
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
path: '$GITHUB_WORKSPACE\$TestResults'

name: ${{matrix.os}}-Test-Results
path: ${{github.workspace}}/${{env.TestFile}}

- name: Upload Coverage Results
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{matrix.os}}-Coverage-Results
path: ${{github.workspace}}/${{env.CodeCoverageFile}}

report-tests:
needs: test
if: always()
runs-on: ubuntu-latest
permissions:
checks: write

steps:
- uses: actions/checkout@v3

- name: Download Test Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: Generate Code Coverage
uses: danielpalme/ReportGenerator-GitHub-Action@4.8.8
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.17
with:
reports: '$GITHUB_WORKSPACE\$CodeCoverageFile'
targetdir: '$GITHUB_WORKSPACE\coveragereports'
sourcedirs: $SourceFolders
reports: 'artifacts/**/*coverage.xml'
targetdir: '${{github.workspace}}/coveragereports'
sourcedirs: 'artifacts/PSKoans'
title: PSKoans Code Coverage

- name: Publish Code Coverage artifacts
uses: actions/upload-artifact@v2.2.3
uses: actions/upload-artifact@v3
with:
name: 'Code Coverage Reports'
path: '$GITHUB_WORKSPACE\coveragereports'
name: 'CodeCoverageReport'
path: '${{github.workspace}}/coveragereports'

event_file:
runs-on: ubuntu-latest
steps:
- name: Upload Event File
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}

publish:
needs: test
if: ${{ success() && startsWith( 'refs/tags/', env.GITHUB_REF ) }}

if: ${{ success() && startsWith( 'refs/tags/', github.ref ) }}
runs-on: ubuntu-latest

env:
BuiltModulePath: '$GITHUB_WORKSPACE/Deploy/PSKoans'
GalleryDeploymentPath: '$GITHUB_WORKSPACE/Deploy/PSGallery'
BuiltModulePath: '${{github.workspace}}/Deploy/PSKoans'
GalleryDeploymentPath: '${{github.workspace}}/Deploy/PSGallery'
# This variable must be set by the script
TagName: ''

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download Module Artifact
uses: actions/download-artifact@v2.0.9
uses: actions/download-artifact@v3
with:
name: $ModuleArtifactName
path: $BuiltModulePath
name: ${{env.ModuleArtifactName}}
path: ${{env.BuiltModulePath}}

- name: Deploy Module to PSGallery
shell: pwsh
run: ./Deploy/Publish.ps1 -ApiKey '${{ secrets.PSGALLERYAPIKEY }}' -Path '${{ env.GalleryDeploymentPath }}'
run: |
./Deploy/Publish.ps1 -ApiKey '${{ secrets.PSGALLERYAPIKEY }}' -Path '${{ env.GalleryDeploymentPath }}'

- name: Set Release Tag Name
shell: pwsh
run: |
$tagName = ("${{ env.GITHUB_REF }}" -replace '^refs/tags/').Trim()
"TagName=$tagname" | Add-Content -Path '${{ env.GITHUB_ENV }}'
$tagName = ("${{ github.ref }}" -replace '^refs/tags/').Trim()
"TagName=$tagname" | Add-Content -Path '${{ github.env }}'

- name: Download Artifacts
uses: actions/download-artifact@v2.0.9
uses: actions/download-artifact@v3
with:
path: '$GITHUB_WORKSPACE/artifacts'
path: '${{github.workspace}}/artifacts'

- name: Update Release with Artifacts & Changelog
uses: Roang-zero1/[email protected]
with:
created_tag: $TagName
changelog_file: '$GITHUB_WORKSPACE/artifacts/Changelog.md'
release_title: 'PSKoans Release $TagName'
created_tag: ${{env.TagName}}
changelog_file: '${{github.workspace}}/artifacts/Changelog.md'
release_title: 'PSKoans Release ${{env.TagName}}'
Loading