From 3b0cd779ad531007ac52f57cc531db3f0d381ece Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 09:01:03 +0100 Subject: [PATCH 01/11] Adds actions workflow --- .github/workflows/main.yml | 42 ++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..2dc4b4b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,42 @@ +name: Indented PowerShell module + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + + concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + + - name: Build + shell: pwsh + run: .\build.ps1 -TaskName Clean, Build + + - name: Unit test (pwsh) + if: github.event.pull_request.base.ref == 'main' + shell: pwsh + run: .\build.ps1 -TaskName Test + + - name: Unit test (winps) + if: runner.os == 'Windows' && github.event.pull_request.base.ref == 'main' + shell: powershell + run: .\build.ps1 -TaskName Test + + - name: Publish Test Report + if: github.event.pull_request.base.ref == 'main' && always() + uses: mikepenz/action-junit-report@v2 diff --git a/.vscode/settings.json b/.vscode/settings.json index 8cfdcbc..d8a210b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "diffEditor.ignoreTrimWhitespace": true, "editor.trimAutoWhitespace": true, - "editor.renderFinalNewline": false, + "editor.renderFinalNewline": "off", "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "files.trimFinalNewlines": true, From 9a9d22af941323b6d052744f3d98f37e352b473f Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 09:04:24 +0100 Subject: [PATCH 02/11] Adds Setup --- .github/workflows/main.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2dc4b4b..dff0e6b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,16 @@ jobs: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} + - name: Setup (pwsh) + if: github.event.pull_request.base.ref == 'main' + shell: pwsh + run: .\build.ps1 -TaskName Setup + + - name: Setup (winps) + if: github.event.pull_request.base.ref == 'main' && runner.os == 'Windows' + shell: powershell + run: .\build.ps1 -TaskName Setup + - name: Build shell: pwsh run: .\build.ps1 -TaskName Clean, Build @@ -33,7 +43,7 @@ jobs: run: .\build.ps1 -TaskName Test - name: Unit test (winps) - if: runner.os == 'Windows' && github.event.pull_request.base.ref == 'main' + if: github.event.pull_request.base.ref == 'main' && runner.os == 'Windows' shell: powershell run: .\build.ps1 -TaskName Test From 2cdd41ecd482e14932411fdbfbf780e4a8b25c6b Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 09:31:34 +0100 Subject: [PATCH 03/11] Fix report file name --- build.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index 0d06a85..29c55c5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -65,7 +65,7 @@ function Test { } } - Import-Module -Name $modulePath -Force -Global + $moduleInfo = Import-Module -Name $modulePath -Force -Global -PassThru $configuration = @{ Run = @{ @@ -78,8 +78,9 @@ function Test { OutputPath = Join-Path -Path $PSScriptRoot -ChildPath 'build\codecoverage.xml' } TestResult = @{ - Enabled = $true - OutputPath = Join-Path -Path $PSScriptRoot -ChildPath 'build\nunit.xml' + Enabled = $true + OutputPath = Join-Path -Path $PSScriptRoot -ChildPath ('build\junit-{0}.xml' -f $moduleInfo.Name) + OutputFormat = 'JUnitXml' } Output = @{ Verbosity = 'Detailed' From eb860ee4777a6aab7bcb5ce816d67245f4bb5dc6 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 09:41:41 +0100 Subject: [PATCH 04/11] Removes concurrency control --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dff0e6b..436a117 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,10 +13,6 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - steps: - uses: actions/checkout@v3 with: From 938ebb80d2e1f1e9f595c0ed5d20174d8dd9bc6b Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 09:44:10 +0100 Subject: [PATCH 05/11] Fixes report path --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 436a117..d82b7c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,3 +46,5 @@ jobs: - name: Publish Test Report if: github.event.pull_request.base.ref == 'main' && always() uses: mikepenz/action-junit-report@v2 + with: + report_paths: '**/build/junit-*.xml' From dc986e17d8484820b57093469edbfea6e642e18a Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 09:46:34 +0100 Subject: [PATCH 06/11] Changes matrix order --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d82b7c8..252d73a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [windows-latest, ubuntu-latest] steps: - uses: actions/checkout@v3 From defb62d91d094becb9498620f4213f2184f94a0e Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 18:06:39 +0100 Subject: [PATCH 07/11] What went wrong with the root module --- build.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.ps1 b/build.ps1 index 29c55c5..4887c53 100644 --- a/build.ps1 +++ b/build.ps1 @@ -48,6 +48,8 @@ function Build { Update-Metadata -Path $moduleManifest.FullName -PropertyName DscResourcesToExport -Value $dscResourcesToExport } + + $rootModule | Write-Host } function Test { From 2ec9c06dbea65f523b108960cbd2d494584658da Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 18:09:00 +0100 Subject: [PATCH 08/11] Build again --- build.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index 4887c53..96594fd 100644 --- a/build.ps1 +++ b/build.ps1 @@ -24,6 +24,9 @@ function Build { Build-Module -Path (Resolve-Path $PSScriptRoot\*\build.psd1) $rootModule = Join-Path -Path $PSScriptRoot -ChildPath 'build\*\*\*.psm1' | Resolve-Path + + Get-Content $rootModule | Write-Host + $tokens = $errors = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile( $rootModule, @@ -48,8 +51,6 @@ function Build { Update-Metadata -Path $moduleManifest.FullName -PropertyName DscResourcesToExport -Value $dscResourcesToExport } - - $rootModule | Write-Host } function Test { From 2c957ba9ae308ce1071f1edbc40bdf9b45b6a4b3 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 18:11:11 +0100 Subject: [PATCH 09/11] Build-Module is not building? --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 96594fd..c73337a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -21,7 +21,7 @@ function Clean { } function Build { - Build-Module -Path (Resolve-Path $PSScriptRoot\*\build.psd1) + Build-Module -Path (Resolve-Path $PSScriptRoot\*\build.psd1) -Verbose $rootModule = Join-Path -Path $PSScriptRoot -ChildPath 'build\*\*\*.psm1' | Resolve-Path From 40fe9ba8126dff5bc1d5a4d98d75ed6a1af55d4b Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 18:15:47 +0100 Subject: [PATCH 10/11] Disables fail-fast --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 252d73a..a66a3f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,7 @@ jobs: build: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [windows-latest, ubuntu-latest] From 6b9e9f064de3431708e765f66885126780c39797 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 25 May 2023 18:45:20 +0100 Subject: [PATCH 11/11] Case-sensitive source directories --- Indented.Net.IP/build.psd1 | 7 +++++++ build.ps1 | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Indented.Net.IP/build.psd1 b/Indented.Net.IP/build.psd1 index 0b21bba..07f173f 100644 --- a/Indented.Net.IP/build.psd1 +++ b/Indented.Net.IP/build.psd1 @@ -1,5 +1,12 @@ @{ ModuleManifest = 'Indented.Net.IP.psd1' + SourceDirectories = @( + 'enum' + 'class' + 'private' + 'public' + ) + PublicFilter = 'public\*.ps1' OutputDirectory = '../build' VersionedOutputDirectory = $true } diff --git a/build.ps1 b/build.ps1 index c73337a..7b000f2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -24,9 +24,6 @@ function Build { Build-Module -Path (Resolve-Path $PSScriptRoot\*\build.psd1) -Verbose $rootModule = Join-Path -Path $PSScriptRoot -ChildPath 'build\*\*\*.psm1' | Resolve-Path - - Get-Content $rootModule | Write-Host - $tokens = $errors = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile( $rootModule,