Skip to content

Commit

Permalink
Add build pipeline that builds extension vsix with server artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Dec 2, 2022
1 parent 8b7d087 commit 8b3763e
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 80 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/branch-merge.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/server-ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bin
obj
node_modules
out
artifacts
.omnisharp/
.omnisharp-*/
.vs/
Expand Down
46 changes: 19 additions & 27 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"CODE_WORKSPACE_ROOT": "${workspaceRoot}",
"CODE_TESTS_PATH": "${workspaceRoot}/out/test/featureTests",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "featureTests"
"OSVC_SUITE": "featureTests",
"USE_OMNISHARP_SERVER": "true",
},
"sourceMaps": true,
"outFiles": [
Expand All @@ -74,7 +75,8 @@
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/singleCsproj",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "singleCsproj",
"OMNISHARP_ENGINE": "stdio"
"OMNISHARP_ENGINE": "stdio",
"USE_OMNISHARP_SERVER": "true",
},
"sourceMaps": true,
"outFiles": [
Expand All @@ -99,7 +101,8 @@
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "BasicRazorApp2_1",
"OMNISHARP_ENGINE": "stdio"
"OMNISHARP_ENGINE": "stdio",
"USE_OMNISHARP_SERVER": "true",
},
},
{
Expand All @@ -119,7 +122,8 @@
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "slnWithCsproj",
"OMNISHARP_ENGINE": "stdio"
"OMNISHARP_ENGINE": "stdio",
"USE_OMNISHARP_SERVER": "true",
},
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -145,7 +149,8 @@
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/singleCsproj",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "singleCsproj",
"OMNISHARP_ENGINE": "lsp"
"OMNISHARP_ENGINE": "lsp",
"USE_OMNISHARP_SERVER": "true",
},
"stopOnEntry": false,
"sourceMaps": true,
Expand All @@ -171,7 +176,8 @@
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/BasicRazorApp2_1",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "BasicRazorApp2_1",
"OMNISHARP_ENGINE": "lsp"
"OMNISHARP_ENGINE": "lsp",
"USE_OMNISHARP_SERVER": "true",
},
},
{
Expand All @@ -191,7 +197,8 @@
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/slnWithCsproj",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "slnWithCsproj",
"OMNISHARP_ENGINE": "lsp"
"OMNISHARP_ENGINE": "lsp",
"USE_OMNISHARP_SERVER": "true",
},
"sourceMaps": true,
"outFiles": [
Expand All @@ -215,7 +222,8 @@
"CODE_TESTS_PATH": "${workspaceRoot}/out/test/integrationTests",
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/slnFilterWithCsproj",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "slnFilterWithCsproj"
"OSVC_SUITE": "slnFilterWithCsproj",
"USE_OMNISHARP_SERVER": "true",
},
"sourceMaps": true,
"outFiles": [
Expand All @@ -239,7 +247,8 @@
"CODE_TESTS_PATH": "${workspaceRoot}/out/test/integrationTests",
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/slnWithGenerator",
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
"OSVC_SUITE": "slnWithGenerator"
"OSVC_SUITE": "slnWithGenerator",
"USE_OMNISHARP_SERVER": "true",
},
"sourceMaps": true,
"outFiles": [
Expand All @@ -261,23 +270,6 @@
"NEW_DEPS_VERSION": "1.39.2"
},
"cwd": "${workspaceFolder}"
},
{
"name": "Launch Roslyn Language Server",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"env": {
"ROSLYN_LSP": "true",
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/*.js"
],
"preLaunchTask": "buildDev",
},
}
]
}
62 changes: 62 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
trigger:
- feature/*

pr:
- feature/*

pool:
vmImage: 'ubuntu-latest'

steps:
- task: UseDotNet@2
displayName: 'Install .NET Core SDKs'
inputs:
useGlobalJson: true
workingDirectory: server/

- script: dotnet build ./server/Microsoft.CodeAnalysis.LanguageServer.sln -warnaserror
displayName: 'Build Microsoft.CodeAnalysis.LanguageServer.sln'

- script: dotnet test ./server/Microsoft.CodeAnalysis.LanguageServer.sln --no-build
displayName: 'Test Microsoft.CodeAnalysis.LanguageServer.sln'

- script: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
displayName: Setup virtual display

- task: NodeTool@0
displayName: 'Install Node.js 15.x'
inputs:
versionSpec: '15.x'

- script: |
npm ci
npm i -g gulp
displayName: 'Install dependencies'

- script: npm run compile
displayName: 'Compile'

- script: gulp 'vsix:release:package:platform-neutral'
displayName: 'Build platform-neutral extension package'

- script: |
npm run test
npm run test:artifacts
displayName: 'Run unit and integration tests'
env:
CODE_VERSION: 1.66.0
DISPLAY: :99.0
# Continue on error so we still upload the vsix even if tests fail.
continueOnError: true

- task: CopyFiles@2
displayName: 'Copy vsixes to upload directory'
inputs:
contents: '$(Build.SourcesDirectory)/*.vsix'
targetFolder: '$(Build.SourcesDirectory)/vsix'

- task: PublishPipelineArtifact@1
displayName: 'Publish VSIXs'
inputs:
targetPath: '$(Build.SourcesDirectory)/vsix'
artifactName: 'VSIXs'
1 change: 1 addition & 0 deletions offline.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.vscode-test/**
coverage/**
out/**
server/**
src/**
tasks/**
test/**
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@
"default": "verbose",
"description": "Traces the communication between VS Code and the language server."
},
"microsoft-codeanalysis-languageserver.useOmnisharpServer": {
"type": "boolean",
"default": false,
"description": "Switches to use the Omnisharp server for language features when enabled (requires restart)."
},
"csharp.format.enable": {
"type": "boolean",
"default": true,
Expand Down
1 change: 1 addition & 0 deletions release.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.vscode-test/**
coverage/**
out/**
server/**
src/**
tasks/**
test/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>../../artifacts</BaseOutputPath>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export async function exec(command: string, workDirectory: string = process.cwd(

function startServer(outputChannel: vscode.OutputChannel, solutionPath: vscode.Uri) : cp.ChildProcess {
let clientRoot = __dirname;
const serverPath = path.join(clientRoot, "..", "server", "Microsoft.CodeAnalysis.LanguageServer", "bin", "Debug", "net7.0", "Microsoft.CodeAnalysis.LanguageServer.dll");
const serverPath = path.join(clientRoot, "..", "artifacts", "Debug", "net7.0", "Microsoft.CodeAnalysis.LanguageServer.dll");

if (!fs.existsSync(serverPath)) {
const error = new Error(`Cannot find language server in path '${serverPath}''`);
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ import { activateRoslynLanguageServer } from "./lsptoolshost/roslynLanguageServe

export async function activate(context: vscode.ExtensionContext): Promise<CSharpExtensionExports | null> {

let useRoslynLsp = process.env.ROSLYN_LSP;
if (useRoslynLsp) {
const config = vscode.workspace.getConfiguration('microsoft-codeanalysis-languageserver');
let useOmnisharpServer = config.get<boolean>('useOmnisharpServer') || process.env.USE_OMNISHARP_SERVER;
if (!useOmnisharpServer)
{
activateRoslynLanguageServer(context);
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions tasks/testTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ gulp.task("test:feature", async () => {
CODE_TESTS_PATH: path.join(testRootPath, "featureTests"),
CODE_WORKSPACE_ROOT: rootPath,
CODE_DISABLE_EXTENSIONS: "true",
USE_OMNISHARP_SERVER: "true",
};

const result = await spawnNode([featureTestRunnerPath], { env });
Expand Down Expand Up @@ -73,6 +74,7 @@ async function runIntegrationTest(testAssetName: string, engine: 'stdio' | 'lsp'
OMNISHARP_ENGINE: engine,
OMNISHARP_LOCATION: process.env.OMNISHARP_LOCATION,
CODE_DISABLE_EXTENSIONS: 'true',
USE_OMNISHARP_SERVER: "true",
};

const result = await spawnNode([integrationTestRunnerPath], { env, cwd: rootPath });
Expand Down
3 changes: 2 additions & 1 deletion test/artifactTests/vsix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ suite("Omnisharp-Vscode VSIX", async () => {
});

vsixFiles.forEach(element => {
const sizeInMB = 5;
// We're packaging the Roslyn server in the vsix, so the size should be roughly ~20MB
const sizeInMB = 25;
const maximumVsixSizeInBytes = sizeInMB * 1024 * 1024;

suite(`Given ${element}`, () => {
Expand Down

0 comments on commit 8b3763e

Please sign in to comment.