Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Add `extra-install-packages` input to install additional apt packages required by custom dangerfiles
- Custom dangerfiles receive full Danger API access (`fail`, `warn`, `message`, `markdown`, `danger`)
- Enables repositories to extend Danger checks without overwriting shared workflow comments
- Sentry-CLI integration test action - Add `InvokeSentryResult::Events()` method to extract events from envelopes ([#137](https://github.com/getsentry/github-workflows/pull/137))

## 3.1.0

Expand Down
26 changes: 26 additions & 0 deletions sentry-cli/integration-test/action.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ class InvokeSentryResult
return $envelopes
}

# Events are extracted from envelopes, each event body as single item.
# Note: Unlike Envelopes(), this method discards potential duplicates based on event_id.
[string[]]Events()
{
$ids = @()
$events = @()
foreach ($envelope in $this.Envelopes())
{
$lines = @($envelope -split "\\n")
$header = $lines[0].Trim() | ConvertFrom-Json
$eventId = $header | Select-Object -ExpandProperty event_id -ErrorAction SilentlyContinue
if ($eventId -and $ids -notcontains $eventId)
{
$body = $lines | Select-Object -Skip 1 | Where-Object {
($_ | ConvertFrom-Json | Select-Object -ExpandProperty event_id -ErrorAction SilentlyContinue) -eq $eventId
} | Select-Object -First 1
if ($body)
{
$ids += $eventId
$events += $body
}
}
}
return $events
}

[bool]HasErrors()
{
return $this.ServerStdErr.Length -gt 0
Expand Down
26 changes: 26 additions & 0 deletions sentry-cli/integration-test/tests/action.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,30 @@ helloworld
$result.Envelopes().Length | Should -Be 1
$result.Envelopes()[0].Length | Should -Be 357
}

It "discards duplicate events" {
$result = Invoke-SentryServer {
param([string]$url)
Invoke-WebRequest -Uri "$url/api/0/envelope" -Method Post -Body @'
{"dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42","sent_at":"2025-11-20T03:52:42.924Z"}
{"type":"session","length":42}
{"sid":"66356dadc138458a8d5cd9e258065175"}
'@
Invoke-WebRequest -Uri "$url/api/0/envelope" -Method Post -Body @'
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42","sent_at":"2025-11-20T03:53:38.929Z"}
{"type":"event","length":47,"content_type":"application/json"}
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc"}
'@
Invoke-WebRequest -Uri "$url/api/0/envelope" -Method Post -Body @'
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42","sent_at":"2025-11-20T03:53:41.505Z"}
{"type":"event","length":47,"content_type":"application/json"}
{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc"}
'@
}

Should -ActualValue $result.HasErrors() -BeFalse
$result.Envelopes().Length | Should -Be 3
$result.Events().Length | Should -Be 1
$result.Events()[0].Length | Should -Be 47
}
}
Loading