diff --git a/.github/Dependabot.yml b/.github/Dependabot.yml index 0dd3319..4a7c04f 100644 --- a/.github/Dependabot.yml +++ b/.github/Dependabot.yml @@ -14,4 +14,4 @@ updates: - "rebelinux" labels: - "dependencies" - - "automated" \ No newline at end of file + - "automated" diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ce70ef9..1015b96 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -95,4 +95,3 @@ body: - label: >- I have checked for previously opened & closed [issues](https://github.com/AsBuiltReport/AsBuiltReport.Chart/issues) before submitting this bug report. required: true - diff --git a/.github/ISSUE_TEMPLATE/change_request.yml b/.github/ISSUE_TEMPLATE/change_request.yml index 0ad1858..8a2cee0 100644 --- a/.github/ISSUE_TEMPLATE/change_request.yml +++ b/.github/ISSUE_TEMPLATE/change_request.yml @@ -31,4 +31,3 @@ body: - label: >- I have checked for previously opened & closed [issues](https://github.com/AsBuiltReport/AsBuiltReport.Chart/issues) before submitting this change request. required: true - diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index ec4bb38..3ba13e0 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1 @@ -blank_issues_enabled: false \ No newline at end of file +blank_issues_enabled: false diff --git a/.github/workflows/Codeql.yml b/.github/workflows/Codeql.yml index dbe878b..a46295b 100644 --- a/.github/workflows/Codeql.yml +++ b/.github/workflows/Codeql.yml @@ -1,47 +1,47 @@ name: "CodeQL Analysis" on: - push: - branches: [ dev ] - pull_request: - branches: [ dev ] - schedule: - - cron: '0 2 * * *' + push: + branches: [dev] + pull_request: + branches: [dev] + schedule: + - cron: "0 2 * * *" jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'csharp' ] + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + language: ["csharp"] - steps: - - name: Checkout repository - uses: actions/checkout@v6 + steps: + - name: Checkout repository + uses: actions/checkout@v6 - # Initializes the CodeQL tools and creates a CodeQL database - - name: Initialize CodeQL - uses: github/codeql-action/init@v4 - with: - build-mode: none - languages: ${{ matrix.language }} - # If you have custom queries, you can add them here using a queries property + # Initializes the CodeQL tools and creates a CodeQL database + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + build-mode: none + languages: ${{ matrix.language }} + # If you have custom queries, you can add them here using a queries property - # Autobuild attempts to build the C# project automatically. - # For complex C# projects, you may need to replace this with custom build commands (e.g., using `dotnet build`) - - name: Autobuild - uses: github/codeql-action/autobuild@v4 - with: - working-directory: ./Sources + # Autobuild attempts to build the C# project automatically. + # For complex C# projects, you may need to replace this with custom build commands (e.g., using `dotnet build`) + - name: Autobuild + uses: github/codeql-action/autobuild@v4 + with: + working-directory: ./Sources - # Performs the CodeQL analysis and uploads the results to GitHub - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 - with: - category: "/language:${{ matrix.language }}" + # Performs the CodeQL analysis and uploads the results to GitHub + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/PSScriptAnalyzer.yml b/.github/workflows/PSScriptAnalyzer.yml index 210b4c4..759bcad 100644 --- a/.github/workflows/PSScriptAnalyzer.yml +++ b/.github/workflows/PSScriptAnalyzer.yml @@ -1,17 +1,17 @@ name: PSScriptAnalyzer on: [push, pull_request] jobs: - lint: - name: Run PSScriptAnalyzer - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - name: lint - uses: devblackops/github-action-psscriptanalyzer@master - with: - sendComment: true - failOnErrors: true - failOnWarnings: false - failOnInfos: false - repoToken: ${{ secrets.GITHUB_TOKEN }} - settingsPath: .github/workflows/PSScriptAnalyzerSettings.psd1 \ No newline at end of file + lint: + name: Run PSScriptAnalyzer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: lint + uses: devblackops/github-action-psscriptanalyzer@master + with: + sendComment: true + failOnErrors: true + failOnWarnings: false + failOnInfos: false + repoToken: ${{ secrets.GITHUB_TOKEN }} + settingsPath: .github/workflows/PSScriptAnalyzerSettings.psd1 diff --git a/.github/workflows/Pester.yml b/.github/workflows/Pester.yml index 67527da..b4201ce 100644 --- a/.github/workflows/Pester.yml +++ b/.github/workflows/Pester.yml @@ -1,90 +1,95 @@ name: Pester Tests on: - push: - branches: - - main - - dev - - master - pull_request: - branches: - - main - - dev - - master - workflow_dispatch: + push: + branches: + - main + - dev + - master + pull_request: + branches: + - main + - dev + - master + workflow_dispatch: jobs: - test: - name: Pester Tests - ${{ matrix.os }} - ${{ matrix.shell }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - shell: [pwsh] - include: - - os: windows-latest - shell: powershell - exclude: - - os: ubuntu-latest - shell: powershell - - os: macos-latest - shell: powershell + test: + name: Pester Tests - ${{ matrix.os }} - ${{ matrix.shell }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + shell: [pwsh] + include: + - os: windows-latest + shell: powershell + exclude: + - os: ubuntu-latest + shell: powershell + - os: macos-latest + shell: powershell - defaults: - run: - shell: ${{ matrix.shell }} + defaults: + run: + shell: ${{ matrix.shell }} - steps: - - name: Checkout repository - uses: actions/checkout@v4 + steps: + - name: Checkout repository + uses: actions/checkout@v6 + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: "8.0.x" + - name: Restore dependencies + run: dotnet restore ./Sources + - name: Build the library for MacOS + run: dotnet publish ./Sources -c Release -r osx-arm64 + if: matrix.os == 'macos-latest' + - name: Copy the library for MacOS + run: Copy-Item -Path ./Sources/bin/Release/netstandard2.0/osx-arm64/publish/* -Destination ./AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-arm64 -Recurse + if: matrix.os == 'macos-latest' + - name: Build the library for Linux + run: dotnet publish ./Sources -c Release -r linux-x64 + if: matrix.os == 'ubuntu-latest' + - name: Copy the library for Linux + run: Copy-Item -Path ./Sources/bin/Release/netstandard2.0/linux-x64/publish/* -Destination ./AsBuiltReport.Chart/Src/Assemblies/Core/linux-x64 -Recurse + if: matrix.os == 'ubuntu-latest' + - name: Build the library for Windows + run: dotnet publish ./Sources -c Release -r win-x64 + if: matrix.os == 'windows-latest' && matrix.shell == 'pwsh' + - name: Copy the library for Windows + run: Copy-Item -Path ./Sources/bin/Release/netstandard2.0/win-x64/publish/* -Destination ./AsBuiltReport.Chart/Src/Assemblies/Core/windows-x64 -Recurse + if: matrix.os == 'windows-latest' && matrix.shell == 'pwsh' + - name: Build the library for Windows PowerShell + run: dotnet publish ./Sources -c Release -r win-x64 + if: matrix.os == 'windows-latest' && matrix.shell == 'powershell' + - name: Copy the library for Windows PowerShell + run: Copy-Item -Path ./Sources/bin/Release/netstandard2.0/win-x64/publish/* -Destination ./AsBuiltReport.Chart/Src/Assemblies/Desktop/windows-x64 -Recurse + if: matrix.os == 'windows-latest' && matrix.shell == 'powershell' + - name: Run tests + run: dotnet test --no-build --verbosity normal ./Sources - - name: Set up PowerShell Gallery - run: | - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + - name: Set up PowerShell Gallery + run: | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - - name: Install Pester - run: | - Install-Module -Name Pester -MinimumVersion 5.0.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser + - name: Install Pester + run: | + Install-Module -Name Pester -MinimumVersion 5.0.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser - - name: Install PScribo - run: | - Install-Module -Name PScribo -MinimumVersion 0.11.1 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser + - name: Run Pester Tests + run: | + $CodeCoverageParam = @{} + $OutputFormatParam = @{ OutputFormat = 'NUnitXml' } - - name: Install PSScriptAnalyzer - run: | - Install-Module -Name PSScriptAnalyzer -MinimumVersion 1.0.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser + .\Tests\Invoke-Tests.ps1 @CodeCoverageParam @OutputFormatParam - - name: Install AsBuiltReport.Core - run: | - Install-Module -Name AsBuiltReport.Core -MinimumVersion 1.6.0 -Repository PSGallery -Force -AllowClobber -Scope CurrentUser - - - name: Run Pester Tests - run: | - $CodeCoverageParam = @{} - $OutputFormatParam = @{ OutputFormat = 'NUnitXml' } - - # Only enable code coverage for Windows + pwsh - if ('${{ matrix.os }}' -eq 'windows-latest' -and '${{ matrix.shell }}' -eq 'pwsh') { - $CodeCoverageParam = @{ CodeCoverage = $true } - } - - .\Tests\Invoke-Tests.ps1 @CodeCoverageParam @OutputFormatParam - - - name: Upload test results - if: always() - uses: actions/upload-artifact@v4 - with: - name: test-results-${{ matrix.os }}-${{ matrix.shell }} - path: Tests/testResults.xml - retention-days: 30 - - - name: Upload code coverage to Codecov - if: matrix.os == 'windows-latest' && matrix.shell == 'pwsh' - uses: codecov/codecov-action@v5 - with: - files: ./Tests/coverage.xml - flags: unit - name: codecov-${{ matrix.os }}-${{ matrix.shell }} - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: false \ No newline at end of file + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results-${{ matrix.os }}-${{ matrix.shell }} + path: Tests/testResults.xml + retention-days: 30 diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 91b82b3..46c2838 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -1,69 +1,77 @@ name: Publish PowerShell Module on: - release: - types: [published] + release: + types: [published] jobs: - publish-to-psgallery: - runs-on: windows-latest - steps: - - uses: actions/checkout@v6 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: '8.0.x' - - name: Restore dependencies - run: dotnet restore ./Sources - - name: Build the library for MacOS - run: dotnet publish ./Sources -c Release -r osx-x64 - - name: Copy the library for MacOS - run: copy ./Sources/bin/Release/netstandard2.0/osx-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/osx-x64 - - name: Build the library for Linux - run: dotnet publish ./Sources -c Release -r linux-x64 - - name: Copy the library for Linux - run: copy ./Sources/bin/Release/netstandard2.0/linux-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/linux-x64 - - name: Build the library for Windows - run: dotnet publish ./Sources -c Release -r win-x64 - - name: Copy the library for Windows - run: copy ./Sources/bin/Release/netstandard2.0/win-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/windows-x64 - - name: Run tests - run: dotnet test --no-build --verbosity normal ./Sources - - name: Set PSRepository to Trusted for PowerShell Gallery - shell: pwsh - run: | - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - - name: Test Module Manifest - shell: pwsh - run: | - Test-ModuleManifest .\AsBuiltReport.Chart\AsBuiltReport.Chart.psd1 - - name: Publish module to PowerShell Gallery - shell: pwsh - run: | - Publish-Module -Path .\AsBuiltReport.Chart\ -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }} -Verbose - tweet: - needs: publish-to-psgallery - runs-on: ubuntu-latest - steps: - - uses: Eomm/why-don-t-you-tweet@v2 - # We don't want to tweet if the repository is not a public one - if: ${{ !github.event.repository.private }} - with: - # GitHub event payload - # https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release - tweet-message: "[New Release] ${{ github.event.repository.name }} ${{ github.event.release.tag_name }}! Check out what's new! ${{ github.event.release.html_url }} #AsBuiltReport #PowerShell" - env: - TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} - TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} - TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} - TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} - bsky-post: - needs: publish-to-psgallery - runs-on: ubuntu-latest - steps: - - uses: zentered/bluesky-post-action@v0.3.0 - with: - post: "[New Release] ${{ github.event.repository.name }} ${{ github.event.release.tag_name }}! Check out what's new! ${{ github.event.release.html_url }} #AsBuiltReport #PowerShell" - env: - BSKY_IDENTIFIER: ${{ secrets.BSKY_IDENTIFIER }} - BSKY_PASSWORD: ${{ secrets.BSKY_PASSWORD }} + publish-to-psgallery: + runs-on: windows-latest + steps: + - uses: actions/checkout@v6 + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: "8.0.x" + - name: Restore dependencies + run: dotnet restore ./Sources + - name: Build the library for MacOS X64 + run: dotnet publish ./Sources -c Release -r osx-x64 + - name: Copy the library for MacOS X64 + run: copy ./Sources/bin/Release/netstandard2.0/osx-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-x64 + - name: Build the library for MacOS Arm64 + run: dotnet publish ./Sources -c Release -r osx-arm64 + - name: Copy the library for MacOS Arm64 + run: copy ./Sources/bin/Release/netstandard2.0/osx-arm64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-arm64 + - name: Build the library for Linux + run: dotnet publish ./Sources -c Release -r linux-x64 + - name: Copy the library for Linux + run: copy ./Sources/bin/Release/netstandard2.0/linux-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/linux-x64 + - name: Build the library for Windows + run: dotnet publish ./Sources -c Release -r win-x64 + - name: Copy the library for Windows + run: copy ./Sources/bin/Release/netstandard2.0/win-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Core/windows-x64 + - name: Build the library for Windows PowerShell + run: dotnet publish ./Sources -c Release -r win-x64 + - name: Copy the library for Windows PowerShell + run: copy ./Sources/bin/Release/netstandard2.0/win-x64/publish/*.* ./AsBuiltReport.Chart/Src/Assemblies/Desktop/windows-x64 + - name: Run tests + run: dotnet test --no-build --verbosity normal ./Sources + - name: Set PSRepository to Trusted for PowerShell Gallery + shell: pwsh + run: | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + - name: Test Module Manifest + shell: pwsh + run: | + Test-ModuleManifest .\AsBuiltReport.Chart\AsBuiltReport.Chart.psd1 + - name: Publish module to PowerShell Gallery + shell: pwsh + run: | + Publish-Module -Path .\AsBuiltReport.Chart\ -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }} -Verbose + tweet: + needs: publish-to-psgallery + runs-on: ubuntu-latest + steps: + - uses: Eomm/why-don-t-you-tweet@v2 + # We don't want to tweet if the repository is not a public one + if: ${{ !github.event.repository.private }} + with: + # GitHub event payload + # https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release + tweet-message: "[New Release] ${{ github.event.repository.name }} ${{ github.event.release.tag_name }}! Check out what's new! ${{ github.event.release.html_url }} #AsBuiltReport #PowerShell" + env: + TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} + TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} + TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} + TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} + bsky-post: + needs: publish-to-psgallery + runs-on: ubuntu-latest + steps: + - uses: zentered/bluesky-post-action@v0.3.0 + with: + post: "[New Release] ${{ github.event.repository.name }} ${{ github.event.release.tag_name }}! Check out what's new! ${{ github.event.release.html_url }} #AsBuiltReport #PowerShell" + env: + BSKY_IDENTIFIER: ${{ secrets.BSKY_IDENTIFIER }} + BSKY_PASSWORD: ${{ secrets.BSKY_PASSWORD }} diff --git a/.github/workflows/Stale.yml b/.github/workflows/Stale.yml index 108bcdf..be3ca59 100644 --- a/.github/workflows/Stale.yml +++ b/.github/workflows/Stale.yml @@ -1,19 +1,18 @@ -name: 'Close stale issues and PRs' +name: "Close stale issues and PRs" on: - schedule: - - cron: '30 1 * * *' + schedule: + - cron: "30 1 * * *" jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' - days-before-stale: 60 - days-before-close: 7 - exempt-pr-labels: 'help wanted,enhancement,security,pinned' - stale-pr-label: 'wontfix' - stale-issue-label: 'wontfix' - exempt-issue-labels: 'help wanted,enhancement,security,pinned' - + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions." + days-before-stale: 60 + days-before-close: 7 + exempt-pr-labels: "help wanted,enhancement,security,pinned" + stale-pr-label: "wontfix" + stale-issue-label: "wontfix" + exempt-issue-labels: "help wanted,enhancement,security,pinned" diff --git a/AsBuiltReport.Chart/AsBuiltReport.Chart.psd1 b/AsBuiltReport.Chart/AsBuiltReport.Chart.psd1 index ca2918c..e24a408 100644 --- a/AsBuiltReport.Chart/AsBuiltReport.Chart.psd1 +++ b/AsBuiltReport.Chart/AsBuiltReport.Chart.psd1 @@ -12,7 +12,7 @@ RootModule = 'AsBuiltReport.Chart.psm1' # Version number of this module. - ModuleVersion = '0.1.0' + ModuleVersion = '0.2.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -93,31 +93,26 @@ PrivateData = @{ PSData = @{ - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() + Tags = 'AsBuiltReport', 'Chart', 'Documentation', 'ScottPlot', 'Windows', 'Linux', 'MacOS', 'PSEdition_Desktop', 'PSEdition_Core' # A URL to the license for this module. - # LicenseUri = '' + LicenseUri = 'https://raw.githubusercontent.com/AsBuiltReport/AsBuiltReport.Chart/master/LICENSE' # A URL to the main website for this project. - # ProjectUri = '' + ProjectUri = 'https://github.com/AsBuiltReport/AsBuiltReport.Chart' # A URL to an icon representing this module. - # IconUri = '' + IconUri = 'https://raw.githubusercontent.com/AsBuiltReport/.github/main/profile/images/AsBuiltReport.png' # ReleaseNotes of this module - # ReleaseNotes = '' + ReleaseNotes = 'https://raw.githubusercontent.com/AsBuiltReport/AsBuiltReport.Chart/master/CHANGELOG.md' # Prerelease string of this module # Prerelease = '' # Flag to indicate whether the module requires explicit user acceptance for install/update/save # RequireLicenseAcceptance = $false - - # External dependent modules of this module - # ExternalModuleDependencies = @() - } # End of PSData hashtable } # End of PrivateData hashtable diff --git a/AsBuiltReport.Chart/AsBuiltReport.Chart.psm1 b/AsBuiltReport.Chart/AsBuiltReport.Chart.psm1 index 42a9d1e..57d1e66 100644 --- a/AsBuiltReport.Chart/AsBuiltReport.Chart.psm1 +++ b/AsBuiltReport.Chart/AsBuiltReport.Chart.psm1 @@ -2,7 +2,19 @@ switch ($PSVersionTable.PSEdition) { 'Core' { if ($IsMacOS) { - Import-Module ("$PSScriptRoot{0}Src{0}Assemblies{0}Core{0}osx-x64{0}AsBuiltReportChart.dll" -f [System.IO.Path]::DirectorySeparatorChar) + $architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture + if ($architecture -eq "Arm64" -or $architecture -eq "Arm") { + Write-Verbose "Architecture: ARM (Apple Silicon)" + Import-Module ("$PSScriptRoot{0}Src{0}Assemblies{0}Core{0}mac-osx{0}osx-arm64{0}AsBuiltReportChart.dll" -f [System.IO.Path]::DirectorySeparatorChar) -Verbose -Debug + + } elseif ($architecture -eq "X64" -or $architecture -eq "X86") { + Write-Verbose "Architecture: x86 (Intel)" + Import-Module ("$PSScriptRoot{0}Src{0}Assemblies{0}Core{0}mac-osx{0}osx-x64{0}AsBuiltReportChart.dll" -f [System.IO.Path]::DirectorySeparatorChar) -Verbose -Debug + + } else { + Write-Verbose "Architecture: Unknown or other architecture" + Import-Module ("$PSScriptRoot{0}Src{0}Assemblies{0}Core{0}mac-osx{0}osx-arm64{0}AsBuiltReportChart.dll" -f [System.IO.Path]::DirectorySeparatorChar) -Verbose -Debug + } } elseif ($IsLinux) { Import-Module ("$PSScriptRoot{0}Src{0}Assemblies{0}Core{0}linux-x64{0}AsBuiltReportChart.dll" -f [System.IO.Path]::DirectorySeparatorChar) } elseif ($IsWindows) { diff --git a/AsBuiltReport.Chart/Src/Assemblies/Core/osx-x64/dummy b/AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/dummy similarity index 100% rename from AsBuiltReport.Chart/Src/Assemblies/Core/osx-x64/dummy rename to AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/dummy diff --git a/AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-arm64/dummy b/AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-arm64/dummy new file mode 100644 index 0000000..e69de29 diff --git a/AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-x64/dummy b/AsBuiltReport.Chart/Src/Assemblies/Core/mac-osx/osx-x64/dummy new file mode 100644 index 0000000..e69de29 diff --git a/CHANGELOG.md b/CHANGELOG.md index d933a72..6aed89a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2026-02-20 + +### Added + +- Add pester test to validate the functionality of the module + +### Changed + +- Update module version to 0.2.0 + ## [0.1.0] - 2026-02-19 ### Added diff --git a/Sources/StackedBarChart.cs b/Sources/StackedBarChart.cs index 4941d90..20e945e 100755 --- a/Sources/StackedBarChart.cs +++ b/Sources/StackedBarChart.cs @@ -10,6 +10,10 @@ internal class StackedBar : Chart static StackedBar() { } public object Chart(List values, string[] labels, string[] categoryNames, string filename = "output", int width = 400, int height = 300) { + if (values.Count != categoryNames.Length) + { + throw new Exception("Error: Values and category names must be equal."); + } if (values.Count == labels.Length) { Plot myPlot = new Plot(); diff --git a/Tests/AsBuiltReport.Chart.Functions.Tests.ps1 b/Tests/AsBuiltReport.Chart.Functions.Tests.ps1 new file mode 100644 index 0000000..6b29037 --- /dev/null +++ b/Tests/AsBuiltReport.Chart.Functions.Tests.ps1 @@ -0,0 +1,74 @@ + +# Requires -Version 5.0 + +BeforeAll { + # Import the module + $ModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\AsBuiltReport.Chart\AsBuiltReport.Chart.psd1' + Import-Module $ModulePath -Force +} + +Describe 'AsBuiltReport.Chart Exported Functions' { + It 'Should export New-PieChart' { + Get-Command -Module AsBuiltReport.Chart -Name New-PieChart | Should -Not -BeNullOrEmpty + } + It 'Should export New-BarChart' { + Get-Command -Module AsBuiltReport.Chart -Name New-BarChart | Should -Not -BeNullOrEmpty + } + It 'Should export New-StackedBarChart' { + Get-Command -Module AsBuiltReport.Chart -Name New-StackedBarChart | Should -Not -BeNullOrEmpty + } + + Context 'New-PieChart' { + It 'Should run without error with sample input' { + { New-PieChart -Title 'Test' -Values @(1, 2) -Labels @('A', 'B') -Format 'png' -OutputFolderPath $TestDrive } | Should -Not -Throw + } + It 'Should return a file path as output' { + $result = New-PieChart -Title 'Test' -Values @(1, 2) -Labels @('A', 'B') -Format 'png' -OutputFolderPath $TestDrive + $result | Should -BeOfType 'System.IO.FileSystemInfo' + Test-Path $result | Should -BeTrue + } + It 'Should throw error for missing mandatory parameters' { + { New-PieChart } | Should -Throw + } + It 'Should throw error for mismatched Values and Labels' { + { New-PieChart -Title 'Test' -Values @(1, 2) -Labels @('A') -Format 'png' -OutputFolderPath $TestDrive } | Should -Throw -ExpectedMessage "Error: Values and labels must be equal." + } + } + + Context 'New-BarChart' { + It 'Should run without error with sample input' { + { New-BarChart -Title 'Test' -Values @(1, 2) -Labels @('A', 'B') -Format 'png' -OutputFolderPath $TestDrive } | Should -Not -Throw + } + It 'Should return a file path as output' { + $result = New-BarChart -Title 'Test' -Values @(1, 2) -Labels @('A', 'B') -Format 'png' -OutputFolderPath $TestDrive + $result | Should -BeOfType 'System.IO.FileSystemInfo' + Test-Path $result | Should -BeTrue + } + It 'Should throw error for missing mandatory parameters' { + { New-BarChart } | Should -Throw + } + It 'Should throw error for mismatched Values and Labels' { + { New-BarChart -Title 'Test' -Values @(1, 2) -Labels @('A') -Format 'png' -OutputFolderPath $TestDrive } | Should -Throw -ExpectedMessage "Error: Values and labels must be equal." + } + } + + Context 'New-StackedBarChart' { + It 'Should run without error with sample input' { + { New-StackedBarChart -Title 'Test' -Values @(@(1, 2), @(3, 4)) -Labels @('A', 'B') -LegendCategories @('X', 'Y') -Format 'png' -OutputFolderPath $TestDrive } | Should -Not -Throw + } + It 'Should return a file path as output' { + $result = New-StackedBarChart -Title 'Test' -Values @(@(1, 2), @(3, 4)) -Labels @('A', 'B') -LegendCategories @('X', 'Y') -Format 'png' -OutputFolderPath $TestDrive + $result | Should -BeOfType 'System.IO.FileSystemInfo' + Test-Path $result | Should -BeTrue + } + It 'Should throw error for missing mandatory parameters' { + { New-StackedBarChart } | Should -Throw + } + It 'Should throw error for mismatched Values and Labels' { + { New-StackedBarChart -Title 'Test' -Values @(@(1, 2), @(3, 4)) -Labels @('A') -LegendCategories @('X', 'Y') -OutputFolderPath $TestDrive -Format 'png' } | Should -Throw -ExpectedMessage "Error: Values and labels must be equal." + } + It 'Should throw error for mismatched Values and LegendCategories' { + { New-StackedBarChart -Title 'Test' -Values @(@(1, 2), @(3, 4)) -Labels @('A', 'B') -LegendCategories @('X') -Format 'png' -OutputFolderPath $TestDrive } | Should -Throw -ExpectedMessage "Error: Values and category names must be equal." + } + } +} diff --git a/Tests/Invoke-Tests.ps1 b/Tests/Invoke-Tests.ps1 index f43e37f..7996873 100644 --- a/Tests/Invoke-Tests.ps1 +++ b/Tests/Invoke-Tests.ps1 @@ -58,8 +58,6 @@ Write-Host "`nInstalling required modules..." -ForegroundColor Yellow $RequiredModules = @( @{ Name = 'Pester'; MinimumVersion = '5.0.0' } - @{ Name = 'PScribo'; MinimumVersion = '0.11.1' } - @{ Name = 'PSScriptAnalyzer'; MinimumVersion = '1.0.0' } ) foreach ($Module in $RequiredModules) { @@ -134,7 +132,7 @@ if ($CodeCoverage) { Write-Host "`nRunning Pester tests..." -ForegroundColor Yellow Write-Host '======================================' -ForegroundColor Cyan -$TestResults = Invoke-Pester -Configuration $PesterConfiguration +$TestResults = Invoke-Pester -Configuration $PesterConfiguration -Verbose -Debug # Display results Write-Host "`n======================================" -ForegroundColor Cyan