diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..a66a3f8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,51 @@ +name: Indented PowerShell module + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest] + + steps: + - uses: actions/checkout@v3 + with: + 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 + + - name: Unit test (pwsh) + if: github.event.pull_request.base.ref == 'main' + shell: pwsh + run: .\build.ps1 -TaskName Test + + - name: Unit test (winps) + if: github.event.pull_request.base.ref == 'main' && runner.os == 'Windows' + 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 + with: + report_paths: '**/build/junit-*.xml' 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, 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 0d06a85..7b000f2 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 $tokens = $errors = $null @@ -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'