Skip to content

Commit

Permalink
Implemented unit test in build (#30)
Browse files Browse the repository at this point in the history
* Updated jest dependencies.
Removed jest dependencies from root package.json.
Moved jest-config to extentensions/crossmodel-lang  for now.

* Enabled test in the pipeline.

* Added github specific reporting option for jest.

* Fixed error with not seeing debug messages in debug mode.

* Updated package.json files to all have test script and use lerna to run all tests.

* Refactored build workflows and actions to use bash i.s.o. PowerShell and aligned with Theia Blueprint.

* Removed setting yarn version.

* Added matrix for feature branch to test multiple OSes.

* Updated main workflow to also include the matrix, like the feature workflow.

* Added publishing of test results.

* Added jest-junit and configured jest to report the junit xml.
Updated workflow to pickup the jest xml.

* Fixed error in publish test result.

* another try with different test path

* Refactored test result reporting into seperate job.

* Changed path for upload artifacts.

* Refactored workflows from actions to subworkflow.

* Added missing type on workflow inputs

* Changed required on inputs to false.

* Refactored use of inputs to env variables for software versions.
Changed jest config to write in the root, i.s.o. out directory.
Changed scan path for publishing test results.

* Fixed error with environment variable.

* Fixed folder naming issue.

* Excluded plugin folders in publish of test results.
Updated publish test result files path.

* Updated tsconfig to be in line with Theia and solve warning.
Performed yarn upgrade.

* Updated upload-artifacts for excluding plugin folders.

* Updated jest config to work for alle applications, extensions and packages.

* Fixed jest root level configuration and vscode settings.
Remove coverage report.

* Also skip the node_modules folder for uploading test results.

* Added skipping node_modules in jest base config.

* Removed coverage files and added to gitignore.

* Added jest to tslint configuration
Refactored tsconfig to all extend the base tsconfig and have specific one in the root of the workspace.

* Setup gitpod config.

* Setup devcontainer config.

* Updated eslintrc ignore patterns.

* Updated eslint include path config.

* Added lint to github build-and-test workflow.

* Updated Jest launch and settings to test debugging works in VS Code.
Added model-server test from another branch.

* Moved setting jest reports to workspace level.
pdated package.json in root to execute jest directly, i.s.o. via lerna per package.

* Updated model-server unit tests, to test on error code, i.s.o. path (which is OS dependent).

* Updated uploading test results.

* Set theia version explicitly to 1.37.2.

* Fixed lint error in no return type.
  • Loading branch information
harmen-xb committed Nov 3, 2023
1 parent a1d6d23 commit f8c9c68
Show file tree
Hide file tree
Showing 53 changed files with 3,081 additions and 3,883 deletions.
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Dev-Container for CrossModel.
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "Node.js & TypeScript",
// https://github.com/devcontainers/templates/tree/main/src/typescript-node
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-16-bullseye",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11.4"
}
},

// Allow port 3000 to be forwarded.
"forwardPorts": [3000],

// Install the needed OS libs for building.
"postCreateCommand": "sudo apt-get update && sudo apt-get -y install libsecret-1-dev libxkbfile-dev"
}
12 changes: 4 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
extends: [
'./configs/base.eslintrc.js',
'./configs/warnings.eslintrc.js',
'./configs/errors.eslintrc.js'
],
extends: ['./configs/base.eslintrc.js', './configs/warnings.eslintrc.js', './configs/errors.eslintrc.js'],
ignorePatterns: ['**/{node_modules,lib}', '**/.eslintrc.js', 'extensions/**/generated'],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json'
},
settings: {
react: {
version: 'detect'
}
react: {
version: 'detect'
}
}
};
60 changes: 0 additions & 60 deletions .github/actions/build/action.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/actions/test/action.yml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
on:
workflow_call:

env:
NODE_VERSION: 16.20.0
PYTHON_VERSION: 3.11.4

defaults:
run:
shell: bash

jobs:
build-and-test:
name: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [windows-2019, ubuntu-latest, macos-11]

runs-on: ${{ matrix.os }}
timeout-minutes: 60

steps:
# Checkout the code.
- name: checkout
uses: actions/checkout@v4

# Setup Node
- name: Setup Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

# Setup Python
- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

# Build the code.
- name: Build
# We set a timeout here as a fix for the timeout issues which sometimes occur when connecting the the npm repo.
run: |
yarn --skip-integrity-check --network-timeout 100000
yarn build
# Execute the tests.
- name: Test
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

# Upload Test Results (The different files for the OSes will end up in the same artifact).
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-tesults
# Include the unit-test-results folders (which is in the root of the workspace).
path: unit-test-results

# Run lint only on Linux (since it only makes sense to run it once, and linux is the fastest).
- name: Lint
if: runner.os == 'Linux'
run: yarn lint

# Publish a test report using the test result files published in the previous step (executed per OS).
publish-test-report:
name: Publish Test Report
needs: build-and-test
runs-on: ubuntu-latest
if: always()
steps:
# Download the test results artifacts.
- name: Download Test Results
uses: actions/download-artifact@v3
with:
name: unit-test-tesults
path: unit-test-tesults
# Publish Test Results
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: Test Results
files: |
unit-test-tesults/**/*.xml
13 changes: 13 additions & 0 deletions .github/workflows/cicd-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: cicd-feature

on:
push:
branches:
- feature/*
pull_request:
branches:
- feature/*

jobs:
build-and-test:
uses: ./.github/workflows/build-and-test.yml
10 changes: 10 additions & 0 deletions .github/workflows/cicd-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: cicd-main

on:
push:
branches:
- main

jobs:
build-and-test:
uses: ./.github/workflows/build-and-test.yml
18 changes: 0 additions & 18 deletions .github/workflows/feature.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/main.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ plugins
bin
.ignored_out
dist
*.port
*.port
**/unit-test-results
**/coverage
24 changes: 11 additions & 13 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

# To have the dependencies for Theia installed execute the following commands in the GitPod workspace once:
# sudo apt-get install libsecret-1-dev libxkbfile-dev
# nvm install 16.20.0
# pyenv install -s 3.11.4
# pyenv global 3.11.4
# GitPod configuration for CrossModel.

tasks:
- init: yarn install && yarn run build
command: yarn run watch
# To have the OS dependencies for CrossModel installed execute the following commands in the GitPod workspace once:
- before: |
sudo apt-get -y install libsecret-1-dev libxkbfile-dev
nvm install 16.20.0
pyenv install -s 3.11.4
pyenv global 3.11.4
# Download dependencies
init: yarn
# Build and watch the source code.
command: yarn watch
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"protocol": "inspector",
"args": [
"${workspaceFolder}/applications/electron-app",
"--loglevel=debug",
"--log-level=debug",
"--hostname=localhost",
"--no-cluster",
"--root-dir=${workspaceRoot}/examples/yaml-example",
Expand Down Expand Up @@ -59,7 +59,7 @@
"args": [
"${workspaceFolder}/applications/browser-app",
"--debug",
"--loglevel=debug",
"--log-level=debug",
"--hostname=localhost",
"--no-cluster",
"--root-dir=${workspaceRoot}/examples/workspace",
Expand Down Expand Up @@ -123,8 +123,8 @@
"--inspect-brk",
"${workspaceRoot}/node_modules/jest/bin/jest.js",
"--runInBand",
"--config=extensions/crossmodel-lang/jest.config.js",
"--testPathPattern=extensions/crossmodel-lang/test/language-server/util/name-util.test.ts"
"--config=${workspaceRoot}/config/jest.config.js",
"--testPathPattern={extensions|packages}/*/test/**/*.test.ts"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"jest.jestCommandLine": "npm exec -- jest --config=configs/jest.config.js"
}
5 changes: 5 additions & 0 deletions applications/browser-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseConfig = require('../../configs/base.jest.config');

module.exports = {
...baseConfig
};
29 changes: 15 additions & 14 deletions applications/browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"prepare": "theia build --mode development && yarn download:plugins",
"rebuild": "theia rebuild:browser --cacheRoot ../..",
"start": "yarn rebuild && theia start --plugins=local-dir:plugins",
"test": "jest --passWithNoTests",
"watch": "theia build --watch --mode development"
},
"dependencies": {
Expand All @@ -28,22 +29,22 @@
"@crossbreeze/model-service": "^1.0.0",
"@crossbreeze/product": "0.0.0",
"@crossbreeze/property-view": "^1.0.0",
"@theia/core": "^1.34.4",
"@theia/editor": "^1.34.4",
"@theia/filesystem": "^1.34.4",
"@theia/markers": "^1.34.4",
"@theia/messages": "^1.34.4",
"@theia/monaco": "^1.34.4",
"@theia/navigator": "^1.34.4",
"@theia/plugin-ext": "^1.34.4",
"@theia/plugin-ext-vscode": "^1.34.4",
"@theia/preferences": "^1.34.4",
"@theia/process": "^1.34.4",
"@theia/terminal": "^1.34.4",
"@theia/workspace": "^1.34.4"
"@theia/core": "1.37.2",
"@theia/editor": "1.37.2",
"@theia/filesystem": "1.37.2",
"@theia/markers": "1.37.2",
"@theia/messages": "1.37.2",
"@theia/monaco": "1.37.2",
"@theia/navigator": "1.37.2",
"@theia/plugin-ext": "1.37.2",
"@theia/plugin-ext-vscode": "1.37.2",
"@theia/preferences": "1.37.2",
"@theia/process": "1.37.2",
"@theia/terminal": "1.37.2",
"@theia/workspace": "1.37.2"
},
"devDependencies": {
"@theia/cli": "^1.34.4"
"@theia/cli": "1.37.2"
},
"productName": "CrossModel Community Edition",
"theia": {
Expand Down
5 changes: 5 additions & 0 deletions applications/electron-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseConfig = require('../../configs/base.jest.config');

module.exports = {
...baseConfig
};

0 comments on commit f8c9c68

Please sign in to comment.