Skip to content

Commit

Permalink
Merge branch 'master' into planger/issues/12917
Browse files Browse the repository at this point in the history
  • Loading branch information
planger authored Nov 28, 2023
2 parents 7b0fc81 + c542676 commit 0ff911f
Show file tree
Hide file tree
Showing 50 changed files with 648 additions and 476 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/production-smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Production Build Smoke Test

on:
push:
branches:
- master
workflow_dispatch:
pull_request:
branches:
- master

jobs:
build-and-test-playwright:
name: Smoke Test for Browser Example Production Build on ubuntu-latest with Node.js 18.x

runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js "18.x"
uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"

- name: Use Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Build Browser Example Application for Production
shell: bash
run: |
yarn global add node-gyp
yarn --skip-integrity-check --network-timeout 100000
yarn browser build:production
env:
NODE_OPTIONS: --max_old_space_size=4096
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9

- name: Build Playwright
shell: bash
run: |
yarn --cwd examples/playwright build
- name: Run Smoke Test (examples/playwright/src/tests/theia-app)
uses: GabrielBB/xvfb-action@v1
with:
run: yarn test:playwright theia-app
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## v1.44.0

- [task] prevent task widget title from being changed by task process [#13003](https://github.com/eclipse-theia/theia/pull/13003)
- [vscode] added Notebook CodeActionKind [#13093](https://github.com/eclipse-theia/theia/pull/13093) - contributed on behalf of STMicroelectronics
- [vscode] added support to env.ondidChangeShell event [#13097](https://github.com/eclipse-theia/theia/pull/13097) - contributed on behalf of STMicroelectronics
- [task] support `isDefault: false` in task group definition [#13075](https://github.com/eclipse-theia/theia/pull/13075) - contributed on behalf of STMicroelectronics

## v1.43.0 - 10/26/2023
Expand Down
35 changes: 24 additions & 11 deletions dev-packages/application-manager/src/generator/backend-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ ${Array.from(electronMainModules?.values() ?? [], jsModulePath => `\
await load(require('${jsModulePath}'));`).join(EOL)}
await start();
} catch (reason) {
console.error('Failed to start the electron application.');
if (reason) {
console.error(reason);
if (typeof reason !== 'number') {
console.error('Failed to start the electron application.');
if (reason) {
console.error(reason);
}
}
app.quit();
};
Expand Down Expand Up @@ -139,8 +141,17 @@ async function start(port, host, argv = process.argv) {
if (!container.isBound(BackendApplicationServer)) {
container.bind(BackendApplicationServer).toConstantValue({ configure: defaultServeStatic });
}
await container.get(CliManager).initializeCli(argv);
return container.get(BackendApplication).start(port, host);
let result = undefined;
await container.get(CliManager).initializeCli(argv.slice(2),
() => container.get(BackendApplication).configured,
async () => {
result = container.get(BackendApplication).start(port, host);
});
if (result) {
return result;
} else {
return Promise.reject(0);
}
}
module.exports = async (port, host, argv) => {
Expand All @@ -149,9 +160,11 @@ ${Array.from(backendModules.values(), jsModulePath => `\
await load(require('${jsModulePath}'));`).join(EOL)}
return await start(port, host, argv);
} catch (error) {
console.error('Failed to start the backend application:');
console.error(error);
process.exitCode = 1;
if (typeof error !== 'number') {
console.error('Failed to start the backend application:');
console.error(error);
process.exitCode = 1;
}
throw error;
}
}
Expand All @@ -168,9 +181,9 @@ BackendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.backe
const serverModule = require('./server');
const serverAddress = main.start(serverModule());
serverAddress.then(({ port, address, family }) => {
if (process && process.send) {
process.send({ port, address, family });
serverAddress.then((addressInfo) => {
if (process && process.send && addressInfo) {
process.send(addressInfo);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { Command, CommandContribution, CommandRegistry, FilterContribution, ContributionFilterRegistry, bindContribution, Filter } from '@theia/core/lib/common';
import { Command, CommandContribution, CommandRegistry, ContributionFilterRegistry, FilterContribution, bindContribution } from '@theia/core/lib/common';
import { injectable, interfaces } from '@theia/core/shared/inversify';

export namespace SampleFilteredCommand {
Expand Down Expand Up @@ -58,8 +58,8 @@ export class SampleFilterAndCommandContribution implements FilterContribution, C
contrib => contrib.constructor !== this.constructor
]);
registry.addFilters('*', [
// filter a contribution based on its class name
filterClassName(name => name !== 'SampleFilteredCommandContribution')
// filter a contribution based on its class type
contrib => !(contrib instanceof SampleFilteredCommandContribution)
]);
}
}
Expand All @@ -69,12 +69,3 @@ export function bindSampleFilteredCommandContribution(bind: interfaces.Bind): vo
bind(SampleFilterAndCommandContribution).toSelf().inSingletonScope();
bindContribution(bind, SampleFilterAndCommandContribution, [CommandContribution, FilterContribution]);
}

function filterClassName(filter: Filter<string>): Filter<Object> {
return object => {
const className = object?.constructor?.name;
return className
? filter(className)
: false;
};
}
38 changes: 30 additions & 8 deletions examples/api-samples/src/node/sample-mock-open-vsx-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { inject, injectable } from '@theia/core/shared/inversify';
import { OVSXMockClient, VSXExtensionRaw } from '@theia/ovsx-client';
import * as path from 'path';
import { SampleAppInfo } from '../common/vsx/sample-app-info';
import * as http from 'http';
import * as https from 'https';
import { Deferred } from '@theia/core/lib/common/promise-util';

type VersionedId = `${string}.${string}@${string}`;

Expand All @@ -35,6 +38,16 @@ export class SampleMockOpenVsxServer implements BackendApplicationContribution {
@inject(SampleAppInfo)
protected appInfo: SampleAppInfo;

protected mockClient: OVSXMockClient;
protected staticFileHandlers: Map<string, express.RequestHandler<{
namespace: string;
name: string;
version: string;
}, express.Response>>;

private readyDeferred = new Deferred<void>();
private ready = this.readyDeferred.promise;

get mockServerPath(): string {
return '/mock-open-vsx';
}
Expand All @@ -43,23 +56,30 @@ export class SampleMockOpenVsxServer implements BackendApplicationContribution {
return '../../sample-plugins';
}

async configure(app: express.Application): Promise<void> {
async onStart?(server: http.Server | https.Server): Promise<void> {
const selfOrigin = await this.appInfo.getSelfOrigin();
const baseUrl = `${selfOrigin}${this.mockServerPath}`;
const pluginsDb = await this.findMockPlugins(this.pluginsDbPath, baseUrl);
const staticFileHandlers = new Map(Array.from(pluginsDb.entries(), ([key, value]) => [key, express.static(value.path)]));
const mockClient = new OVSXMockClient(Array.from(pluginsDb.values(), value => value.data));
this.staticFileHandlers = new Map(Array.from(pluginsDb.entries(), ([key, value]) => [key, express.static(value.path)]));
this.mockClient = new OVSXMockClient(Array.from(pluginsDb.values(), value => value.data));
this.readyDeferred.resolve();
}

async configure(app: express.Application): Promise<void> {
app.use(
this.mockServerPath + '/api',
express.Router()
.get('/-/query', async (req, res) => {
res.json(await mockClient.query(this.sanitizeQuery(req.query)));
await this.ready;
res.json(await this.mockClient.query(this.sanitizeQuery(req.query)));
})
.get('/-/search', async (req, res) => {
res.json(await mockClient.search(this.sanitizeQuery(req.query)));
await this.ready;
res.json(await this.mockClient.search(this.sanitizeQuery(req.query)));
})
.get('/:namespace', async (req, res) => {
const extensions = mockClient.extensions
await this.ready;
const extensions = this.mockClient.extensions
.filter(ext => req.params.namespace === ext.namespace)
.map(ext => `${ext.namespaceUrl}/${ext.name}`);
if (extensions.length === 0) {
Expand All @@ -72,15 +92,17 @@ export class SampleMockOpenVsxServer implements BackendApplicationContribution {
}
})
.get('/:namespace/:name', async (req, res) => {
res.json(mockClient.extensions.find(ext => req.params.namespace === ext.namespace && req.params.name === ext.name));
await this.ready;
res.json(this.mockClient.extensions.find(ext => req.params.namespace === ext.namespace && req.params.name === ext.name));
})
.get('/:namespace/:name/reviews', async (req, res) => {
res.json([]);
})
// implicitly GET/HEAD because of the express.static handlers
.use('/:namespace/:name/:version/file', async (req, res, next) => {
await this.ready;
const versionedId = this.getVersionedId(req.params.namespace, req.params.name, req.params.version);
const staticFileHandler = staticFileHandlers.get(versionedId);
const staticFileHandler = this.staticFileHandlers.get(versionedId);
if (!staticFileHandler) {
return next();
}
Expand Down
2 changes: 2 additions & 0 deletions examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
"scripts": {
"clean": "theia clean",
"build": "yarn -s compile && yarn -s bundle",
"build:production": "yarn -s compile && yarn -s bundle:production",
"bundle": "yarn rebuild && theia build --mode development",
"bundle:production": "yarn rebuild && theia build --mode production",
"compile": "tsc -b",
"coverage": "yarn -s test --test-coverage && yarn -s coverage:report",
"coverage:clean": "rimraf .nyc_output && rimraf coverage",
Expand Down
2 changes: 1 addition & 1 deletion examples/playwright/src/tests/theia-output-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// *****************************************************************************

import { expect } from '@playwright/test';
import { TheiaOutputViewChannel } from 'src/theia-output-channel';
import { TheiaOutputViewChannel } from '../theia-output-channel';
import { TheiaApp } from '../theia-app';
import { TheiaOutputView } from '../theia-output-view';
import test, { page } from './fixtures/theia-fixture';
Expand Down
3 changes: 1 addition & 2 deletions examples/playwright/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"outDir": "lib"
},
"include": [
"src"
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ export const supportPaste = browser.isNative || (!browser.isChrome && document.q

export const RECENT_COMMANDS_STORAGE_KEY = 'commands';

export const CLASSNAME_OS_MAC = 'mac';
export const CLASSNAME_OS_WINDOWS = 'windows';
export const CLASSNAME_OS_LINUX = 'linux';

@injectable()
export class CommonFrontendContribution implements FrontendApplicationContribution, MenuContribution, CommandContribution, KeybindingContribution, ColorContribution {

Expand Down Expand Up @@ -452,6 +456,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
this.initResourceContextKeys();
this.registerCtrlWHandling();

this.setOsClass();
this.updateStyles();
this.preferences.ready.then(() => this.setSashProperties());
this.preferences.onPreferenceChanged(e => this.handlePreferenceChange(e, app));
Expand Down Expand Up @@ -480,6 +485,16 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
});
}

protected setOsClass(): void {
if (isOSX) {
document.body.classList.add(CLASSNAME_OS_MAC);
} else if (isWindows) {
document.body.classList.add(CLASSNAME_OS_WINDOWS);
} else {
document.body.classList.add(CLASSNAME_OS_LINUX);
}
}

protected updateStyles(): void {
document.body.classList.remove('theia-editor-highlightModifiedTabs');
if (this.preferences['workbench.editor.highlightModifiedTabs']) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/browser/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ button.secondary[disabled],
| Import children style files
|----------------------------------------------------------------------------*/

@import "./os.css";
@import "./dockpanel.css";
@import "./dialog.css";
@import "./menus.css";
Expand Down
Loading

0 comments on commit 0ff911f

Please sign in to comment.