Skip to content

Commit 00adbe3

Browse files
authored
Merge pull request OmniSharp#1049 from manandre/npm-ci
Add npm to CI build
2 parents cd644b2 + a6082db commit 00adbe3

File tree

7 files changed

+140
-2
lines changed

7 files changed

+140
-2
lines changed

.build/Build.cs

+16
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using Nuke.Common.Execution;
44
using Nuke.Common.Git;
55
using Nuke.Common.IO;
6+
using Nuke.Common.Tooling;
67
using Nuke.Common.Tools.DotNet;
78
using Nuke.Common.Tools.GitVersion;
89
using Nuke.Common.Tools.MSBuild;
10+
using Nuke.Common.Tools.Npm;
911
using Rocket.Surgery.Nuke.DotNetCore;
1012

1113
namespace Build;
@@ -61,11 +63,25 @@ public sealed partial class Solution : NukeBuild,
6163

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

66+
public Target NpmInstall => _ => _
67+
.Executes(() =>
68+
NpmTasks.NpmCi(s => s
69+
.SetProcessWorkingDirectory(VscodeTestExtensionProjectDirectory)));
70+
71+
public Target TestVscodeExtension => _ => _
72+
.DependsOn(NpmInstall)
73+
.Executes(() =>
74+
NpmTasks.NpmRun(s => s
75+
.SetProcessWorkingDirectory(VscodeTestExtensionProjectDirectory)
76+
.SetCommand("test")));
77+
6478
public Target BuildVersion => _ => _.Inherit<IHaveBuildVersion>(x => x.BuildVersion)
6579
.Before(Default)
6680
.Before(Clean);
6781

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

7084
AbsolutePath ICanUpdateReadme.ReadmeFilePath => RootDirectory / "README.md";
85+
86+
private const string VscodeTestExtensionProjectDirectory = "vscode-testextension";
7187
}

.build/Solution.cs

+22
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,32 @@ RocketSurgeonGitHubActionsConfiguration configuration
102102
.ConfigureStep<CheckoutStep>(step => step.FetchDepth = 0)
103103
.UseDotNetSdks("3.1", "7.0")
104104
.AddNuGetCache()
105+
.AddVscodeExtensionTests()
105106
.PublishLogs<Solution>()
106107
.PublishArtifacts<Solution>()
107108
.FailFast = false;
108109

109110
return configuration;
110111
}
111112
}
113+
114+
public static class Extensions
115+
{
116+
public static RocketSurgeonsGithubActionsJob AddVscodeExtensionTests(this RocketSurgeonsGithubActionsJob job)
117+
{
118+
return job
119+
.AddStep(new RunStep("Npm install") {
120+
Run = string.Join(Environment.NewLine, [
121+
"cd vscode-testextension",
122+
"npm ci",
123+
"cd .."
124+
])
125+
})
126+
.AddStep(new UsingStep("Vscode extension tests") {
127+
Uses = "coactions/setup-xvfb@v1",
128+
With = {
129+
["run"] = "npm run test",
130+
["working-directory"] = "vscode-testextension"
131+
}});
132+
}
133+
}

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ jobs:
117117
id: pack
118118
run: |
119119
dotnet nuke Pack --skip
120+
- name: Npm install
121+
run: |
122+
cd vscode-testextension
123+
npm ci
124+
cd ..
125+
- name: 🚦 Vscode extension tests
126+
uses: coactions/setup-xvfb@v1
127+
with:
128+
run: 'npm run test'
129+
working-directory: 'vscode-testextension'
120130
- name: 🏺 Publish coverage data
121131
if: always()
122132
uses: actions/upload-artifact@v3

.nuke/build.schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@
103103
"GenerateCodeCoverageReportCobertura",
104104
"GenerateCodeCoverageSummary",
105105
"GenerateReadme",
106+
"NpmInstall",
106107
"Pack",
107108
"Restore",
108109
"Test",
110+
"TestVscodeTestExtension",
109111
"Trigger_Code_Coverage_Reports",
110112
"TriggerCodeCoverageReports"
111113
]
@@ -140,9 +142,11 @@
140142
"GenerateCodeCoverageReportCobertura",
141143
"GenerateCodeCoverageSummary",
142144
"GenerateReadme",
145+
"NpmInstall",
143146
"Pack",
144147
"Restore",
145148
"Test",
149+
"TestVscodeTestExtension",
146150
"Trigger_Code_Coverage_Reports",
147151
"TriggerCodeCoverageReports"
148152
]

vscode-testextension/package-lock.json

+69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-testextension/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"glob": "^10.3.10",
5656
"mocha": "^10.2.0",
5757
"source-map-support": "^0.5.21",
58+
"tmp-promise": "^3.0.3",
5859
"typescript": "^5.2.2"
5960
},
6061
"dependencies": {

vscode-testextension/test/runTest.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path';
2+
import * as tmp from 'tmp-promise';
23

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

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

15-
// Download VS Code, unzip it and run the integration test
16-
await runTests({ extensionDevelopmentPath, extensionTestsPath });
16+
// The path to the user data directory used by vscode
17+
// As the default one is too long (> 103 characters) on some CI setups, forcing it to a temporary and hopefully shorter one.
18+
const userDataDir = await tmp.dir({ unsafeCleanup: true });
19+
20+
try {
21+
// Download VS Code, unzip it and run the integration test
22+
await runTests({
23+
extensionDevelopmentPath,
24+
extensionTestsPath,
25+
launchArgs: ["--user-data-dir", userDataDir.path]
26+
});
27+
}
28+
finally
29+
{
30+
await userDataDir.cleanup();
31+
}
1732
} catch (err) {
1833
console.error('Failed to run tests');
34+
console.error(err);
1935
process.exit(1);
2036
}
2137
}

0 commit comments

Comments
 (0)