Fix drone build pipeline (#1)
#### 📖 Summary - fixes dependency for loading the module itself - adds gitea user as parameter -> deletes old PR comments. #### 📑 Test Plan > 💡 Select your test plan for the code changes. - [x] Tested via Drone.io pipeline - [ ] Custom test - [ ] No test plan ##### Details / Justification <!-- Add your test details or justification for missing tests here. --> #### 📚 Additional Notes <!-- A place for additional detail notes. --> Co-authored-by: OCram85 <marco.blessing@googlemail.com> Reviewed-on: #1
This commit is contained in:
parent
8fd180b776
commit
5559445d7e
50
.drone.yml
50
.drone.yml
@ -15,9 +15,15 @@ steps:
|
|||||||
environment:
|
environment:
|
||||||
EXCLUDE: "(.exe|.dll|.ico|.gitkeep)"
|
EXCLUDE: "(.exe|.dll|.ico|.gitkeep)"
|
||||||
commands:
|
commands:
|
||||||
|
- |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y file
|
||||||
|
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Invoke-FileLinter
|
Invoke-FileLinter
|
||||||
}"
|
}"
|
||||||
|
|
||||||
@ -27,7 +33,9 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Invoke-Linter
|
Invoke-Linter
|
||||||
}"
|
}"
|
||||||
|
|
||||||
@ -35,9 +43,15 @@ steps:
|
|||||||
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
failure: ignore
|
failure: ignore
|
||||||
commands:
|
commands:
|
||||||
|
- |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y file
|
||||||
|
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Invoke-UnitTest -ExcludeTag 'Integration'
|
Invoke-UnitTest -ExcludeTag 'Integration'
|
||||||
}"
|
}"
|
||||||
|
|
||||||
@ -52,22 +66,32 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Send-PRComment
|
Send-PRComment
|
||||||
}"
|
}"
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
include:
|
include:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
depends_on:
|
||||||
|
- "Pwsh FileLinter"
|
||||||
|
- "ScriptAnalyzer"
|
||||||
|
- "Pester"
|
||||||
|
|
||||||
- name: "buildState"
|
- name: "buildState"
|
||||||
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Invoke-BuildState
|
Invoke-BuildState
|
||||||
}"
|
}"
|
||||||
|
depends_on:
|
||||||
|
- "PRComment"
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@ -88,12 +112,16 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Update-ModuleMeta -Verbose
|
Update-ModuleMeta -Verbose
|
||||||
}"
|
}"
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
New-BuildPackage -AdditionalPath './src/Rules' -Verbose
|
New-BuildPackage -AdditionalPath './src/Rules' -Verbose
|
||||||
}"
|
}"
|
||||||
|
|
||||||
@ -112,11 +140,13 @@ steps:
|
|||||||
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
#failure: ignore
|
#failure: ignore
|
||||||
environment:
|
environment:
|
||||||
NexusToken:
|
NuGetToken:
|
||||||
from_secret: NexusToken
|
from_secret: PSGallery
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
Import-Module './src/DroneHelper.psd1';
|
Import-Module './tools/DevDependency.psm1' -ErrorAction 'Stop';
|
||||||
|
Invoke-FixDevDependency;
|
||||||
|
Import-Module './src/DroneHelper.psd1' -ErrorAction 'Stop';
|
||||||
Invoke-Publish -Verbose
|
Invoke-Publish -Verbose
|
||||||
}"
|
}"
|
||||||
|
@ -143,8 +143,8 @@ steps:
|
|||||||
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
image: mcr.microsoft.com/dotnet/sdk:6.0-focal
|
||||||
#failure: ignore
|
#failure: ignore
|
||||||
environment:
|
environment:
|
||||||
NexusToken:
|
NuGetToken:
|
||||||
from_secret: NexusToken
|
from_secret: PSGallery
|
||||||
commands:
|
commands:
|
||||||
- |
|
- |
|
||||||
pwsh -NonInteractive -c "& {
|
pwsh -NonInteractive -c "& {
|
||||||
|
@ -35,9 +35,9 @@ function Invoke-Publish {
|
|||||||
Expand-Archive @ExpandParams
|
Expand-Archive @ExpandParams
|
||||||
|
|
||||||
$PublishParams = @{
|
$PublishParams = @{
|
||||||
Repository = 'Nexus'
|
Repository = 'PSGallery'
|
||||||
Path = $Repo.Bin.ExpandPath
|
Path = $Repo.Bin.ExpandPath
|
||||||
NuGetApiKey = $Env:NexusToken
|
NuGetApiKey = $Env:NuGetToken
|
||||||
Verbose = $VerbosePreference
|
Verbose = $VerbosePreference
|
||||||
ErrorAction = 'Stop'
|
ErrorAction = 'Stop'
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ function Invoke-InstallDependency {
|
|||||||
$PoshParams = @{
|
$PoshParams = @{
|
||||||
Name = 'posh-git'
|
Name = 'posh-git'
|
||||||
Scope = 'CurrentUser'
|
Scope = 'CurrentUser'
|
||||||
RequiredVersion = '1.0.0'
|
RequiredVersion = '1.1.0'
|
||||||
Force = $true
|
Force = $true
|
||||||
SkipPublisherCheck = $true
|
SkipPublisherCheck = $true
|
||||||
AllowClobber = $true
|
AllowClobber = $true
|
||||||
|
@ -29,10 +29,17 @@ function Send-PRComment {
|
|||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $false, HelpMessage = 'HelpMessage')]
|
[Parameter(Mandatory = $false, HelpMessage = 'HelpMessage')]
|
||||||
[ValidateSet('Add', 'Edit', 'Renew')]
|
[ValidateSet('Add', 'Edit', 'Renew')]
|
||||||
[string]$Mode = 'Renew'
|
[string]$Mode = 'Renew',
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false, HelpMessage = 'Gitea user for drone bot')]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$GiteaUser = 'drone-bot'
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# workaround for false positive PSReviewUnusedParameter
|
||||||
|
$null = $GiteaUser
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
@ -89,7 +96,7 @@ function Send-PRComment {
|
|||||||
if ($Mode -eq 'Renew') {
|
if ($Mode -eq 'Renew') {
|
||||||
$Comments = Invoke-RestMethod -Method 'Get' -Headers $APIHeaders -Uri $CommentAPICall
|
$Comments = Invoke-RestMethod -Method 'Get' -Headers $APIHeaders -Uri $CommentAPICall
|
||||||
$DroneComments = $Comments | Where-Object {
|
$DroneComments = $Comments | Where-Object {
|
||||||
$_.user.login -eq 'drone'
|
$_.user.login -eq $GiteaUser
|
||||||
} | Select-Object -ExpandProperty 'id'
|
} | Select-Object -ExpandProperty 'id'
|
||||||
Write-Debug -Message ('Found Drone comments: {0}.' -f ($DroneComments -join ', '))
|
Write-Debug -Message ('Found Drone comments: {0}.' -f ($DroneComments -join ', '))
|
||||||
foreach ($id in $DroneComments) {
|
foreach ($id in $DroneComments) {
|
||||||
|
64
tools/DevDependency.psm1
Normal file
64
tools/DevDependency.psm1
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
function Invoke-FixDevDependency {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs dev dependencies.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Invoke-FixDevDependency acts as workaround to load the dependencies needed to load the pwsh module.
|
||||||
|
This is just standalone version of the embedded `Invoke-InstallDependency` which can't be called
|
||||||
|
by the DroneHelper build pipeline itself.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param ()
|
||||||
|
|
||||||
|
process {
|
||||||
|
try {
|
||||||
|
$PSScriptParams = @{
|
||||||
|
Name = 'PSScriptAnalyzer'
|
||||||
|
Scope = 'CurrentUser'
|
||||||
|
RequiredVersion = '1.20.0'
|
||||||
|
Force = $true
|
||||||
|
SkipPublisherCheck = $true
|
||||||
|
AllowClobber = $true
|
||||||
|
Verbose = $VerbosePreference
|
||||||
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
Install-Module @PSScriptParams
|
||||||
|
|
||||||
|
$PesterParams = @{
|
||||||
|
Name = 'Pester'
|
||||||
|
Scope = 'CurrentUser'
|
||||||
|
RequiredVersion = '5.3.1'
|
||||||
|
Force = $true
|
||||||
|
SkipPublisherCheck = $true
|
||||||
|
AllowClobber = $true
|
||||||
|
Verbose = $VerbosePreference
|
||||||
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
Install-Module @PesterParams
|
||||||
|
|
||||||
|
$PoshParams = @{
|
||||||
|
Name = 'posh-git'
|
||||||
|
Scope = 'CurrentUser'
|
||||||
|
RequiredVersion = '1.1.0'
|
||||||
|
Force = $true
|
||||||
|
SkipPublisherCheck = $true
|
||||||
|
AllowClobber = $true
|
||||||
|
Verbose = $VerbosePreference
|
||||||
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
Install-Module @PoshParams
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$ExecParams = @{
|
||||||
|
Exception = [System.Exception]::new(
|
||||||
|
'Could not install required build dependencies!',
|
||||||
|
$PSItem.Exception
|
||||||
|
)
|
||||||
|
ErrorAction = 'Stop'
|
||||||
|
}
|
||||||
|
Write-Error @ExecParams
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user