Skip to content

Commit 75b5a8d

Browse files
authored
Merge pull request #478 from ChaosEngine/dev
Dev -> Master
2 parents ff526a2 + fe2af16 commit 75b5a8d

File tree

82 files changed

+1973
-544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1973
-544
lines changed

.circleci/config.yml

Lines changed: 13 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,10 @@
11
version: 2.1
22

33
jobs:
4-
all-tests:
5-
docker:
6-
- image: mcr.microsoft.com/playwright:latest
7-
# Steps to the job
8-
steps:
9-
- checkout
10-
- run:
11-
name: Update submodules
12-
command: |
13-
git submodule sync
14-
git submodule update --init --recursive --jobs 8
15-
- run:
16-
name: Install framework
17-
command: |
18-
apt update; apt install software-properties-common -y
19-
add-apt-repository ppa:dotnet/backports -y
20-
apt update && apt install -y dotnet-sdk-9.0
21-
corepack enable; corepack install -g pnpm
22-
- run:
23-
name: Show versions
24-
command: |
25-
dotnet --info
26-
node --version
27-
pnpm --version
28-
- run:
29-
name: Install project dependencies
30-
command: |
31-
dotnet restore
32-
cd DotnetPlayground.Web
33-
pnpm i
34-
npx playwright install --only-shell chromium
35-
cd ..
36-
- run:
37-
name: Run Unit and Integration Tests
38-
command: |
39-
export DBKind="sqlite" ConnectionStrings__Sqlite="Filename=./bin/Debug/Blogging.db"
40-
dotnet test -v n --results-directory:"./test_coverage" --collect:"Code Coverage" --logger "trx"
41-
- run:
42-
name: End-2-End Playwright browser tests
43-
command: |
44-
cd DotnetPlayground.Web
45-
export DBKind="sqlite" ConnectionStrings__Sqlite="Filename=./bin/Debug/Blogging.db"
46-
npx playwright test
47-
- store_artifacts:
48-
path: ./test_coverage
49-
- store_artifacts:
50-
path: DotnetPlayground.Web/e2e/playwright-report
51-
- run:
52-
name: test results
53-
when: always
54-
command: |
55-
dotnet tool install -g trx2junit
56-
export PATH="$PATH:$HOME/.dotnet/tools"
57-
trx2junit ./test_coverage/*.trx
58-
- store_test_results:
59-
path: ./test_coverage/
60-
61-
624
Pomelo-tests:
635
docker:
646
- image: mcr.microsoft.com/dotnet/sdk:9.0
65-
# Steps to the job
7+
# Steps for the job
668
steps:
679
- checkout
6810
- run:
@@ -102,7 +44,7 @@ jobs:
10244
InkBall-tests:
10345
docker:
10446
- image: mcr.microsoft.com/dotnet/sdk:9.0
105-
# Steps to the job
47+
# Steps for the job
10648
steps:
10749
- checkout
10850
- run:
@@ -142,7 +84,7 @@ jobs:
14284
DotnetPlayground-tests:
14385
docker:
14486
- image: mcr.microsoft.com/dotnet/sdk:9.0
145-
# Steps to the job
87+
# Steps for the job
14688
steps:
14789
- checkout
14890
- run:
@@ -182,7 +124,7 @@ jobs:
182124
Playwright-tests:
183125
docker:
184126
- image: mcr.microsoft.com/playwright:latest
185-
# Steps to the job
127+
# Steps for the job
186128
steps:
187129
- checkout
188130
- run:
@@ -195,8 +137,8 @@ jobs:
195137
command: |
196138
apt update; apt install software-properties-common -y
197139
add-apt-repository ppa:dotnet/backports -y
198-
apt update && apt install -y dotnet-sdk-9.0
199-
corepack enable; corepack install -g pnpm
140+
apt install -y dotnet-sdk-9.0
141+
npm i -g pnpm@latest
200142
- run:
201143
name: Show versions
202144
command: |
@@ -207,24 +149,22 @@ jobs:
207149
name: Install project dependencies
208150
command: |
209151
dotnet restore
210-
cd DotnetPlayground.Web
152+
dotnet dev-certs https --trust
211153
pnpm i
212154
npx playwright install --only-shell chromium
213-
cd ..
214155
- run:
215156
name: End-2-End Playwright browser tests
216157
command: |
217-
cd DotnetPlayground.Web
218158
export DBKind="sqlite" ConnectionStrings__Sqlite="Filename=./bin/Debug/Blogging.db"
219159
npx playwright test
220160
- store_artifacts:
221-
path: DotnetPlayground.Web/e2e/playwright-report
161+
path: e2e/playwright-report
222162

223163

224164
build:
225165
docker:
226166
- image: mcr.microsoft.com/dotnet/sdk:9.0
227-
# Steps to the job
167+
# Steps for the job
228168
steps:
229169
- checkout
230170
- run:
@@ -240,24 +180,19 @@ jobs:
240180
chmod 500 nsolid_setup_deb.sh
241181
./nsolid_setup_deb.sh 21
242182
apt-get install -y nodejs
243-
corepack enable; corepack install -g pnpm
183+
npm i -g pnpm@latest
244184
- run:
245185
name: "Build Application according to some given configuration"
246-
command: dotnet publish -c Release --self-contained -r linux-x64 DotnetPlayground.Web
186+
command: |
187+
pnpm install --prod --unsafe-perm
188+
dotnet publish -c Release --self-contained -r linux-x64 DotnetPlayground.Web
247189
248190
249191
# Invoke jobs via workflows
250192
workflows:
251193
version: 2
252194
test_and_build:
253195
jobs:
254-
# - all-tests:
255-
# filters:
256-
# branches:
257-
# only:
258-
# - master
259-
# - dev
260-
# - circleci-project-setup
261196
- Pomelo-tests:
262197
filters:
263198
branches:
@@ -294,7 +229,6 @@ workflows:
294229
- dev
295230
- circleci-project-setup
296231
requires:
297-
# - all-tests
298232
- Pomelo-tests
299233
- InkBall-tests
300234
- DotnetPlayground-tests

.gitignore

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ log/
4141
TestResult.xml
4242

4343
# Playwright test results and reports
44-
DotnetPlayground.Web/e2e/test-results/
45-
DotnetPlayground.Web/e2e/playwright-report/
46-
DotnetPlayground.Web/e2e/storageStates/
47-
DotnetPlayground.Web/playwright/.cache/
44+
e2e/test-results/
45+
e2e/playwright-report/
46+
e2e/storageStates/
47+
playwright/.cache/
4848

4949
# Build Results of an ATL Project
5050
[Dd]ebugPS/
@@ -211,9 +211,9 @@ FakesAssemblies/
211211
*.opt
212212

213213
DotnetPlayground.Web/**/wwwroot/lib/
214-
DotnetPlayground.Web/wwwroot/**/*.min.css
215-
DotnetPlayground.Web/wwwroot/**/*.min.js
216-
DotnetPlayground.Web/wwwroot/**/*.map
214+
# DotnetPlayground.Web/wwwroot/**/*.min.css
215+
# DotnetPlayground.Web/wwwroot/**/*.min.js
216+
# DotnetPlayground.Web/wwwroot/**/*.map
217217
docker-*.env
218-
DotnetPlayground.Web/package-lock.json
219-
DotnetPlayground.Web/pnpm-lock.yaml
218+
package-lock.json
219+
pnpm-lock.yaml

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"eslint.enable": true,
3-
"eslint.nodePath": "DotnetPlayground.Web/node_modules",
4-
"eslint.options": { "overrideConfigFile": "DotnetPlayground.Web/package.json" },
53
"eslint.validate": [ "javascript" ],
4+
"eslint.useFlatConfig": true,
65
"dotnet.defaultSolution": "Dotnet-Playground.sln"
76
}

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax = docker/dockerfile:experimental
22
FROM mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build
3-
RUN --mount=type=cache,target=/root/.nuget --mount=type=cache,target=/root/.local/ --mount=type=cache,target=/root/.cache/ --mount=type=cache,target=./DotnetPlayground.Web/node_modules
3+
RUN --mount=type=cache,target=/root/.nuget --mount=type=cache,target=/root/.local/ --mount=type=cache,target=/root/.cache/ --mount=type=cache,target=./node_modules
44
RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh && \
55
chmod 500 nsolid_setup_deb.sh && \
66
./nsolid_setup_deb.sh 21 && \
@@ -27,9 +27,8 @@ RUN dotnet restore -r linux-x64 /p:Configuration=Release
2727
COPY . .
2828
RUN sed -i -e "s/GIT_HASH/$SOURCE_COMMIT/g" -e "s/GIT_BRANCH/$SOURCE_BRANCH/g" DotnetPlayground.Web/wwwroot/js/site.js
2929
RUN dotnet test -v m
30-
RUN dotnet publish -c $BUILD_CONFIG --self-contained -r linux-x64 \
31-
#-p:PublishTrimmed=true \
32-
DotnetPlayground.Web
30+
RUN pnpm install --prod --unsafe-perm
31+
RUN dotnet publish -c $BUILD_CONFIG --self-contained -r linux-x64 DotnetPlayground.Web
3332

3433

3534

Dockerfile.alpine

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax = docker/dockerfile:experimental
22
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
3-
RUN --mount=type=cache,target=/root/.nuget --mount=type=cache,target=/root/.local/ --mount=type=cache,target=/root/.cache/ --mount=type=cache,target=./DotnetPlayground.Web/node_modules
4-
RUN apk add --update nodejs npm && npm install -g pnpm
3+
RUN --mount=type=cache,target=/root/.nuget --mount=type=cache,target=/root/.local/ --mount=type=cache,target=/root/.cache/ --mount=type=cache,target=./node_modules
4+
RUN apk add --update nodejs pnpm
55
WORKDIR /build
66

77
ENV DBKind="sqlite" ConnectionStrings__Sqlite="Filename=./bin/Debug/net9.0/Blogging.db"
@@ -24,9 +24,8 @@ RUN dotnet restore -r linux-musl-x64 /p:Configuration=Release
2424
COPY . .
2525
RUN sed -i -e "s/GIT_HASH/$SOURCE_COMMIT/g" -e "s/GIT_BRANCH/$SOURCE_BRANCH/g" DotnetPlayground.Web/wwwroot/js/site.js
2626
RUN dotnet test -v m
27-
RUN dotnet publish -c $BUILD_CONFIG --self-contained -r linux-musl-x64 \
28-
#-p:PublishTrimmed=true \
29-
DotnetPlayground.Web
27+
RUN pnpm install --prod --unsafe-perm
28+
RUN dotnet publish -c $BUILD_CONFIG --self-contained -r linux-musl-x64 DotnetPlayground.Web
3029

3130

3231

Dotnet-Playground.sln

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
docker-compose.yml = docker-compose.yml
1111
Dockerfile = Dockerfile
1212
Dockerfile.alpine = Dockerfile.alpine
13-
Dotnet-Playground build.sh = Dotnet-Playground build.sh
13+
build.sh = build.sh
14+
eslint.config.mjs = eslint.config.mjs
1415
global.json = global.json
16+
gulpfile.mjs = gulpfile.mjs
1517
haproxy\haproxy.cfg = haproxy\haproxy.cfg
1618
NuGet.config = NuGet.config
19+
package.json = package.json
1720
runContainer.sh = runContainer.sh
1821
startApp.sh = startApp.sh
1922
EndProjectSection

DotnetPlayground.Tests/DotnetPlayground.Tests.csproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
15-
<PackageReference Include="xunit" Version="2.9.2" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
13+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.3" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
15+
<PackageReference Include="xunit" Version="2.9.3" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>
2020
<PackageReference Include="Moq" Version="4.20.72" />
21-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
22-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
23-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
21+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
22+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
23+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.3">
2424
<PrivateAssets>all</PrivateAssets>
2525
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2626
</PackageReference>
27-
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0" />
27+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.3" />
2828
</ItemGroup>
2929

3030
<ItemGroup>

DotnetPlayground.Tests/IntegrationTest.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ await _client.GetAsync($"{_client.BaseAddress}{VirtualScrollController.ASPX}/{na
432432
}
433433

434434
[Collection(nameof(TestServerCollection))]
435-
public class BlogsPage
435+
public partial class BlogsPage
436436
{
437437
private readonly TestServerFixture<Startup> _fixture;
438438
private readonly HttpClient _client;
@@ -524,7 +524,7 @@ public async Task Blog_CRUD_Test()
524524
using (var index_response = await _client.GetAsync($"{_client.BaseAddress}{BlogsController.ASPX}/", HttpCompletionOption.ResponseContentRead))
525525
{
526526
var responseString = await index_response.Content.ReadAsStringAsync();
527-
MatchCollection matches = Regex.Matches(responseString, @"\<form method=""post"" class=""blogForm row g-3"" data-id=""([0-9].*)""\>");
527+
MatchCollection matches = MyRegex().Matches(responseString);
528528
Assert.NotEmpty(matches);
529529
var ids = new List<int>(matches.Count);
530530
foreach (Match m in matches)
@@ -636,7 +636,7 @@ public async Task Posts_CRUD_Test(bool delete_posts_before_blog_cascade_delete_t
636636
using (var index_response = await _client.GetAsync($"{_client.BaseAddress}{BlogsController.ASPX}/", HttpCompletionOption.ResponseContentRead))
637637
{
638638
var responseString = await index_response.Content.ReadAsStringAsync();
639-
MatchCollection matches = Regex.Matches(responseString, @"\<form method=""post"" class=""blogForm row g-3"" data-id=""([0-9].*)""\>");
639+
MatchCollection matches = MyRegex().Matches(responseString);
640640
Assert.NotEmpty(matches);
641641
var ids = new List<int>(matches.Count);
642642
foreach (Match m in matches)
@@ -836,10 +836,13 @@ public async Task Posts_CRUD_Test(bool delete_posts_before_blog_cascade_delete_t
836836
}
837837
}//end using (var create_get_response
838838
}
839-
}
839+
840+
[GeneratedRegex(@"\<form method=""post"" class=""blogForm row g-3"" data-id=""([0-9].*)""\>")]
841+
private static partial Regex MyRegex();
842+
}
840843

841844
[Collection(nameof(TestServerCollection))]
842-
public class WebCamGalleryPage
845+
public partial class WebCamGalleryPage
843846
{
844847
private readonly TestServerFixture<Startup> _fixture;
845848
private readonly HttpClient _client;
@@ -881,7 +884,7 @@ public async Task Show_Index()
881884
</picture>
882885
</a>*/
883886

884-
MatchCollection matches = Regex.Matches(responseString, @"\<a href=""(.*thumbnail-.*\.jpg)"" title=""(.*)"">");
887+
MatchCollection matches = MyRegex().Matches(responseString);
885888
Assert.NotEmpty(matches);
886889
var images = new List<string>(matches.Count);
887890
foreach (Match m in matches.Take(7))
@@ -1008,7 +1011,10 @@ public async Task GetLiveImage()
10081011

10091012
}//end using
10101013
}
1011-
}
1014+
1015+
[GeneratedRegex(@"\<a href=""(.*thumbnail-.*\.jpg)"" title=""(.*)"">")]
1016+
private static partial Regex MyRegex();
1017+
}
10121018

10131019
[Collection(nameof(TestServerCollection))]
10141020
public class IdentityManager2
@@ -1280,6 +1286,8 @@ public StaticAssetContent(TestServerFixture<Startup> fixture)
12801286
[InlineData("lib/signalr-protocol-msgpack/browser/signalr-protocol-msgpack.min.js.map")]
12811287
[InlineData("lib/video.js/alt/video.core.novtt.min.js")]
12821288
[InlineData("lib/video.js/video-js.min.css")]
1289+
[InlineData("locales/en/translation.min.json")]
1290+
[InlineData("locales/pl/translation.min.json")]
12831291
public async Task GetStaticAssetContent(string url)
12841292
{
12851293
//if (!Directory.Exists("wwwroot/lib/jquery")) return;
@@ -1310,6 +1318,13 @@ public async Task GetStaticAssetContent(string url)
13101318
Assert.Equal("text/javascript", response.Content.Headers.ContentType.MediaType);
13111319
break;
13121320

1321+
case ".json":
1322+
Assert.IsType<StreamContent>(response.Content);
1323+
Assert.True(response.Content.Headers.TryGetValues("Content-Type", out c_type));
1324+
Assert.NotNull(c_type);
1325+
Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType);
1326+
break;
1327+
13131328
case ".gif":
13141329
case ".png":
13151330
case ".svg":

DotnetPlayground.Tests/TestServerFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
206206
//string temp = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER");
207207
//DOTNET_RUNNING_IN_CONTAINER = !string.IsNullOrEmpty(temp) && temp.Equals(true.ToString(), StringComparison.InvariantCultureIgnoreCase);
208208

209+
InkBall.Module.ContextSnapshotHelper.DBKind = DBKind;
209210
var db = scopedServices.GetRequiredService<DotnetPlayground.Models.BloggingContext>();
210211
if (DBKind.Equals("sqlite", StringComparison.InvariantCultureIgnoreCase))
211212
db.Database.Migrate();

0 commit comments

Comments
 (0)