Skip to content

Commit 97fede8

Browse files
vaindbitsandfoxes
andauthored
ci: deflaking (#2813)
Co-authored-by: Stefan Jandl <[email protected]>
1 parent 0913f4b commit 97fede8

File tree

4 files changed

+89
-72
lines changed

4 files changed

+89
-72
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
8989
test-solution-filters:
9090
runs-on: ubuntu-latest
91+
if: ${{ !startsWith(github.ref_name, 'release/') }}
9192

9293
steps:
9394
- uses: actions/checkout@v4

.github/workflows/vulnerabilities.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@ name: List vulnerable packages
33
on:
44
workflow_dispatch:
55
schedule:
6-
# once a day
7-
- cron: '0 0 * * *'
6+
- cron: "0 0 * * *" # once a day
7+
pull_request:
88

99
jobs:
10-
List-vulnerable-packages:
11-
name: ${{ matrix.os }}
12-
runs-on: ${{ matrix.os }}
13-
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
os: [ubuntu-latest, windows-latest, macos-latest]
10+
list-vulnerable-packages:
11+
name: List vulnerable packages
12+
runs-on: macos-latest
1813

1914
steps:
2015
- name: Checkout
@@ -27,12 +22,13 @@ jobs:
2722

2823
# We only need to restore to check for vulnerable packages
2924
- name: Restore .NET Dependencies
30-
run: dotnet restore --nologo
25+
run: dotnet restore Sentry.sln --nologo
3126

3227
# The dotnet list package command doesn't change its exit code on detection, so tee to a file and scan it
3328
# See https://github.com/NuGet/Home/issues/11315#issuecomment-1243055173
3429
- name: List vulnerable packages
3530
shell: bash
3631
run: |
37-
dotnet list package --vulnerable --include-transitive | tee vulnerable.txt
38-
sh -c "! grep 'has the following vulnerable packages' vulnerable.txt"
32+
dotnet list Sentry.sln package --vulnerable --include-transitive | tee vulnerable.txt
33+
# https://github.com/getsentry/sentry-dotnet/issues/2814
34+
# ! grep 'has the following vulnerable packages' vulnerable.txt

scripts/generate-solution-filters.ps1

Lines changed: 76 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ Set-StrictMode -Version Latest
66
$ErrorActionPreference = "Stop"
77

88
$yamlModule = "powershell-yaml"
9-
$moduleInstalled = Get-Module -ListAvailable -Name $yamlModule
10-
if (-not $moduleInstalled) {
9+
$retries = 5
10+
while (-not (Get-Module -ListAvailable -Name $yamlModule) -and $retries -gt 0)
11+
{
12+
if ($retries -lt 5)
13+
{
14+
Start-Sleep -Seconds 10
15+
}
1116
Write-Debug "The module '$yamlModule' is not installed. Installing..."
1217
Install-Module -Name $yamlModule -Scope CurrentUser -Force
18+
$retries--
1319
}
1420

15-
import-module $yamlModule
21+
Import-Module $yamlModule
1622

1723
$separator = [IO.Path]::DirectorySeparatorChar.ToString()
1824
$lf = if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { "`r`n" } else { "`n" }
@@ -23,88 +29,102 @@ $repoRoot = Join-Path $scriptDir ('..' + $separator) -Resolve
2329
# Load configuration
2430
$configPath = Join-Path $scriptDir $ConfigFile
2531
Write-Debug "Loading configuration file $configPath"
26-
if (-not (Test-Path $configPath)) {
32+
if (-not (Test-Path $configPath))
33+
{
2734
Write-Error "Config file '$configPath' does not exist."
2835
exit 1
2936
}
30-
try {
37+
38+
try
39+
{
3140
$config = Get-Content $configPath | ConvertFrom-Yaml
3241
}
33-
catch {
42+
catch
43+
{
3444
Write-Error "Error parsing config file '$configPath': $_"
3545
exit 1
3646
}
3747

3848
# Get list of all projects in solution
3949
Write-Debug "Searching the repository for projects..."
40-
$projectPaths = Get-ChildItem -Path $repoRoot -Recurse -Filter *.csproj |
41-
Select-Object -ExpandProperty FullName |
42-
ForEach-Object { $_.Replace($repoRoot, '').Replace('\', '/') } # Force linux style separators for glob matching
50+
$projectPaths = Get-ChildItem -Path $repoRoot -Recurse -Filter *.csproj | `
51+
Select-Object -ExpandProperty FullName | `
52+
ForEach-Object { $_.Replace($repoRoot, '').Replace('\', '/') } # Force linux style separators for glob matching
4353
Write-Debug "Found $($projectPaths.Count) projects"
4454

4555
# Generate a solution filter for each filter config
46-
foreach($filter in $config.filterConfigs){
56+
foreach ($filter in $config.filterConfigs)
57+
{
4758
Write-Debug "Processing filter $($filter.outputPath)"
4859

4960
$includedProjects = @()
5061

5162
# Process includes, if present
5263
if ($filter.ContainsKey("include"))
5364
{
54-
# Add include groups
55-
if ($filter.include.ContainsKey("groups"))
56-
{
57-
foreach($group in $filter.include.groups){
58-
Write-Debug "Include $group"
59-
foreach($include in $config.groupConfigs.$group){
60-
$includedProjects += ($projectPaths | Where-Object { $_ -like $include })
65+
# Add include groups
66+
if ($filter.include.ContainsKey("groups"))
67+
{
68+
foreach ($group in $filter.include.groups)
69+
{
70+
Write-Debug "Include $group"
71+
foreach ($include in $config.groupConfigs.$group)
72+
{
73+
$includedProjects += ($projectPaths | Where-Object { $_ -like $include })
74+
}
6175
}
6276
}
63-
}
64-
65-
# Add ad-hoc includes
66-
if ($filter.include.ContainsKey("patterns"))
67-
{
68-
foreach($include in $filter.include.patterns){
69-
Write-Debug "Include $include"
70-
$includedProjects += ($projectPaths | Where-Object { $_ -like $include })
77+
78+
# Add ad-hoc includes
79+
if ($filter.include.ContainsKey("patterns"))
80+
{
81+
foreach ($include in $filter.include.patterns)
82+
{
83+
Write-Debug "Include $include"
84+
$includedProjects += ($projectPaths | Where-Object { $_ -like $include })
85+
}
7186
}
72-
}
7387
}
7488

7589
# Process excludes, if present
7690
if ($filter.ContainsKey("exclude"))
7791
{
78-
# Remove exclude groups
79-
if ($filter.exclude.ContainsKey("groups"))
80-
{
81-
foreach($group in $filter.exclude.groups){
82-
Write-Debug "Exclude $group"
83-
foreach($exclude in $config.groupConfigs.$group){
84-
$includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
85-
}
92+
# Remove exclude groups
93+
if ($filter.exclude.ContainsKey("groups"))
94+
{
95+
foreach ($group in $filter.exclude.groups)
96+
{
97+
Write-Debug "Exclude $group"
98+
foreach ($exclude in $config.groupConfigs.$group)
99+
{
100+
$includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
101+
}
102+
}
86103
}
87-
}
88-
89-
# Remove ad-hoc excludes
90-
if ($filter.exclude.ContainsKey("patterns"))
91-
{
92-
foreach($exclude in $filter.exclude.patterns){
93-
Write-Debug "Exclude $exclude"
94-
$includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
104+
105+
# Remove ad-hoc excludes
106+
if ($filter.exclude.ContainsKey("patterns"))
107+
{
108+
foreach ($exclude in $filter.exclude.patterns)
109+
{
110+
Write-Debug "Exclude $exclude"
111+
$includedProjects = ($includedProjects | Where-Object { $_ -notlike $exclude })
112+
}
95113
}
96-
}
97114
}
98115

99116
# Remove duplicates and sort
100117
$includedProjects = $includedProjects | Select-Object -Unique | Sort-Object
101118
Write-Debug "Writing filter matching $($includedProjects.Count) projects"
102119

103120
# Start filter file
104-
$solution = if ($filter.ContainsKey('solution')) {
105-
$filter.solution
106-
} else {
107-
$config.defaultSolution
121+
$solution = if ($filter.ContainsKey('solution'))
122+
{
123+
$filter.solution
124+
}
125+
else
126+
{
127+
$config.defaultSolution
108128
}
109129
$content = "{
110130
`"solution`": {
@@ -113,11 +133,13 @@ foreach($filter in $config.filterConfigs){
113133

114134
# Add all the projects we want to include
115135
$firstProject = $true;
116-
foreach($project in $includedProjects) {
136+
foreach ($project in $includedProjects)
137+
{
117138
# Solution Filter files use escaped Windows style path separators
118-
$escapedProject = $project.Replace('/', '\\')
139+
$escapedProject = $project.Replace('/', '\\')
119140
$line = "$lf ""$escapedProject"""
120-
if (!$firstProject) {
141+
if (!$firstProject)
142+
{
121143
$line = "," + $line
122144
}
123145
$firstProject = $false;
@@ -132,10 +154,10 @@ foreach($filter in $config.filterConfigs){
132154
}
133155
'@
134156

135-
# Output filter file
136-
$outputPath = Join-Path $repoRoot $filter.outputPath
137-
$content | Set-Content $outputPath
138-
Write-Debug "Created $outputPath"
157+
# Output filter file
158+
$outputPath = Join-Path $repoRoot $filter.outputPath
159+
$content | Set-Content $outputPath
160+
Write-Debug "Created $outputPath"
139161
}
140162

141163
# Update solution files from Sentry.sln

test/Sentry.Tests/HubTests.verify.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ namespace Sentry.Tests;
55
[UsesVerify]
66
public partial class HubTests
77
{
8-
[SkippableFact]
8+
[Fact]
99
public async Task CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed()
1010
{
11-
// See https://github.com/getsentry/sentry-dotnet/issues/2785
12-
Skip.If(RuntimeInfo.GetRuntime().IsMono() && TestEnvironment.IsGitHubActions);
13-
1411
// Arrange
1512
var worker = new FakeBackgroundWorker();
1613

@@ -53,7 +50,8 @@ await Verify(worker.Envelopes)
5350
_.DebugFile.Contains("Xunit.SkippableFact") ||
5451
_.DebugFile.Contains("xunit.runner") ||
5552
_.DebugFile.Contains("JetBrains.ReSharper.TestRunner") ||
56-
_.DebugFile.Contains("Microsoft.TestPlatform")
53+
_.DebugFile.Contains("Microsoft.TestPlatform") ||
54+
_.DebugFile.Contains("Microsoft.VisualStudio.TestPlatform.Common.pdb")
5755
)
5856
);
5957
}

0 commit comments

Comments
 (0)