From 10679ecd23e10d9aaf93e06b0a8142dfa87b44f4 Mon Sep 17 00:00:00 2001 From: OCram85 Date: Mon, 27 Jun 2022 16:26:45 +0200 Subject: [PATCH] simplify drone setup --- .drone.yml | 52 ++++++++++++++++++---------------------------- tools/DroneIO.psm1 | 38 +++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/.drone.yml b/.drone.yml index 74a98d1..8cebccb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,18 +11,32 @@ steps: - name: Environments image: mcr.microsoft.com/powershell:latest commands: - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-ShowEnv -Verbose}" - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-InstallDependencies -Verbose}" + - | + pwsh -NonInteractive -c "& { + Import-Module './tools/DroneIO.psm1' -Verbose; + Invoke-ShowEnv -Verbose + }" + - name: LintTests image: mcr.microsoft.com/powershell:latest commands: - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-Linter}" + - | + pwsh -NonInteractive -c "& { + Import-Module './tools/DroneIO.psm1'; + Invoke-InstallDependencies; + Invoke-Linter + }" + - name: UnitTests image: mcr.microsoft.com/powershell:latest commands: - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}" + - | + pwsh -NonInteractive -c "& { + Import-Module './tools/DroneIO.psm1'; + Invoke-InstallDependencies; + Invoke-UnitTest + }" + - name: coverage image: plugins/codecov settings: @@ -30,29 +44,3 @@ steps: from_secret: CodeCovToken files: - coverage.xml - ---- -kind: pipeline -type: docker -name: WINDOWS_PWSH7_Build - -platform: - os: linux - arch: amd64 - -steps: - - name: Environments - image: mcr.microsoft.com/powershell:lts-windowsservercore-ltsc2022 - commands: - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-ShowEnv -Verbose}" - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1' -Verbose; Invoke-InstallDependencies -Verbose}" - - name: LintTests - image: mcr.microsoft.com/powershell:lts-windowsservercore-ltsc2022 - commands: - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-Linter}" - - name: UnitTests - image: mcr.microsoft.com/powershell:lts-windowsservercore-ltsc2022 - commands: - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-InstallDependencies}" - - pwsh -NonInteractive -c "& {Import-Module './tools/DroneIO.psm1'; Invoke-UnitTests}" diff --git a/tools/DroneIO.psm1 b/tools/DroneIO.psm1 index 1428b12..4d7a579 100644 --- a/tools/DroneIO.psm1 +++ b/tools/DroneIO.psm1 @@ -30,11 +30,41 @@ function Invoke-InstallDependencies { param () process { + $ErrorActionPreference = 'Stop' try { - Install-Module -Name 'PSScriptAnalyzer' -Scope CurrentUser -RequiredVersion '1.19.1' -Force -SkipPublisherCheck -AllowClobber -Verbose:$VerbosePreference -ErrorAction 'Stop' - Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose:$VerbosePreference -ErrorAction 'Stop' - Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '0.7.3' -Force -SkipPublisherCheck -AllowClobber -Verbose:$VerbosePreference -ErrorAction 'Stop' - Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.2.108' -Verbose:$VerbosePreference -ErrorAction 'Stop' + $ParamsPSScript = @{ + Name = 'PSScriptAnalyzer' + Scope = 'CurrentUser' + RequiredVersion = '1.20.0' + Force = $true + SkipPublisherCheck = $true + AllowClobber = $true + Verbose = $VerbosePreference + } + Install-Module @ParamsPSScript + + $ParamsPester = @{ + Name = 'Pester' + Scope = 'CurrentUser' + RequiredVersion = '5.3.3' + Force = $true + SkipPublisherCheck = $true + AllowClobber = $true + Verbose = $VerbosePreference + } + Install-Module @ParamsPester + + $ParamsPosh = @{ + Name = 'posh-git' + Scope = 'CurrentUser' + RequiredVersion = '1.1.0' + Force = $true + SkipPublisherCheck = $true + AllowClobber = $true + Verbose = $VerbosePreference + #ErrorAction = 'Stop' + } + Install-Module @ParamsPosh } catch { $ExceParams = @{