From 9147a7d9f4e9d1ba6f4c3507c03b2db3276554f1 Mon Sep 17 00:00:00 2001 From: Ethan Bergstrom <13603162+ethanbergstrom@users.noreply.github.com> Date: Sat, 21 Jan 2023 14:35:42 -0600 Subject: [PATCH] Suppress installation Environment Variable warning (#8) --- .github/workflows/CI.yml | 39 +++++++++------------------------------ CHANGELOG.md | 4 ++++ src/Foil.ps1 | 2 +- src/Foil.psd1 | 2 +- test/Foil.tests.ps1 | 2 +- 5 files changed, 16 insertions(+), 33 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index afe285b..af2e2d4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,9 +15,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PowerShell module cache - uses: actions/cache@v2 + uses: actions/cache@v3 id: cacher with: path: "~/.local/share/powershell/Modules" @@ -30,7 +30,7 @@ jobs: shell: pwsh run: ./build.ps1 - name: Bundle up module - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: module path: ./src/ @@ -39,9 +39,9 @@ jobs: runs-on: windows-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download module - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: module path: C:\Users\runneradmin\Documents\PowerShell\Modules\Foil\ @@ -51,44 +51,23 @@ jobs: Run = @{ Exit = $true } - TestResult = @{ - Enabled = $true - OutputFormat = 'JUnitXML' + Output = @{ + Verbosity = 'Detailed' } }) - - name: Upload Pester test results - if: always() - uses: actions/upload-artifact@v2 - with: - name: test-results - path: testResults.xml - name: Upload Chocolatey logs if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: choco-logs path: C:\ProgramData\chocolatey\logs\ - Results: - needs: Test - if: success() || failure() - runs-on: ubuntu-latest - steps: - - name: Download Test Results - uses: actions/download-artifact@v2 - with: - name: test-results - path: test-results - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 - with: - files: test-results/**/*.xml Publish: needs: Test if: github.event_name == 'release' && github.event.action == 'published' runs-on: ubuntu-latest steps: - name: Download module - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: module path: '~/.local/share/powershell/Modules/Foil' diff --git a/CHANGELOG.md b/CHANGELOG.md index 4033525..bb0c54a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.1] - 2023-01-21 +#### Fixed +* No longer emits 'Environment' packages of version 'var' when installing a package that updates environment variables + ## [0.2.0] - 2022-09-28 #### Added * Support for finding and installing prelease packages diff --git a/src/Foil.ps1 b/src/Foil.ps1 index 309ff3e..3420ac4 100644 --- a/src/Foil.ps1 +++ b/src/Foil.ps1 @@ -125,7 +125,7 @@ $Commands = @( $packageRegex = "^(?[\S]+)[\|\s]v(?[\S]+)" $packageReportRegex="^[0-9]*(\s*)(packages installed)" $output | ForEach-Object { - if (($_ -match $packageRegex) -and ($_ -notmatch $packageReportRegex) -and ($_ -notmatch 'already installed') -and $Matches.name -and $Matches.version) { + if (($_ -cmatch $packageRegex) -and ($_ -notmatch $packageReportRegex) -and ($_ -notmatch 'already installed') -and $Matches.name -and $Matches.version) { [pscustomobject]@{ Name = $Matches.name Version = $Matches.version diff --git a/src/Foil.psd1 b/src/Foil.psd1 index ad11178..ce38b70 100644 --- a/src/Foil.psd1 +++ b/src/Foil.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'Foil.psm1' - ModuleVersion = '0.2.0' + ModuleVersion = '0.2.1' GUID = '38430603-9954-45fd-949a-5f79492ffaf7' Author = 'Ethan Bergstrom' Copyright = '2021' diff --git a/test/Foil.tests.ps1 b/test/Foil.tests.ps1 index 5020b3b..500910e 100644 --- a/test/Foil.tests.ps1 +++ b/test/Foil.tests.ps1 @@ -49,7 +49,7 @@ Describe "DSC-compliant package installation and uninstallation" { Get-ChocoPackage -Name $package | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty } It 'silently installs the latest version of a package' { - Install-ChocoPackage -Name $package -Force -ParamsGlobal -Parameters "/InstallDir:$env:ProgramFiles\$package /QuickLaunchShortcut:false" | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty + Install-ChocoPackage -Name $package -Force -ParamsGlobal -Parameters "/InstallDir:$env:ProgramFiles\$package /QuickLaunchShortcut:false" | Should -HaveCount 1 } It 'correctly passed parameters to the package' { Get-ChildItem -Path (Join-Path -Path $env:ProgramFiles -ChildPath $package) -ErrorAction SilentlyContinue | Should -Not -BeNullOrEmpty