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

Upgrade to Langium 2.1.3 #40

Merged
merged 2 commits into from
Nov 24, 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
12 changes: 11 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
module.exports = {
root: true,
extends: ['./configs/base.eslintrc.js', './configs/warnings.eslintrc.js', './configs/errors.eslintrc.js'],
ignorePatterns: ['**/{node_modules,lib}', '**/.eslintrc.js', 'extensions/**/generated'],
ignorePatterns: [
'**/{node_modules,lib}',
'**/.eslintrc.js',
'extensions/**/generated',
'**/*jest.config.js',
'**/*.eslintrc.js',
'**/*.eslintrc.cjs',
'**/language-server/generated/**'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json'
},
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
settings: {
react: {
version: 'detect'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ jobs:
run: yarn test
env:
# The test result file name can be controlled using the following environment variable.
JEST_JUNIT_OUTPUT_NAME: unit-test-results-${{ runner.os }}.xml
JEST_JUNIT_OUTPUT_NAME: ${{ runner.os }}-unit-test-results

# Upload Unit Test Results (The different files for the OSes will end up in the same artifact).
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-tesults
name: unit-test-results
# Include the unit-test-results folders (which is in the root of the workspace).
path: unit-test-results
retention-days: 30
Expand Down Expand Up @@ -95,12 +95,12 @@ jobs:
- name: Download Unit Test Results
uses: actions/download-artifact@v3
with:
name: unit-test-tesults
path: unit-test-tesults
name: unit-test-results
path: unit-test-results
# Publish Test Results
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: Unit Test Results
files: |
unit-test-tesults/**/*.xml
unit-test-results/**/*.xml
65 changes: 62 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"${workspaceFolder}/applications/electron-app/src-gen/backend/server.js",
"${workspaceFolder}/applications/electron-app/src-gen/backend/main.js",
"${workspaceFolder}/extensions/*/out/**/*.js",
"${workspaceFolder}/extensions/*/out/**/*.cjs",
"${workspaceFolder}/packages/*/lib/**/*.js",
"${workspaceFolder}/node_modules/langium/lib/**/*.js",
"${workspaceFolder}/node_modules/@eclipse-glsp/*/lib/**/*.js"
Expand Down Expand Up @@ -79,6 +80,7 @@
"${workspaceFolder}/applications/electron-app/src-gen/backend/server.js",
"${workspaceFolder}/applications/electron-app/src-gen/backend/main.js",
"${workspaceFolder}/extensions/*/out/**/*.js",
"${workspaceFolder}/extensions/*/out/**/*.cjs",
"${workspaceFolder}/packages/*/lib/**/*.js",
"${workspaceFolder}/node_modules/langium/lib/**/*.js",
"${workspaceFolder}/node_modules/@eclipse-glsp/*/lib/**/*.js"
Expand Down Expand Up @@ -116,18 +118,75 @@
]
},
{
"name": "Debug Jest Tests",
"name": "Debug All CJS Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"--config=${workspaceRoot}/config/jest.config.js",
"--testPathPattern={extensions|packages}/*/test/**/*.test.ts"
"--config=${workspaceRoot}/configs/jest.config.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Debug All ESM Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--experimental-vm-modules",
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"--config=${workspaceRoot}/configs/esm.jest.config.js"
],
"env": {
"NODE_NO_WARNINGS": "1"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Debug Open CJS Jest Test",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"--config=${workspaceRoot}/configs/jest.config.js",
"${file}"
],
"env": {
"NODE_NO_WARNINGS": "1"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Debug Open ESM Jest Test",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--experimental-vm-modules",
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"--config=${workspaceRoot}/configs/esm.jest.config.js",
"${file}"
],
"env": {
"NODE_NO_WARNINGS": "1"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
"name": "Debug All Jest Tests",
"configurations": ["Debug All CJS Jest Tests", "Debug All ESM Jest Tests"]
}
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"jest.jestCommandLine": "npm exec -- jest --config=configs/jest.config.js"
"jest.jestCommandLine": "yarn test",
"jest.debugMode": true
}
4 changes: 3 additions & 1 deletion applications/browser-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
const baseConfig = require('../../configs/base.jest.config');

module.exports = {
...baseConfig
...baseConfig,
displayName: 'Browser App'
};
4 changes: 3 additions & 1 deletion applications/electron-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
const baseConfig = require('../../configs/base.jest.config');

module.exports = {
...baseConfig
...baseConfig,
displayName: 'Electron App'
};
20 changes: 20 additions & 0 deletions configs/base.esm.jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
const baseConfig = require('./base.jest.config');

module.exports = {
...baseConfig,
extensionsToTreatAsEsm: ['.ts', '.tsx'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true
}
]
}
};
16 changes: 15 additions & 1 deletion configs/base.jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
const path = require('path');

module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['./node_modules/']
testPathIgnorePatterns: ['./node_modules/'],
reporters: [
[
'jest-junit',
{
outputDirectory: path.join(__dirname, '..', 'unit-test-results'),
outputName: 'jest-report',
uniqueOutputName: 'true'
}
],
['github-actions', { silent: false }],
'summary'
]
};
5 changes: 5 additions & 0 deletions configs/esm.jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
rootDir: '../',
projects: ['<rootDir>/extensions/*']
};
4 changes: 2 additions & 2 deletions configs/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
rootDir: '../',
projects: ['<rootDir>/applications/*', '<rootDir>/extensions/*', '<rootDir>/packages/*'],
reporters: ['default', ['jest-junit', { outputDirectory: 'unit-test-results', outputName: 'jest-report.xml' }]]
harmen-xb marked this conversation as resolved.
Show resolved Hide resolved
projects: ['<rootDir>/applications/*', '<rootDir>/packages/*']
};
3 changes: 2 additions & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"lint": "eslint -c ../.eslintrc.js --ext .ts ./src",
"playwright:install": "yarn playwright install --with-deps",
"prepare": "yarn clean && yarn build && yarn lint",
"test": "yarn playwright test"
"test": "",
"ui-test": "yarn playwright test"
},
"dependencies": {
"@playwright/test": "^1.37.1",
Expand Down
9 changes: 9 additions & 0 deletions extensions/crossmodel-lang/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['../../.eslintrc.js'],
ignorePatterns: ['language-server/generated/**', 'jest.config.cjs', 'jest.setup.js'],
rules: {
// turn import issues off as eslint cannot handle ES modules
'import/no-unresolved': 'off'
}
};
56 changes: 56 additions & 0 deletions extensions/crossmodel-lang/esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//@ts-check
import * as esbuild from 'esbuild';

const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');

const success = watch ? 'Watch build succeeded' : 'Build succeeded';

function getTime() {
const date = new Date();
return `[${`${padZeroes(date.getHours())}:${padZeroes(date.getMinutes())}:${padZeroes(date.getSeconds())}`}] `;
}

function padZeroes(i) {
return i.toString().padStart(2, '0');
}

const plugins = [
{
name: 'watch-plugin',
setup(build) {
build.onEnd(result => {
if (result.errors.length === 0) {
console.log(getTime() + success);
}
});
}
}
];

const ctx = await esbuild.context({
// Entry points for the vscode extension and the language server
entryPoints: ['src/extension.ts', 'src/main.ts'],
outdir: 'out',
bundle: true,
target: 'ES2017',
// VSCode's extension host is still using cjs, so we need to transform the code
format: 'cjs',
// To prevent confusing node, we explicitly use the `.cjs` extension
outExtension: {
'.js': '.cjs'
},
loader: { '.ts': 'ts' },
external: ['vscode'],
platform: 'node',
sourcemap: !minify,
minify,
plugins
});

if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
ctx.dispose();
}
7 changes: 7 additions & 0 deletions extensions/crossmodel-lang/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
const baseConfig = require('../../configs/base.esm.jest.config');

module.exports = {
...baseConfig,
displayName: 'Extension'
};
5 changes: 0 additions & 5 deletions extensions/crossmodel-lang/jest.config.js

This file was deleted.

Loading
Loading