Skip to content

Commit

Permalink
chore: add testreport to test action
Browse files Browse the repository at this point in the history
  • Loading branch information
Phliipp Jenni committed Jan 12, 2024
1 parent 991c416 commit 2a62203
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/run-cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,16 @@ jobs:

- name: Test
run: dotnet run --project build/Build.csproj --target=test

- name: Summary
run: |
echo "# Bootstrap 3 Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat ch.jnetwork.sac-controls/reports/bs3.md >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Bootstrap 4 Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat ch.jnetwork.sac-controls/reports/bs4.md >> $GITHUB_STEP_SUMMARY
echo "# Bootstrap 5 Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat ch.jnetwork.sac-controls/reports/bs5.md >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<PackageReference Include="Cake.Frosting" Version="1.3.0" />
<PackageReference Include="Cake.Json" Version="6.0.1" />
<PackageReference Include="Cake.Npm" Version="1.0.0" />
<PackageReference Include="Cake.Npx" Version="1.0.0" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions build/pipelines/TestBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Build.pipelines
[TaskDescription("Default Task without publishing")]
[IsDependentOn(typeof(NpmBuild))]
[IsDependentOn(typeof(CypressRun))]
[IsDependentOn(typeof(CypressReport))]
public class TestBuild : FrostingTask<BuildContext>
{
/// <summary>
Expand Down
90 changes: 90 additions & 0 deletions build/tasks/CypressReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using Build.context;
using Build.extensions;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Frosting;
using Cake.Npx;

namespace Build.tasks
{
[TaskName("CypressReport")]
[TaskDescription("Run Cypress Tests")]
public class CypressReport : FrostingTask<BuildContext>
{
/// <summary>
/// Run Task
/// </summary>
/// <param name="context">Build Context</param>
public override void Run(BuildContext context)
{
base.Run(context);

context.Log.Information("Build markdown report file from testresult");

ReportBs3();
ReportBs4();
ReportBs5();

context.Log.Information("markdown created");

void ReportBs3()
{
context.Npx("mochawesome-merge", args => args.Append("./reports/bs3/*.json")
.AppendSwitch("-o", "./reports/bs3.json")
, settings =>
{
settings.WorkingDirectory = context.Environment.WorkingDirectory.Combine(context.ProjectDirectory.ToDirectoryPath());
});

context.Npx("mochawesome-json-to-md", args => args.AppendSwitch("-p", "./reports/bs3.json")
.AppendSwitch("-o", "./reports/bs3.md")
.AppendSwitch("-t", "./node_modules/mochawesome-json-to-md/sample-template.md")
, settings =>
{
settings.WorkingDirectory = context.Environment.WorkingDirectory.Combine(context.ProjectDirectory.ToDirectoryPath());
});
}

void ReportBs4()
{
context.Npx("mochawesome-merge", args => args.Append("./reports/bs4/*.json")
.AppendSwitch("-o", "./reports/bs4.json")
, settings =>
{
settings.WorkingDirectory = context.Environment.WorkingDirectory.Combine(context.ProjectDirectory.ToDirectoryPath());
});

context.Npx("mochawesome-json-to-md", args => args.AppendSwitch("-p", "./reports/bs4.json")
.AppendSwitch("-o", "./reports/bs4.md")
.AppendSwitch("-t", "./node_modules/mochawesome-json-to-md/sample-template.md")
, settings =>
{
settings.WorkingDirectory = context.Environment.WorkingDirectory.Combine(context.ProjectDirectory.ToDirectoryPath());
});
}

void ReportBs5()
{
context.Npx("mochawesome-merge", args => args.Append("./reports/bs5/*.json")
.AppendSwitch("-o", "./reports/bs5.json")
, settings =>
{
settings.WorkingDirectory = context.Environment.WorkingDirectory.Combine(context.ProjectDirectory.ToDirectoryPath());
});

context.Npx("mochawesome-json-to-md", args => args.AppendSwitch("-p", "./reports/bs5.json")
.AppendSwitch("-o", "./reports/bs5.md")
.AppendSwitch("-t", "./node_modules/mochawesome-json-to-md/sample-template.md")
, settings =>
{
settings.WorkingDirectory = context.Environment.WorkingDirectory.Combine(context.ProjectDirectory.ToDirectoryPath());
});
}
}

public override bool ShouldRun(BuildContext context)
{
return !context.Arguments.HasArgument("notest");
}
}
}
4 changes: 3 additions & 1 deletion ch.jnetwork.sac-controls/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ projects/sac-bootstrap4/cypress/videos/
projects/sac-bootstrap5/.angular/
projects/sac-bootstrap5/.nyc_output/
projects/sac-bootstrap5/cypress/screenshots/
projects/sac-bootstrap5/cypress/videos/
projects/sac-bootstrap5/cypress/videos/

reports/
5 changes: 4 additions & 1 deletion ch.jnetwork.sac-controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@
"codelyzer": "^6.0.0",
"cypress": "^12.5.1",
"eslint": "^8.51.0",
"mochawesome": "^7.1.3",
"mochawesome-json-to-md": "1.0.1",
"mochawesome-merge": "^4.3.0",
"ng-packagr": "^16.2.3",
"tslint": "~6.1.0",
"typescript": "~5.0.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import coverageWebpack from './cypress/coverage.webpack';
export default defineConfig({
viewportWidth: 1024,
viewportHeight: 768,
reporter: '../../../node_modules/mochawesome/src/mochawesome.js',
reporterOptions: {
reportDir: '../../reports/bs3',
overwrite: false,
html: false,
json: true,
},

component: {
devServer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import coverageWebpack from './cypress/coverage.webpack';
export default defineConfig({
viewportWidth: 1024,
viewportHeight: 768,
reporter: '../../../node_modules/mochawesome/src/mochawesome.js',
reporterOptions: {
reportDir: '../../reports/bs4',
overwrite: false,
html: false,
json: true,
},

component: {
devServer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import coverageWebpack from './cypress/coverage.webpack';
export default defineConfig({
viewportWidth: 1024,
viewportHeight: 768,
reporter: '../../../node_modules/mochawesome/src/mochawesome.js',
reporterOptions: {
reportDir: '../../reports/bs5',
overwrite: false,
html: false,
json: true,
},

component: {
devServer: {
Expand Down

0 comments on commit 2a62203

Please sign in to comment.