Repository navigation
180 lines (151 loc) · 6.27 KB
/
Copy pathpr_validation.yaml
File metadata and controls
180 lines (151 loc) · 6.27 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
name: pr_validation
on:
push:
branches:
- master
- dev
- main
pull_request:
branches:
- master
- dev
- main
permissions:
checks: write
pull-requests: write
issues: write
contents: read
jobs:
build-docker:
# Permissions this GitHub Action needs for other things in GitHub
name: Docker-${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: "Checkout"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: "./global.json"
- name: "Update release notes"
shell: pwsh
run: |
./build.ps1
- name: Set up Docker
uses: docker/setup-docker-action@77e84dbf09b47d1e29270283c22f16145aa85ca1 # v5
with:
daemon-config: |
{
"debug": true,
"features": {
"containerd-snapshotter": true
}
}
- name: "dotnet docker"
run: dotnet publish -c Release /t:PublishContainer
test:
# Permissions this GitHub Action needs for other things in GitHub
name: Test-${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: "Checkout"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: "./global.json"
- name: "dotnet tool restore"
run: dotnet tool restore
- name: "Update release notes"
shell: pwsh
run: |
./build.ps1
- name: Extract PlayWrightVersion using PowerShell
id: playwright_version
shell: pwsh
run: |
$xml = [xml](Get-Content './Directory.Packages.props')
$playwrightVersion = $xml.Project.PropertyGroup | Where-Object { $_.Label -eq 'SharedVersions' } | Select-Object -ExpandProperty PlayWrightVersion
echo "PlayWrightVersion=$playwrightVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
if: runner.os == 'Linux'
- name: Use PlayWrightVersion
run: |
echo "The Playwright version is: ${{ env.PlayWrightVersion }}"
if: runner.os == 'Linux'
- name: Extract TargetFramework using PowerShell
id: target_framework
shell: pwsh
run: |
$xml = [xml](Get-Content './Directory.Build.props')
# Cast to array: with a single PropertyGroup element, .PropertyGroup is an object, not a collection
$propertyGroups = @($xml.Project.PropertyGroup)
$tfm = $propertyGroups | Where-Object { $_.TargetFramework } | Select-Object -First 1 -ExpandProperty TargetFramework
if (-not $tfm) { throw "TargetFramework not found in Directory.Build.props" }
echo "TargetFramework=$tfm" | Out-File -FilePath $env:GITHUB_ENV -Append
if: runner.os == 'Linux'
# https://playwrightsolutions.com/playwright-github-action-to-cache-the-browser-binaries/
- name: Cache playwright binaries
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PlayWrightVersion }}
if: runner.os == 'Linux'
# Cache the pinned SQL Server image so cold runners don't pull ~1.6GB
# before every E2E run (same pattern as the Playwright binary cache).
# The tag MUST match the pinned tag in src/DrawTogether.AppHost/Program.cs
# (AddSqlServer.WithImageTag) - keep them in sync.
- name: Cache SQL Server image
id: mssql-cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ./ci-cache/mssql
key: ${{ runner.os }}-mssql-server-2022-CU26-ubuntu-22.04
if: runner.os == 'Linux'
- name: Pull and save SQL Server image (cache miss)
run: |
mkdir -p ./ci-cache/mssql
docker pull mcr.microsoft.com/mssql/server:2022-CU26-ubuntu-22.04
docker save mcr.microsoft.com/mssql/server:2022-CU26-ubuntu-22.04 -o ./ci-cache/mssql/image.tar
if: runner.os == 'Linux' && steps.mssql-cache.outputs.cache-hit != 'true'
- name: Load SQL Server image from cache (cache hit)
run: docker load -i ./ci-cache/mssql/image.tar
if: runner.os == 'Linux' && steps.mssql-cache.outputs.cache-hit == 'true'
- name: "dotnet build"
run: dotnet build -c Release
- name: "Ensure playwright browsers are installed"
working-directory: ./tests/DrawTogether.End2End.Tests
shell: pwsh
run: ./bin/Release/${{ env.TargetFramework }}/playwright.ps1 install --with-deps
if: runner.os == 'Linux' && steps.playwright-cache.outputs.cache-hit != 'true'
- name: "dotnet test"
run: dotnet test --configuration Release --verbosity normal --logger trx --collect:"XPlat Code Coverage"
if: runner.os == 'Linux'
- name: "dotnet test (unit tests only - Windows)"
run: dotnet incrementalist run -s DrawTogether.slnx --config .incrementalist/incrementalistWindows.json -- test --configuration Release --verbosity normal --logger trx --collect:"XPlat Code Coverage"
if: runner.os == 'Windows'
- name: Collect Playwright screenshots into one folder
run: |
mkdir -p flat-screenshots
# find every file under any TestScreenshots directory and copy it into flat-screenshots/
find . -type f -path '*/TestScreenshots/*' -exec cp {} flat-screenshots/ \;
if: runner.os == 'Linux'
- name: Upload flattened screenshots
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: playwright-screenshots-${{ matrix.os == 'windows-latest' && 'windows' || 'linux' }}-${{ github.run_id }}
path: flat-screenshots/
if: runner.os == 'Linux'