Fix reflection errors preventing Sentry events from being sent in PowerShell #227
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'release/**' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dependencies | |
uses: ./.github/actions/setup-dependencies | |
- name: Create module archive | |
run: Compress-Archive -Path modules/Sentry/* -DestinationPath modules/Sentry.zip | |
shell: pwsh | |
- name: Upload release artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ github.sha }} | |
path: modules/*.zip | |
test: | |
name: ${{ matrix.os }} - ${{ matrix.shell }} ${{ matrix.version }} | |
runs-on: ${{ matrix.os == 'ubuntu' && 'ubuntu-latest' || matrix.os == 'macos' && 'macos-latest' || matrix.os == 'windows' && 'windows-latest' || matrix.os }} | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu] | |
shell: [pwsh] | |
version: | |
- '7.5.0' | |
- '7.4.0' | |
# Test builtin `pwsh` version on all `*-latest` os images and Windows Powershell on Windows 2022 and 2025. | |
include: | |
- os: ubuntu | |
shell: pwsh | |
- os: macos | |
shell: pwsh | |
- os: windows | |
shell: pwsh | |
- os: windows-2022 | |
shell: powershell | |
- os: windows-2025 | |
shell: powershell | |
defaults: | |
run: | |
shell: ${{ matrix.shell }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download release artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ github.sha }} | |
- name: Extract module archives | |
run: | | |
Remove-Item -Recurse -Force modules/Sentry | |
Expand-Archive -Path Sentry.zip -DestinationPath modules/Sentry | |
- name: Setup PowerShell ${{ matrix.version }} | |
if: ${{ matrix.version != '' }} | |
uses: ./.github/actions/setup-powershell | |
env: | |
POWERSHELL_VERSION: ${{ matrix.version }} | |
- run: $PSVersionTable | |
# We don't test module loading with Pester because we're unable to unload the module between tests. | |
# Testing as a separate step allows unloads it automatically at the step end. | |
- name: Module loading | |
run: | | |
. ./scripts/settings.ps1 | |
# Loading the first time | |
Get-Item ./modules/Sentry/Sentry.psd1 | Import-Module -PassThru | |
# This needs to return actual types (method overloads) | |
[Sentry.SentrySdk]::init | |
# Loading the second time must be possible, without errors | |
Get-Item ./modules/Sentry/Sentry.psd1 | Import-Module | |
# And accessing APIs must still work too | |
[Sentry.SentrySdk]::init | |
- name: Unit tests | |
run: | | |
. ./scripts/settings.ps1 | |
Get-Item ./modules/Sentry/Sentry.psd1 | Import-Module | |
$config = New-PesterConfiguration | |
$config.Run.Path = "tests" | |
$config.TestResult.Enabled = $true | |
Invoke-Pester -Configuration $config |