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
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ jobs:
id: prepareEnvVarsAndSecrets
with:
environmentVariablesYaml: |
# BUILDVAR_PythonPackageRepoUrl: "${{ startsWith(github.ref, 'refs/tags/') && '' || vars.PRIVATE_PYTHON_PACKAGE_REPOSITORY_URL }}"
BUILDVAR_PythonPackageRepoUrl: "${{ vars.PRIVATE_PYTHON_PACKAGE_REPOSITORY_URL }}"
ZF_BUILD_PYTHON_PUBLISH_REPOSITORY_URL: "${{ vars.PRIVATE_PYTHON_PACKAGE_REPOSITORY_URL }}"
secretsYaml: |
# PYTHON_PACKAGE_REPOSITORY_KEY: "${{ startsWith(github.ref, 'refs/tags/') && secrets.PYPI_APIKEY || secrets.PRIVATE_PYTHON_PACKAGE_REPOSITORY_KEY }}"
PYTHON_PACKAGE_REPOSITORY_KEY: "${{ secrets.PRIVATE_PYTHON_PACKAGE_REPOSITORY_KEY }}"
[]
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }}

build:
needs: prepareConfig
Expand Down Expand Up @@ -79,8 +78,9 @@ jobs:
# compilePhaseAzureCredentials: ${{ secrets.AZURE_READER_CREDENTIALS }}
# testPhaseAzureCredentials: ${{ secrets.TESTS_KV_READER_CREDENTIALS }}
# packagePhaseAzureCredentials: ${{ secrets.AZURE_PUBLISH_CREDENTIALS }}
# publishPhaseAzureCredentials: ${{ secrets.AZURE_PUBLISH_CREDENTIALS }}
publishPhaseAzureCredentials: ${{ secrets.AZURE_PUBLISHER_CREDENTIALS }}
# compilePhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
# testPhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
# packagePhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
publishPhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
# publishPhaseSecrets: ${{ needs.prepareConfig.outputs.RESOLVED_SECRETS }}
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,7 @@ local*.*
test-reports/
pytest-test-results.xml
behave-test-results.xml
behave-test-reports-temp/
behave-test-reports-temp/
.zf/extensions/
_packages/
_codeCoverage/
55 changes: 55 additions & 0 deletions .zf/config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
$zerofailedExtensions = @(
@{
# References the extension from its GitHub repository. If not already installed, use latest version from 'main' will be downloaded.
Name = "ZeroFailed.Build.Python"
GitRepository = "https://github.com/zerofailed/ZeroFailed.Build.Python"
}
)
. ZeroFailed.tasks -ZfPath $here/.zf

#
# Build process configuration
#
#
# Build process control options
#
$SkipInit = $false
$SkipVersion = $false
$SkipBuild = $false
$SkipTest = $false
$SkipRunPyTest = $false
$SkipTestReport = $false
$SkipAnalysis = $true
$SkipPackage = $false

# Python build config
$PythonProjectManager = 'poetry'
$PythonProjectDir = $here
$PythonSourceDirectory = 'src'
$UseAzCliAuthForAzureArtifacts = $true

# Customise the build process
task . FullBuild

#
# Build Process Extensibility Points - uncomment and implement as required
#

# task RunFirst {}
# task PreInit {}
# task PostInit {}
# task PreVersion {}
# task PostVersion {}
# task PreBuild {}
# task PostBuild {}
# task PreTest {}
# task PostTest {}
# task PreTestReport {}
# task PostTestReport {}
# task PreAnalysis {}
# task PostAnalysis {}
# task PrePackage {}
# task PostPackage {}
# task PrePublish {}
# task PostPublish {}
# task RunLast {}
149 changes: 37 additions & 112 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#!/usr/bin/pwsh
#Requires -Version 7
<#
.SYNOPSIS
Runs a .NET flavoured build process.
Runs a Python flavoured build process.
.DESCRIPTION
This script was scaffolded using a template from the Endjin.RecommendedPractices.Build PowerShell module.
It uses the InvokeBuild module to orchestrate an opinonated software build process for .NET solutions.
This script was scaffolded using a template from the ZeroFailed project.
It uses the InvokeBuild module to orchestrate an opinionated software build process for Python projects.
.EXAMPLE
PS C:\> ./build.ps1
Downloads any missing module dependencies (Endjin.RecommendedPractices.Build & InvokeBuild) and executes
Downloads any missing module dependencies (ZeroFailed & InvokeBuild) and executes
the build process.
.PARAMETER Tasks
Optionally override the default task executed as the entry-point of the build.
.PARAMETER Configuration
The build configuration, defaults to 'Release'.
.PARAMETER BuildRepositoryUri
Optional URI that supports pulling MSBuild logic from a web endpoint (e.g. a GitHub blob).
.PARAMETER SourcesDir
The path where the source code to be built is located, defaults to the current working directory.
.PARAMETER CoverageDir
Expand All @@ -26,30 +23,23 @@
The output path for any packages produced as part of the build.
.PARAMETER LogLevel
The logging verbosity.
.PARAMETER Clean
When true, the .NET solution will be cleaned and all output/intermediate folders deleted.
.PARAMETER BuildModulePath
The path to import the Endjin.RecommendedPractices.Build module from. This is useful when
testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet
available in the PowerShell Gallery.
.PARAMETER BuildModuleVersion
The version of the Endjin.RecommendedPractices.Build module to import. This is useful when
testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet
available in the PowerShell Gallery.
.PARAMETER ZfModulePath
The path to import the ZeroFailed module from. This is useful when testing pre-release
versions of ZeroFailed that are not yet available in the PowerShell Gallery.
.PARAMETER ZfModuleVersion
The version of the ZeroFailed module to import. This is useful when testing pre-release
versions of ZeroFailed that are not yet available in the PowerShell Gallery.
.PARAMETER InvokeBuildModuleVersion
The version of the InvokeBuild module to be used.
#>
[CmdletBinding()]
param (
[Parameter(Position = 0)]
[Parameter(Position=0)]
[string[]] $Tasks = @("."),

[Parameter()]
[string] $Configuration = "Debug",

[Parameter()]
[string] $BuildRepositoryUri = "",

[Parameter()]
[string] $SourcesDir = $PWD,

Expand All @@ -63,122 +53,57 @@ param (
[string] $PackagesDir = "_packages",

[Parameter()]
[ValidateSet("minimal", "normal", "detailed")]
[ValidateSet("minimal","normal","detailed")]
[string] $LogLevel = "minimal",

[Parameter()]
[switch] $Clean,

[Parameter()]
[string] $BuildModulePath,

[Parameter()]
[version] $BuildModuleVersion = "1.5.12",
[string] $ZfModulePath,

[Parameter()]
[string] $BuildModulePackageVersion = $BuildModuleVersion,
[string] $ZfModuleVersion = "1.0.6",

[Parameter()]
[version] $InvokeBuildModuleVersion = "5.11.3"
[version] $InvokeBuildModuleVersion = "5.12.1"
)

$ErrorActionPreference = $ErrorActionPreference ? $ErrorActionPreference : 'Stop'
$InformationPreference = 'Continue'

$ErrorActionPreference = 'Stop'
$here = Split-Path -Parent $PSCommandPath

#region InvokeBuild setup
if (!(Get-Module -ListAvailable InvokeBuild)) {
Install-Module InvokeBuild -RequiredVersion $InvokeBuildModuleVersion -Scope CurrentUser -Force -Repository PSGallery
}
Import-Module InvokeBuild
# This handles calling the build engine when this file is run like a normal PowerShell script
# (i.e. avoids the need to have another script to setup the InvokeBuild environment and issue the 'Invoke-Build' command )
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
Install-PSResource InvokeBuild -Version $InvokeBuildModuleVersion -Scope CurrentUser -TrustRepository -Verbose:$false | Out-Null
try {
# Add handling for when we have to pass an array of tasks as a space-delimited string (e.g. when called from bash)
if ($Tasks.Count -eq 1 -and $Tasks -match ",") {
Write-Host "Splitting tasks provided as delimited string: $Tasks"
$Tasks = $Tasks -split ","
Write-Host "Split tasks: `n$Tasks"
}
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
}
catch {
$_.ScriptStackTrace
throw
Write-Host -f Yellow "`n`n***`n*** Build Failure Summary - check previous logs for more details`n***"
Write-Host -f Yellow $_.Exception.Message
Write-Host -f Yellow $_.ScriptStackTrace
exit 1
}
return
}
#endregion

#region Import shared tasks and initialise build framework
if (!($BuildModulePath)) {
if (!(Get-Module -ListAvailable Endjin.RecommendedPractices.Build | ? { $_.Version -eq $BuildModuleVersion })) {
Write-Information "Installing 'Endjin.RecommendedPractices.Build' module: $BuildModulePackageVersion"
Install-Module Endjin.RecommendedPractices.Build -RequiredVersion $BuildModulePackageVersion -Scope CurrentUser -Force -Repository PSGallery -AllowPrerelease:$($BuildModulePackageVersion -imatch "-")
}
$BuildModulePath = "Endjin.RecommendedPractices.Build"
#region Initialise build framework
$splat = @{ Force = $true; Verbose = $false}
Import-Module Microsoft.PowerShell.PSResourceGet
if (!($ZfModulePath)) {
Install-PSResource ZeroFailed -Version $ZfModuleVersion -Scope CurrentUser -TrustRepository | Out-Null
$ZfModulePath = "ZeroFailed"
$splat.Add("RequiredVersion", ($ZfModuleVersion -split '-')[0])
}
else {
Write-Information "BuildModulePath: $BuildModulePath"
Write-Host "ZfModulePath: $ZfModulePath"
}
Import-Module $BuildModulePath -RequiredVersion $BuildModuleVersion -Force

# Load the build process & tasks
. Endjin.RecommendedPractices.Build.tasks
$splat.Add("Name", $ZfModulePath)
# Ensure only 1 version of the module is loaded
Get-Module ZeroFailed | Remove-Module
Import-Module @splat
$ver = "{0} {1}" -f (Get-Module ZeroFailed).Version, (Get-Module ZeroFailed).PrivateData.PsData.PreRelease
Write-Host "Using ZeroFailed module version: $ver"
#endregion


#
# Build process control options
#
$SkipInit = $false
$SkipVersion = $false
$SkipBuild = $false
$CleanBuild = $Clean
$SkipRunPyTest = $false
$SkipTest = $false
$SkipTestReport = $false
$SkipAnalysis = $true
$SkipPackage = $false
$SkipPublish = $false


# NOTE: Install the 'Endjin.RecommendedPractices.Build' VS Code extension to get handy
# snippets for enabling & configuring features in this build script.
# Once installed <CTRL-ALT-J> will open the snippet picker and you can type 'build'
# to see the available snippets.

#
# Build process configuration
#

$PythonPoetryProject = $here
$SkipPrAutoflowEnrollmentCheck = $true
$PythonPackageRepoUrl = "TBD"

# Synopsis: Build, Test and Package
task . FullBuild


# build extensibility tasks
task RunFirst {}
task PreInit {}
task PostInit {}
task PreVersion {}
task PostVersion {}
task PreBuild {}
task PostBuild {}
task PreTest {}
task PostTest {}
task PreTestReport {}
task PostTestReport {}
task PreAnalysis {}
task PostAnalysis {}
task PrePackage {}
task PostPackage {}
task PrePublish {}
task PostPublish {}
task RunLast {}

# Load the build configuration
. $here/.zf/config.ps1
Loading
Loading