Skip to content

Commit

Permalink
chore: optimized build process and updated metadata
Browse files Browse the repository at this point in the history
The recent set of changes encompass optimizations to the build process and updates to the module metadata. The build pipeline was refactored into child workflows for better organization and simplicity, alongside removal of certain caching and module installation steps which were found to be less beneficial. Additionally, the version script was simplified for non-production use. On the metadata front, the psd1 file was updated with the most recent information and optimized. A few file renamings were also part of this chore to enhance clarity. These refinements collectively contribute to a more streamlined development workflow and accurate metadata representation.
  • Loading branch information
SebastianSchuetze committed Oct 31, 2023
1 parent 2aa5100 commit 59b8adb
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 341 deletions.
496 changes: 199 additions & 297 deletions .github/workflows/actions-pipeline.yml

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions .github/workflows/reusable.integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
on:
workflow_call:
inputs:
pesterVersion:
type: string
description: 'The version of Pester to install'
required: true
default: '5.5.0'
secrets:
ghToken:
required: true
description: 'The GitHub token to use for publishing artifacts'

jobs:
testing-stage:
runs-on: windows-latest
strategy:
matrix:
api_version: [VSTS]
fail-fast: true
steps:

- name: Download nuget package artifact
uses: actions/download-artifact@v3
with:
name: VSTeamPackage
path: ./module

- name: Download integration tests
uses: actions/download-artifact@v3
with:
name: test
path: ./test

- name: Download pipeline scripts
uses: actions/download-artifact@v3
with:
name: pipeline-scripts
path: ./tools

- name: Module test installation
shell: pwsh
run: |
./Test-InstallFromLocalFeed.ps1 -GitHubToken $env:GITHUB_TOKEN -RunnerTempPath '${{ runner.temp }}'
env:
GITHUB_TOKEN: ${{secrets.ghToken}}
working-directory: './tools/scripts'

- name: Install Pester
run: Install-Module -Name Pester -Repository PSGallery -Force -AllowPrerelease -MinimumVersion "${{ inputs.pesterVersion }}" -Scope CurrentUser -AllowClobber -SkipPublisherCheck
shell: pwsh

- name: Run Integration Tests
run: |
Import-Module VSTeam
#This loads [PesterConfiguration] into scope
Import-Module Pester
$pesterArgs = [PesterConfiguration]::Default
$pesterArgs.Run.Exit = $true
$pesterArgs.Run.PassThru = $true
$pesterArgs.Output.Verbosity = 'None'
$pesterArgs.TestResult.Enabled = $true
$pesterArgs.TestResult.OutputFormat = 'JUnitXml'
$pesterArgs.TestResult.OutputPath = 'test-results.xml'
$env:VSTEAM_NO_UPDATE_MESSAGE = $true
$env:VSTEAM_NO_MODULE_MESSAGES = $true
Invoke-Pester -Configuration $pesterArgs
shell: pwsh
env:
PAT: ${{ secrets.RSAZDOPAT }}
EMAIL: ${{ secrets.RSEMAIL }}
API_VERSION: ${{ matrix.api_version }}
ACCT: ${{ secrets.RSORG }}
working-directory: './test/Tests/integration'

- name: Prepare test result publishing
run: git init
shell: pwsh

- name: Publish PowerShell test results
uses: dorny/test-reporter@v1
with:
name: PS integration-tests results - (${{ matrix.api_version }})
path: '**/test-results.xml'
reporter: jest-junit
43 changes: 43 additions & 0 deletions .github/workflows/reusable.package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
workflow_call:
secrets:
ghToken:
required: true

jobs:
package-stage:
# run from here only if it's not a pull request
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download module
uses: actions/download-artifact@v3
with:
name: module

- name: Download pipeline scripts
uses: actions/download-artifact@v3
with:
name: pipeline-scripts
path: ./tools

- name: Install NuGet 5.2.0
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.2.0'

- name: Pack and push module
shell: pwsh
run: |
./Install-ModuleDependencies -ModulePath "./../../dist"
$version = ./Get-VersionNumber.ps1 -RevisionNumber ${{ github.run_number }} -ModulePath "./../../"
./Invoke-PublishModule.ps1 -GitHubToken $env:GITHUB_TOKEN -Version $version -ModulePath "./../../"
env:
GITHUB_TOKEN: ${{secrets.ghToken}}
working-directory: './tools/scripts'

- name: Upload nuget package as artifact
uses: actions/upload-artifact@v3
with:
name: VSTeamPackage
path: ./dist/*.nupkg
6 changes: 3 additions & 3 deletions Source/Classes/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
},
"PowerShellStandard.Library": {
"type": "Direct",
"requested": "[5.1.0, )",
"resolved": "5.1.0",
"contentHash": "iYaRvQsM1fow9h3uEmio+2m2VXfulgI16AYHaTZ8Sf7erGe27Qc8w/h6QL5UPuwv1aXR40QfzMEwcCeiYJp2cw=="
"requested": "[5.1.1, )",
"resolved": "5.1.1",
"contentHash": "e31xJjG+Kjbv6YF3Yq6D4Dl3or8v7LrNF41k3CXrWozW6hR1zcOe5KYuZJaGSiAgLnwP8wcW+I3+IWEzMPZKXQ=="
},
"Trackyon.System.Management.Automation.Abstractions": {
"type": "Direct",
Expand Down
10 changes: 5 additions & 5 deletions Source/VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
GUID = '210e95b1-50bb-44da-a993-f567f4574214'

# Author of this module
Author = 'Donovan Brown (@DonovanBrown), Sebastian Schütze (@RazorSPoint)'
Author = 'Donovan Brown (@DonovanBrown), Sebastian Schütze (Twitter: @RazorSPoint)'

# Company or vendor of this module
CompanyName = ''

# Copyright statement for this module
Copyright = '(c) 2022 Donovan Brown. All rights reserved.'
Copyright = '(c) 2023 Donovan Brown and Sebastian Schütze. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Adds functionality for working with Azure DevOps and Team Foundation Server.'
Expand Down Expand Up @@ -110,17 +110,17 @@
ProjectUri = 'https://github.com/MethodsAndPractices/vsteam'

# A URL to an icon representing this module.
# IconUri = ''
IconUri = 'https://methodsandpractices.github.io/vsteam-docs/img/startpage_vsteam_api.svg'

# ReleaseNotes of this module
ReleaseNotes = 'https://github.com/MethodsAndPractices/vsteam/blob/trunk/CHANGELOG.md'
ReleaseNotes = 'https://github.com/MethodsAndPractices/vsteam/releases'

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
HelpInfoURI = 'https://methodsandpractices.github.io/vsteam-docs'

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
Expand Down
32 changes: 32 additions & 0 deletions tools/scripts/Get-VersionNumber.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[CmdletBinding(DefaultParameterSetName = 'DirectVersion')]
param (
# Revision number for non-production use
[Parameter(Mandatory = $true, ParameterSetName = 'Revision')]
[int]
$RevisionNumber,

# Path to the module without the name e.g. "C:\path\without\name" and not "C:\path\without\name\VSTeam"
[Parameter(Mandatory = $true)]
[string]
$ModulePath
)

if ($null -eq (Get-Module -Name Metadata -ListAvailable)) {
$null = Install-Module -Name Metadata -Scope CurrentUser -Force
}

Write-Host 'Compute Version Number'

# Load the psd1 file so you can read the version
$manifest = Import-Metadata -Path "$ModulePath/dist/VSTeam.psd1"

# Load as semantic version
[version]$sem_version = $manifest.ModuleVersion
# Build new semantic version with revision number
$computedVersion = "$($sem_version.Major).$($sem_version.Minor).$($sem_version.Build).$($RevisionNumber)"

$manifest.ModuleVersion = $computedVersion
Write-Host "Package Version Number: $computedVersion"
$null = Export-Metadata -Path "$ModulePath/dist/VSTeam.psd1" -InputObject $manifest

Write-Output $computedVersion
6 changes: 3 additions & 3 deletions tools/scripts/Invoke-PublishModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
param (
# version number that should be used when publishing to github
[Parameter(Mandatory = $true, ParameterSetName = "PublishGithub")]
[Parameter(Mandatory = $true, ParameterSetName = "PublishPSGallery")]
[version]
$Version,
#github token
Expand Down Expand Up @@ -46,7 +47,6 @@ if ($PsCmdlet.ParameterSetName -eq "PublishGithub") {
}
elseif ($PsCmdlet.ParameterSetName -eq "PublishPSGallery" -or $PsCmdlet.ParameterSetName -eq "TestPublishPSGallery") {


$DestinationPath = "$ModulePath/VSTeam"

Copy-Item -Path "$ModulePath/dist" -Destination $DestinationPath -Recurse -WhatIf:$false
Expand Down Expand Up @@ -74,9 +74,9 @@ elseif ($PsCmdlet.ParameterSetName -eq "PublishPSGallery" -or $PsCmdlet.Paramete
}

if ($PSCmdlet.ShouldProcess("Module publishing to PS gallery")) {
Publish-Module -NuGetApiKey $PSGalleryApiKey -Path $DestinationPath
Publish-Module -NuGetApiKey $PSGalleryApiKey -Path $DestinationPath -RequiredVersion $Version
}
else {
Publish-Module -NuGetApiKey $PSGalleryApiKey -Path $DestinationPath -WhatIf
Publish-Module -NuGetApiKey $PSGalleryApiKey -Path $DestinationPath -RequiredVersion $Version -WhatIf
}
}
33 changes: 0 additions & 33 deletions tools/scripts/Set-VersionNumber.ps1

This file was deleted.

0 comments on commit 59b8adb

Please sign in to comment.