Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add npm to CI build #1049

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.Npm;
using Rocket.Surgery.Nuke.DotNetCore;

namespace Build;
Expand Down Expand Up @@ -61,11 +63,25 @@

public Target Test => _ => _.Inherit<ICanTestWithDotNetCore>(x => x.CoreTest);

public Target NpmInstall => _ => _

Check warning on line 66 in .build/Build.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Member 'NpmInstall' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 66 in .build/Build.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Member 'NpmInstall' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 66 in .build/Build.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Member 'NpmInstall' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)
.Executes(() =>
NpmTasks.NpmCi(s => s
.SetProcessWorkingDirectory(VscodeTestExtensionProjectDirectory)));

public Target TestVscodeExtension => _ => _
.DependsOn(NpmInstall)
.Executes(() =>
NpmTasks.NpmRun(s => s
.SetProcessWorkingDirectory(VscodeTestExtensionProjectDirectory)
.SetCommand("test")));

public Target BuildVersion => _ => _.Inherit<IHaveBuildVersion>(x => x.BuildVersion)
.Before(Default)
.Before(Clean);

[Parameter("Configuration to build")] public Configuration Configuration { get; } = IsLocalBuild ? Configuration.Debug : Configuration.Release;

AbsolutePath ICanUpdateReadme.ReadmeFilePath => RootDirectory / "README.md";

private const string VscodeTestExtensionProjectDirectory = "vscode-testextension";
}
22 changes: 22 additions & 0 deletions .build/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,32 @@
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
.UseDotNetSdks("3.1", "7.0")
.AddNuGetCache()
.AddVscodeExtensionTests()
.PublishLogs<Solution>()
.PublishArtifacts<Solution>()
.FailFast = false;

return configuration;
}
}

public static class Extensions

Check warning on line 114 in .build/Solution.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type name Extensions conflicts in whole or in part with the namespace name 'Azure.Core.Extensions'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

Check warning on line 114 in .build/Solution.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type name Extensions conflicts in whole or in part with the namespace name 'Azure.Core.Extensions'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)

Check warning on line 114 in .build/Solution.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The type name Extensions conflicts in whole or in part with the namespace name 'Azure.Core.Extensions'. Change either name to eliminate the conflict. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1724)
{
public static RocketSurgeonsGithubActionsJob AddVscodeExtensionTests(this RocketSurgeonsGithubActionsJob job)
{
return job
.AddStep(new RunStep("Npm install") {
Run = string.Join(Environment.NewLine, [
"cd vscode-testextension",
"npm ci",
"cd .."
])
})
.AddStep(new UsingStep("Vscode extension tests") {
Uses = "coactions/setup-xvfb@v1",
With = {
["run"] = "npm run test",
["working-directory"] = "vscode-testextension"
}});
}
}
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ jobs:
id: pack
run: |
dotnet nuke Pack --skip
- name: Npm install
run: |
cd vscode-testextension
npm ci
cd ..
- name: 🚦 Vscode extension tests
uses: coactions/setup-xvfb@v1
with:
run: 'npm run test'
working-directory: 'vscode-testextension'
- name: 🏺 Publish coverage data
if: always()
uses: actions/upload-artifact@v3
Expand Down
4 changes: 4 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@
"GenerateCodeCoverageReportCobertura",
"GenerateCodeCoverageSummary",
"GenerateReadme",
"NpmInstall",
"Pack",
"Restore",
"Test",
"TestVscodeTestExtension",
"Trigger_Code_Coverage_Reports",
"TriggerCodeCoverageReports"
]
Expand Down Expand Up @@ -140,9 +142,11 @@
"GenerateCodeCoverageReportCobertura",
"GenerateCodeCoverageSummary",
"GenerateReadme",
"NpmInstall",
"Pack",
"Restore",
"Test",
"TestVscodeTestExtension",
"Trigger_Code_Coverage_Reports",
"TriggerCodeCoverageReports"
]
Expand Down
69 changes: 69 additions & 0 deletions vscode-testextension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vscode-testextension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"glob": "^10.3.10",
"mocha": "^10.2.0",
"source-map-support": "^0.5.21",
"tmp-promise": "^3.0.3",
"typescript": "^5.2.2"
},
"dependencies": {
Expand Down
20 changes: 18 additions & 2 deletions vscode-testextension/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as path from 'path';
import * as tmp from 'tmp-promise';

import { runTests } from '@vscode/test-electron';

Expand All @@ -12,10 +13,25 @@ async function main() {
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
// The path to the user data directory used by vscode
// As the default one is too long (> 103 characters) on some CI setups, forcing it to a temporary and hopefully shorter one.
const userDataDir = await tmp.dir({ unsafeCleanup: true });

try {
// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: ["--user-data-dir", userDataDir.path]
});
}
finally
{
await userDataDir.cleanup();
}
} catch (err) {
console.error('Failed to run tests');
console.error(err);
process.exit(1);
}
}
Expand Down
Loading