Repository navigation
245 lines (207 loc) · 12.3 KB
/
Copy pathci.yml
File metadata and controls
245 lines (207 loc) · 12.3 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: CI
on:
push:
branches: [ main, develop, "release/**" ]
pull_request:
branches: [ main, develop, "release/**" ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore ShellUI.slnx
# Regenerated every run: it's gitignored because Windows and Linux Tailwind builds differ byte for byte.
- name: Build precompiled CSS bundle
# Run through bash so the executable bit doesn't matter.
run: |
set -euxo pipefail
bash scripts/rebuild-precompiled-css.sh
BUNDLE=src/ShellUI.Components/wwwroot/shellui-all.css
test -f "$BUNDLE" || (echo "ERROR: bundle was not produced"; exit 1)
grep -Fq -- '--background' "$BUNDLE" || (echo "ERROR: theme vars not in bundle"; exit 1)
grep -Fq '.bg-background' "$BUNDLE" || (echo "ERROR: core utility rule missing"; exit 1)
grep -Fq 'hover\:bg-accent' "$BUNDLE" || (echo "ERROR: hover: modifier rules missing"; exit 1)
grep -Fq 'state=open' "$BUNDLE" || (echo "ERROR: data-[state=open] arbitrary value not compiled"; exit 1)
grep -Fq 'px-2\.5' "$BUNDLE" || (echo "ERROR: Badge padding class px-2.5 missing (variant .cs helpers not scanned?)"; exit 1)
grep -Fq 'border-transparent' "$BUNDLE" || (echo "ERROR: border-transparent missing (variant .cs helpers not scanned?)"; exit 1)
# Above the current bundle, below an accidental full Tailwind build.
size=$(wc -c < "$BUNDLE")
echo "precompiled bundle size: ${size} bytes"
if [ "$size" -gt 150000 ]; then
echo "ERROR: bundle exceeded 150KB — investigate before shipping."
exit 1
fi
- name: Build
run: dotnet build ShellUI.slnx --no-restore --configuration Release
- name: Run tests
run: dotnet test ShellUI.slnx --no-restore --no-build --configuration Release --verbosity normal
# Builds a scaffolded project; catches what TemplateCompileTests can't.
- name: Smoke-test CLI scaffolding
shell: bash
run: |
set -euxo pipefail
TMPDIR=$(mktemp -d)
dotnet pack src/ShellUI.CLI/ShellUI.CLI.csproj -c Release -o "$TMPDIR/nupkgs" --no-build
dotnet tool install --tool-path "$TMPDIR/tools" --add-source "$TMPDIR/nupkgs" ShellUI.CLI --prerelease
export PATH="$TMPDIR/tools:$PATH"
mkdir -p "$TMPDIR/app" && cd "$TMPDIR/app"
dotnet new blazor -o SmokeApp --no-restore
cd SmokeApp
shellui init --tailwind standalone --yes
grep -q 'HeadOutlet @rendermode="InteractiveServer"' Components/App.razor || (echo "init did not patch HeadOutlet @rendermode"; exit 1)
grep -q 'Routes @rendermode="InteractiveServer"' Components/App.razor || (echo "init did not patch Routes @rendermode"; exit 1)
grep -q 'ShellUI theme bootstrap' Components/App.razor || (echo "init did not inject theme bootstrap"; exit 1)
grep -q '<script src="shellui.js"></script>' Components/App.razor || (echo "init did not inject shellui.js script tag"; exit 1)
if grep -Fq 'shellui-sidebar.js' Components/App.razor; then
echo "init incorrectly injected a shellui-sidebar.js script tag (sidebar JS lives in the global shellui.js now)"
exit 1
fi
grep -q '@theme inline' wwwroot/input.css || (echo "init did not write full theme to input.css"; exit 1)
grep -q ':root' wwwroot/input.css || (echo "init did not write :root variables to input.css"; exit 1)
grep -q '\.dark' wwwroot/input.css || (echo "init did not write .dark variables to input.css"; exit 1)
shellui add chart pie-chart dashboard-02 data-table --force
grep -q 'Blazor-ApexCharts' SmokeApp.csproj || (echo "shellui add chart did not add Blazor-ApexCharts NuGet dep"; exit 1)
grep -q 'System.Linq.Dynamic.Core' SmokeApp.csproj || (echo "shellui add data-table did not add System.Linq.Dynamic.Core NuGet dep"; exit 1)
test -f Components/UI/Models/DataTableModels.cs || (echo "shellui add data-table did not install data-table-models"; exit 1)
# Without charts.css, chart tooltips render white on white.
test -f wwwroot/css/charts.css || (echo "shellui add chart did not install chart-styles CSS"; exit 1)
grep -q '<link href="css/charts.css"' Components/App.razor || (echo "shellui add chart did not link charts.css in App.razor"; exit 1)
# A dynamic import of shellui-sidebar.js 404s once compiled into a consumer's RCL.
grep -q 'ShellUI.initSidebar' Components/UI/SidebarProvider.razor || (echo "SidebarProvider did not call ShellUI.initSidebar"; exit 1)
if grep -Fq 'shellui-sidebar.js' Components/UI/SidebarProvider.razor; then
echo "SidebarProvider still dynamically imports shellui-sidebar.js"
exit 1
fi
test -f wwwroot/shellui.js || (echo "shellui.js was not installed"; exit 1)
grep -Fq 'initSidebar: function (handle, dotNetRef)' wwwroot/shellui.js || (echo "shellui.js does not expose initSidebar"; exit 1)
grep -Fq 'disposeSidebar: function (handle)' wwwroot/shellui.js || (echo "shellui.js does not expose disposeSidebar"; exit 1)
test ! -e wwwroot/shellui-sidebar.js || (echo "legacy sidebar JS was installed for a fresh sidebar install"; exit 1)
dotnet build -c Debug
cd "$TMPDIR/app"
dotnet new blazor -o DashApp --no-restore
cd DashApp
shellui init --tailwind standalone --yes --dashboard 02
grep -q 'typeof(Layout.DashboardLayout02)' Components/Routes.razor || (echo "init --dashboard 02 did not switch Routes.razor"; exit 1)
test ! -e Components/Layout/MainLayout.razor || (echo "stock MainLayout.razor was not removed"; exit 1)
test ! -e Components/Layout/NavMenu.razor || (echo "stock NavMenu.razor was not removed"; exit 1)
grep -q 'id="blazor-error-ui"' Components/App.razor || (echo "the error bar was not added to App.razor"; exit 1)
grep -q '"/counter"' Components/UI/AppSidebar.razor || (echo "AppSidebar links were not built from the pages"; exit 1)
dotnet build -c Debug
cd "$TMPDIR/app"
dotnet new blazor -o IdentityApp --auth Individual --no-restore
cd IdentityApp
shellui init --tailwind standalone --yes --dashboard 02
grep -q '<SidebarAccount />' Components/UI/AppSidebar.razor || (echo "the sidebar footer has no account menu"; exit 1)
grep -q 'StartsWithSegments("/Account")' Components/App.razor || (echo "Identity pages are not kept static"; exit 1)
shellui add auth-01
grep -q '@layout IdentityApp.Components.Layout.AuthLayout01' Components/Account/Pages/_Imports.razor || (echo "auth-01 was not set as the sign-in layout"; exit 1)
! grep -q 'class="form-control"' Components/Account/Pages/Login.razor || (echo "Login.razor was not restyled"; exit 1)
dotnet build -c Debug
# Catches missing dependencies that per-template tests can't see.
ALL=$(python3 - "$GITHUB_WORKSPACE" <<'PY'
import os, re, sys
root = sys.argv[1]
reg = open(os.path.join(root, "src/ShellUI.Templates/ComponentRegistry.cs")).read().split("GetComponentContent")[0]
names = [n for n, c in re.findall(r'\{ "([a-z0-9-]+)", (\w+)\.Metadata \}', reg)
if not re.search(r"IsAvailable\s*=\s*false", open(os.path.join(root, f"src/ShellUI.Templates/Templates/{c}.cs")).read())]
print(" ".join(names))
PY
)
# The CLI's source must build in .NET 8 and 9 projects too, and hyphenated names test the namespace sanitizing.
for fw in net10.0 net9.0 net8.0; do
cd "$TMPDIR/app"
dotnet new blazor -o "AllApp-$fw" -f "$fw" --no-restore
cd "AllApp-$fw"
shellui init --tailwind standalone --yes
shellui add $ALL
dotnet build -c Debug
done
# Package-only install from a local-only feed, so nuget.org can't mask a broken package.
- name: NuGet-only install — verify safelist ships
shell: bash
run: |
set -euxo pipefail
LOCAL_FEED="$GITHUB_WORKSPACE/src/ShellUI.Components/bin/Release"
test -d "$LOCAL_FEED" || (echo "local feed not found at $LOCAL_FEED — did the pack step run?"; exit 1)
ls "$LOCAL_FEED"/*.nupkg | head -3
echo "---nupkg contents (looking for shellui-all.css):---"
unzip -l "$LOCAL_FEED"/ShellUI.Components*.nupkg | grep -E 'shellui-all|staticwebassets/' | head -10 || echo " (no matches — bundle not in nupkg!)"
echo "---source wwwroot check:---"
ls -la "$GITHUB_WORKSPACE/src/ShellUI.Components/wwwroot/" | head -10
TMPDIR=$(mktemp -d)
mkdir -p "$TMPDIR/app" && cd "$TMPDIR/app"
dotnet new blazor -o NuGetSmoke --no-restore
cd NuGetSmoke
cat > NuGet.config <<EOF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="local" value="$LOCAL_FEED" />
</packageSources>
</configuration>
EOF
# A cached copy of the same version would shadow the fresh nupkg.
rm -rf ~/.nuget/packages/shellui.components
dotnet add package ShellUI.Components --prerelease
# The package's .targets copies the safelist during build, so restore alone isn't enough.
dotnet build -c Debug
SAFELIST="wwwroot/shellui-classes.txt"
test -f "$SAFELIST" || (
echo "ERROR: $SAFELIST not in consumer project after dotnet build."
echo "The package's build/ShellUI.Components.targets should have copied it."
echo "Files in wwwroot/:"; ls -la wwwroot/ 2>/dev/null || echo " (no wwwroot/ directory)"
exit 1
)
grep -q 'bg-background' "$SAFELIST" || (echo "safelist appears malformed — missing core Tailwind class 'bg-background'"; exit 1)
wc -l "$SAFELIST"
# .NET 10 serves package assets from the NuGet cache, not bin/, so check the extracted package.
BUNDLE="$(find ~/.nuget/packages/shellui.components -name 'shellui-all.css' -type f | head -1)"
if [ -z "$BUNDLE" ]; then
echo "ERROR: shellui-all.css not in consumer's extracted NuGet cache — the pure-NuGet install path is broken."
echo "---consumer's extracted NuGet cache tree:---"
find ~/.nuget/packages/shellui.components -type f 2>/dev/null | head -30
exit 1
fi
echo "found bundle at: $BUNDLE"
BUNDLE_SIZE=$(wc -c < "$BUNDLE")
echo "bundle size: $BUNDLE_SIZE bytes"
grep -Fq -- '--background' "$BUNDLE" || (echo "ERROR: bundle missing --background theme var"; exit 1)
grep -Fq '.bg-background' "$BUNDLE" || (echo "ERROR: bundle missing .bg-background utility"; exit 1)
grep -Fq 'hover\:bg-accent' "$BUNDLE" || (echo "ERROR: bundle missing hover:bg-accent modifier rule"; exit 1)
grep -Fq 'state=open' "$BUNDLE" || (echo "ERROR: bundle missing data-[state=open] arbitrary-value modifier"; exit 1)
grep -Fq 'px-2\.5' "$BUNDLE" || (echo "ERROR: bundle missing Badge padding — .cs variant scan regression?"; exit 1)
# The package also ships net8.0 and net9.0 builds.
for fw in net8.0 net9.0; do
cd "$TMPDIR/app"
dotnet new blazor -o "NuGetSmoke-$fw" -f "$fw" --no-restore
cd "NuGetSmoke-$fw"
cp ../NuGetSmoke/NuGet.config .
dotnet add package ShellUI.Components --prerelease
echo '@using ShellUI.Components' >> Components/_Imports.razor
echo '@page "/shellui"' > Components/Pages/ShellUISmoke.razor
echo '<Button>Save</Button> <Card><CardContent>ok</CardContent></Card>' >> Components/Pages/ShellUISmoke.razor
dotnet build -c Debug
test -f wwwroot/shellui-classes.txt
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
**/*.nupkg
**/*.snupkg