forked from fluentmigrator/fluentmigrator
-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (208 loc) · 8.76 KB
/
pull-requests.yaml
File metadata and controls
225 lines (208 loc) · 8.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Pull Requests
on:
pull_request_target:
branches:
- '*'
push:
branches:
- 'main'
env:
solution: 'FluentMigrator.sln'
buildPlatform: 'Any CPU'
buildConfiguration: Release
jobs:
build:
name: Build & Test
runs-on: ${{ matrix.os }}
permissions:
checks: write
issues: write
pull-requests: write
strategy:
matrix:
include:
- os: windows-latest
dotnet-tfm: net48
- os: ubuntu-latest
dotnet-tfm: net8.0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: 6.3.x
- name: Execute GitVersion
uses: gittools/actions/gitversion/execute@v4.1.0
env:
BUILD_BUILDNUMBER: ${{ env.GitVersion.NuGetVersionV2 }}
with:
updateAssemblyInfo: false
- name: Setup dotnet SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Setup dotnet SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Setup .NET Framework 4.8 Developer Pack (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
# Check registry for .NET Framework 4.8 (Release >= 528040 indicates 4.8)
try { $reg = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -ErrorAction Stop; $release = $reg.Release } catch { $release = 0 }
if ($release -ge 528040) {
Write-Host ".NET Framework 4.8 or higher already installed (Release=$release). Skipping install."
exit 0
}
Write-Host "No .NET Framework 4.8 Developer Pack found (Release=$release). Installing..."
# Ensure TLS 1.2 for secure downloads
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Resolve the current Microsoft download link by scraping the official docs page
$downloadPage = 'https://learn.microsoft.com/en-us/dotnet/framework/install/dotnet-48'
Write-Host "Resolving installer URL from: $downloadPage"
try {
$page = (Invoke-WebRequest -Uri $downloadPage -ErrorAction Stop).Content
if ($page -match 'https://download\.visualstudio\.microsoft\.com/[^\s"''<>]+ndp48-devpack-enu\.exe') { $link = $Matches[0] }
} catch {
$link = $null
}
if (-not $link) {
throw "Failed to resolve download URL for ndp48-devpack-enu.exe from Microsoft documentation. Please update the workflow with a valid installer URL."
}
Write-Host "Resolved download URL: $link"
$installerPath = Join-Path $env:TEMP 'ndp48-devpack-enu.exe'
# Download with retries; prefer BITS when available
$maxAttempts = 5
for ($i = 1; $i -le $maxAttempts; $i++) {
try {
if (Get-Command Start-BitsTransfer -ErrorAction SilentlyContinue) {
Start-BitsTransfer -Source $link -Destination $installerPath -ErrorAction Stop
} else {
Invoke-WebRequest -Uri $link -OutFile $installerPath -UseBasicParsing -ErrorAction Stop
}
break
} catch {
Write-Warning "Download attempt $i failed: $($_.Exception.Message)"
if ($i -eq $maxAttempts) { throw "Failed to download .NET Framework 4.8 Developer Pack after $maxAttempts attempts." }
Start-Sleep -Seconds (15 * $i)
}
}
Write-Host "Running installer: $installerPath"
Start-Process -FilePath $installerPath -ArgumentList '/quiet','/norestart' -Wait -ErrorAction Stop
# Verify installation
try { $reg = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -ErrorAction Stop; $newRelease = $reg.Release } catch { $newRelease = 0 }
if ($newRelease -ge 528040) {
Write-Host ".NET Framework 4.8 Developer Pack installed (Release=$newRelease)."
} else {
throw ".NET Framework 4.8 installation completed but registry Release value is $newRelease."
}
# Cleanup
if (Test-Path $installerPath) { Remove-Item $installerPath -Force -ErrorAction SilentlyContinue }
- name: Restore, Build, Test
run: dotnet test --framework ${{ matrix.dotnet-tfm }} --configuration ${{ env.buildConfiguration }} --verbosity quiet --logger trx --collect:"XPlat Code Coverage" --results-directory "TestResults-${{ matrix.dotnet-tfm }}"
env:
# Enable containers for integration tests only on Linux
FM_TestConnectionStrings__MySql__ContainerEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__MySql__IsEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__Oracle__ContainerEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__Oracle__IsEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__Postgres__ContainerEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__Postgres__IsEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__SqlServer2016__ContainerEnabled: ${{ matrix.os == 'ubuntu-latest' }}
FM_TestConnectionStrings__SqlServer2016__IsEnabled: ${{ matrix.os == 'ubuntu-latest' }}
- name: Combine Coverage Reports
uses: danielpalme/ReportGenerator-GitHub-Action@v5.5.0
if: '!cancelled()'
with:
reports: "**/*.cobertura.xml"
targetdir: "${{ github.workspace }}"
reporttypes: "Cobertura"
verbosity: "Info"
title: "Code Coverage"
tag: "${{ github.run_number }}_${{ github.run_id }}"
toolpath: "reportgeneratortool"
- name: Upload Combined Coverage XML
uses: actions/upload-artifact@v4
if: '!cancelled()'
with:
name: coverage-${{ matrix.os }}-${{ matrix.dotnet-tfm }}
path: ${{ github.workspace }}/Cobertura.xml
retention-days: 5
- name: Publish Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
if: matrix.os == 'ubuntu-latest' && (!cancelled())
with:
filename: "Cobertura.xml"
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: "10 30"
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Upload Test Result Files
uses: actions/upload-artifact@v4
if: '!cancelled()'
with:
name: test-results-${{ matrix.os }}-${{ matrix.dotnet-tfm }}
path: ${{ github.workspace }}/**/TestResults-${{ matrix.dotnet-tfm }}/**/*
retention-days: 5
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
# GitHub Actions initially only supported containerized actions, which is not supported on Windows
# and this particular GitHub action from EnricoMi is a containerized action
if: matrix.os == 'ubuntu-latest' && (!cancelled())
with:
files: "${{ github.workspace }}/**/*.trx"
- name: Diagnostics (Linux)
if: matrix.os == 'ubuntu-latest' && failure()
run: |
echo "=== dotnet --info ==="
dotnet --info || true
echo "=== Repo root listing ==="
ls -la || true
echo "=== Check test project obj folder ==="
TEST_OBJ="test/FluentMigrator.Analyzers.Tests/obj"
if [ -d "$TEST_OBJ" ]; then
echo "Found $TEST_OBJ, listing contents (first 1000 chars of each file):"
find "$TEST_OBJ" -type f -maxdepth 3 -print -exec sh -c 'echo "---- {} ----"; head -c 1000 "{}" || true; echo' \;
else
echo "$TEST_OBJ does not exist"
fi
- name: Diagnostics (Windows)
if: matrix.os == 'windows-latest' && failure()
shell: pwsh
run: |
Write-Host "=== dotnet --info ==="
dotnet --info
Write-Host "=== Repo root listing ==="
Get-ChildItem -Force
$testObj = "test\FluentMigrator.Analyzers.Tests\obj"
Write-Host "=== Check test project obj folder ($testObj) ==="
if (Test-Path $testObj) {
Get-ChildItem -Path $testObj -Recurse -File | ForEach-Object {
$file = $_.FullName
Write-Host "---- $file ----"
try {
# Output the first 1000 lines
Get-Content -Path $file -TotalCount 1000
}
catch {
Write-Warning "Unable to read '$file': $($_.Exception.Message)"
}
Write-Host ""
}
} else {
Write-Host "$testObj does not exist"
}