Skip to content

Commit

Permalink
fix #6409: api integration testing setup
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Jan 22, 2020
1 parent fde9de3 commit 224ecda
Show file tree
Hide file tree
Showing 51 changed files with 2,121 additions and 2,437 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lerna-debug.log
coverage
errorShots
examples/*/src-gen
examples/*/webpack.config.js
examples/*/gen-webpack.config.js
.browser_modules
**/docs/api
package-backup.json
Expand Down
2 changes: 2 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ image:
ports:
- port: 3000 # Theia
- port: 3030 # VS Code extension tests
- port: 9229 # Node.js debug port
onOpen: ignore
- port: 9339 # Node.js debug port
onOpen: ignore
- port: 6080
Expand Down
109 changes: 54 additions & 55 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
sudo: required
language: node_js
node_js: '10'
node_js: "10"
git:
depth: 1
cache:
yarn: true
directories:
# All directories need to be listed here, because Travis does not support globs.
# Auto generated by scripts/prepare-travis
# start_cache_directories
# All directories need to be listed here, because Travis does not support globs.
# Auto generated by scripts/prepare-travis
# start_cache_directories
- /tmp/vscode-ripgrep-cache-1.5.7
- dev-packages/application-manager/node_modules
- dev-packages/application-package/node_modules
Expand Down Expand Up @@ -65,16 +65,16 @@ cache:
- packages/variable-resolver/node_modules
- packages/workspace/node_modules
# end_cache_directories
- packages/java-debug/download
- packages/debug-nodejs/download
- packages/java-debug/download
- packages/debug-nodejs/download
before_cache:
# Runs before the cache is updated, after successful CI
- rm -f node_modules/@theia/electron/post-install.log
- rm -rf node_modules/@theia/electron/download
- rm -rf node_modules/electron
branches:
only:
- master
- master
env:
global:
- CXX=g++-4.8
Expand All @@ -83,14 +83,13 @@ addons:
apt:
update: true
sources:
- ubuntu-toolchain-r-test
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- libsecret-1-dev
- xvfb
- libx11-dev
- libxkbfile-dev
chrome: stable
- g++-4.8
- libsecret-1-dev
- xvfb
- libx11-dev
- libxkbfile-dev
jdk:
- oraclejdk9
before_install:
Expand All @@ -115,50 +114,50 @@ script:
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/c42ddc125fe6bbfccb48
- https://webhooks.gitter.im/e/c42ddc125fe6bbfccb48
on_success: change
on_failure: always
on_start: never
jobs:
fast_finish: true
include:
- stage: test
os: linux
- os: osx
env: CXX=c++
before_script: skip
script:
- travis_retry yarn test:theia
- os: windows
env:
- CXX=c++
- YARN_GPG=no
before_script: skip
script:
- travis_retry yarn test:theia
- stage: deploy
if: NOT type IN (cron, pull_request)
os: linux
before_script: skip
script: skip
install: skip
before_deploy:
- |
if ! [ "$BEFORE_DEPLOY_RUN" ]; then
export BEFORE_DEPLOY_RUN=1
printf "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}\n" >> ~/.npmrc
THEIA_SKIP_NPM_PREPARE=1 yarn install --skip-integrity-check # fix cache we meddled-with
yarn run docs
fi
deploy:
- provider: script
script: yarn run publish:next
on:
branch: master
skip_cleanup: true
- provider: pages
skip_cleanup: true
github-token: $GITHUB_TOKEN
local-dir: gh-pages
on:
branch: master
- stage: test
os: linux
- os: osx
env: CXX=c++
before_script: skip
script:
- travis_retry yarn test:theia
- os: windows
env:
- CXX=c++
- YARN_GPG=no
before_script: skip
script:
- travis_retry yarn test:theia
- stage: deploy
if: NOT type IN (cron, pull_request)
os: linux
before_script: skip
script: skip
install: skip
before_deploy:
- |
if ! [ "$BEFORE_DEPLOY_RUN" ]; then
export BEFORE_DEPLOY_RUN=1
printf "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}\n" >> ~/.npmrc
THEIA_SKIP_NPM_PREPARE=1 yarn install --skip-integrity-check # fix cache we meddled-with
yarn run docs
fi
deploy:
- provider: script
script: yarn run publish:next
on:
branch: master
skip_cleanup: true
- provider: pages
skip_cleanup: true
github-token: $GITHUB_TOKEN
local-dir: gh-pages
on:
branch: master
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ Breaking changes:
Before these attributes have to be computed for all nodes and stored as a part of the layout.
From now on they will be computed only on demand for visible nodes.
It decreases requirements to the local storage and allows to invalidate node appearance by simply rerendering a tree.
- [application-manager] `ApplicationPackageManager.start*` methods return an instance of a server child process instead of promise.
- [cli] Generated webpack config is renamed to `gen-webpack.config.js`.
`webpack.config.js` is generated only once. It can be edited by users to custoimze bundling,
but should be based on `gen-webpack.config.js` to pick any changes in the generated config.
If it does not have a reference to `gen-webpack.config.js` then it will be regenerated.

## v0.14.0

Expand Down
6 changes: 0 additions & 6 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ vscode-java-debug (0.15.0)

* License: MIT

webdriverio (n/a)

* License: MIT
* Project: http://webdriver.io/
* Source: https://github.com/webdriverio/webdriverio.git

when (3.7.8)

* License: MIT
Expand Down
1 change: 1 addition & 0 deletions configs/mocha.opts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
--require reflect-metadata/Reflect
--reporter spec
--watch-extensions js
--exit
1 change: 1 addition & 0 deletions dev-packages/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@theia/application-package": "^0.14.0",
"@theia/compression-webpack-plugin": "^3.0.0",
"@types/fs-extra": "^4.0.2",
"@types/webpack": "^4.41.2",
"babel-loader": "^8.0.6",
"circular-dependency-plugin": "^5.0.0",
"copy-webpack-plugin": "^4.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ApplicationPackageManager {
async clean(): Promise<void> {
await this.remove(this.pck.lib());
await this.remove(this.pck.srcGen());
await this.remove(this.webpack.configPath);
await this.remove(this.webpack.genConfigPath);
}

async generate(): Promise<void> {
Expand All @@ -70,22 +70,22 @@ export class ApplicationPackageManager {
return this.__process.run('webpack', args);
}

async start(args: string[] = []): Promise<void> {
start(args: string[] = []): cp.ChildProcess {
if (this.pck.isElectron()) {
return this.startElectron(args);
}
return this.startBrowser(args);
}

async startElectron(args: string[]): Promise<void> {
startElectron(args: string[]): cp.ChildProcess {
const { mainArgs, options } = this.adjustArgs([this.pck.frontend('electron-main.js'), ...args]);
const electronCli = require.resolve('electron/cli.js', { paths: [this.pck.projectPath] });
this.__process.fork(electronCli, mainArgs, options);
return this.__process.fork(electronCli, mainArgs, options);
}

async startBrowser(args: string[]): Promise<void> {
startBrowser(args: string[]): cp.ChildProcess {
const { mainArgs, options } = this.adjustArgs(args);
this.__process.fork(this.pck.backend('main.js'), mainArgs, options);
return this.__process.fork(this.pck.backend('main.js'), mainArgs, options);
}

private adjustArgs(args: string[], forkOptions: cp.ForkOptions = {}): Readonly<{ mainArgs: string[]; options: cp.ForkOptions }> {
Expand Down
78 changes: 78 additions & 0 deletions dev-packages/application-manager/src/expose-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/********************************************************************************
* Copyright (C) 2020 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import * as path from 'path';
import * as webpack from 'webpack';
// tslint:disable:no-implicit-dependencies
import { RawSourceMap } from 'source-map';
import { ApplicationPackage } from '@theia/application-package/lib/application-package';

const modulePackages: { dir: string, name?: string }[] = [];
for (const extensionPackage of new ApplicationPackage({ projectPath: process.cwd() }).extensionPackages) {
modulePackages.push({
name: extensionPackage.name,
dir: path.dirname(extensionPackage.raw.installed!.packagePath)
});
}

function exposeModule(modulePackage: { dir: string, name?: string }, resourcePath: string, source: string): string {
if (!modulePackage.name) {
return source;
}
const { dir, name } = path.parse(resourcePath);
let moduleName = path.join(modulePackage.name, dir.substring(modulePackage.dir.length));
if (name !== 'index') {
moduleName = path.join(moduleName, name);
}
if (path.sep !== '/') {
moduleName = moduleName.split(path.sep).join('/');
}
return source + `\nif (!global) global = {};\n(global['theia'] = global['theia'] || {})['${moduleName}'] = this;\n`;
}

/**
* Expose bundled modules on window.theia.moduleName namespace, e.g.
* window['theia']['@theia/core/lib/common/uri'].
* Such syntax can be used by external code, for instance, for testing.
*/
export = function (this: webpack.loader.LoaderContext, source: string, sourceMap?: RawSourceMap): string | undefined {
if (this.cacheable) {
this.cacheable();
}

let modulePackage = modulePackages.find(({ dir }) => this.resourcePath.startsWith(dir));
if (modulePackage) {
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
return;
}
const index = this.resourcePath.lastIndexOf('/node_modules');
if (index !== -1) {
const nodeModulesPath = this.resourcePath.substring(0, index + '/node_modules'.length);
let dir = this.resourcePath;
while ((dir = path.dirname(dir)) !== nodeModulesPath) {
try {
const { name } = require(path.join(dir, 'package.json'));
modulePackage = { name, dir };
modulePackages.push(modulePackage);
this.callback(undefined, exposeModule(modulePackage, this.resourcePath, source), sourceMap);
return;
} catch {
/** no-op */
}
}
}
this.callback(undefined, source, sourceMap);
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ const main = require('@theia/core/lib/node/main');
BackendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.backend.config)});
const serverModule = require('./server');
const address = main.start(serverModule());
address.then(function (address) {
const serverAddress = main.start(serverModule());
serverAddress.then(function ({ port, address }) {
if (process && process.send) {
process.send(address.port.toString());
process.send({ port, address });
}
});
module.exports = address;
module.exports = serverAddress;
`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ function load(raw) {
}
function start() {
(window['theia'] = window['theia'] || {}).container = container;
const themeService = ThemeService.get();
themeService.loadUserTheme();
Expand Down Expand Up @@ -317,8 +319,8 @@ app.on('ready', () => {
});
} else {
const cp = fork(mainPath, [], { env: Object.assign({}, process.env) });
cp.on('message', (message) => {
loadMainWindow(message);
cp.on('message', (address) => {
loadMainWindow(address.port);
});
cp.on('error', (error) => {
console.error(error);
Expand Down
Loading

0 comments on commit 224ecda

Please sign in to comment.