diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f09d3e4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: 'CI' + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-node@v4.0.2 + with: + node-version: 18.x + - name: Install dependencies + run: yarn install + - name: Check for uncommitted changes in yarn.lock + run: | + if git diff --name-only | grep -q "^yarn.lock"; then + echo "::error::The yarn.lock file has uncommitted changes!" + exit 1 + fi + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-node@v4.0.2 + with: + node-version: 18.x + - name: Install + run: | + yarn install --ignore-scripts + yarn compile + - name: Create eslint json report + run: | + yarn lint:ci + continue-on-error: true + - name: Create summary + run: | + npm_config_yes=true npx github:10up/eslint-json-to-md#82ff16b --path ./eslint_report.json --output ./eslint_report.md + cat eslint_report.md >> $GITHUB_STEP_SUMMARY + + playwright: + name: Playwright Tests + runs-on: ubuntu-latest + env: + CI: true + STANDALONE_URL: 'file://${{ github.workspace }}/examples/workflow-test/repositories/glsp-client/examples/workflow-standalone/app/diagram.html' + THEIA_URL: 'http://localhost:3000' + VSCODE_VSIX_ID: 'eclipse-glsp.workflow-vscode-example' + VSCODE_VSIX_PATH: '${{ github.workspace }}/examples/workflow-test/repositories/glsp-vscode-integration/example/workflow/extension/workflow-vscode-example-2.2.0-next.vsix' + GLSP_SERVER_DEBUG: 'true' + GLSP_SERVER_PORT: '8081' + GLSP_SERVER_PLAYWRIGHT_MANAGED: 'true' + GLSP_WEBSOCKET_PATH: 'workflow' + + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/setup-node@v4.0.2 + with: + node-version: '18' + - name: Install dependencies + run: yarn install + - name: Prepare repos + run: yarn repo prepare + - name: Run Playwright tests + run: yarn test + - name: Upload Playwright report + uses: actions/upload-artifact@v4.3.4 + with: + name: playwright-report + path: glsp-playwright/examples/workflow-test/playwright-report/ diff --git a/.github/workflows/publish-next.yml b/.github/workflows/publish-next.yml new file mode 100644 index 0000000..24ab279 --- /dev/null +++ b/.github/workflows/publish-next.yml @@ -0,0 +1,47 @@ +name: 'Publish next' +on: + workflow_run: + workflows: ['CI'] + types: + - completed + workflow_dispatch: + +permissions: + id-token: write +jobs: + build: + name: Build & Release + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') + env: + changes: true + steps: + - uses: actions/checkout@v4.1.7 + with: + # To fetch all history for all branches and tags. + # Required for lerna to determine the version of the next package. + fetch-depth: 0 + ref: ${{ github.event.workflow_run.head_commit.id || github.sha }} + - name: Check for changes in "packages" or "examples" directory + id: check_changes + run: | + if git diff --name-only HEAD^ HEAD | grep -qE '^(packages|examples)'; then + echo "changes=true" >> $GITHUB_ENV + else + echo "changes=false" >> $GITHUB_ENV + fi + if: github.event_name == 'workflow_run' + - uses: actions/setup-node@v4.0.2 + with: + node-version: 18.x + registry-url: 'https://registry.npmjs.org' + if: env.changes == 'true' + - name: Build + run: yarn --skip-integrity-check --network-timeout 100000 + if: env.changes == 'true' + - name: Publish NPM + run: yarn publish:next + env: + NPM_CONFIG_PROVENANCE: 'true' + NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }} + if: env.changes == 'true' diff --git a/.vscode/settings.json b/.vscode/settings.json index 212682c..b5122ae 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,9 @@ "task.autoDetect": "off", "typescript.tsdk": "node_modules/typescript/lib", "typescript.preferences.importModuleSpecifier": "relative", - "typescript.preferences.autoImportFileExcludePatterns": ["packages/*/src/index.ts"], + "typescript.preferences.autoImportFileExcludePatterns": [ + "packages/*/src/index.ts" + ], "[css]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, @@ -40,7 +42,12 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[yaml]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2 + }, + "[github-actions-workflow]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2 }, "markdownlint.config": { "MD007": { diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 88cd510..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,149 +0,0 @@ -def kubernetes_config = """ -apiVersion: v1 -kind: Pod -spec: - containers: - - name: node - image: eclipseglsp/ci:alpine-v5.0 - tty: true - resources: - limits: - memory: "2Gi" - cpu: "1" - requests: - memory: "2Gi" - cpu: "1" - command: - - cat - volumeMounts: - - mountPath: "/home/jenkins" - name: "jenkins-home" - readOnly: false - - mountPath: "/.yarn" - name: "yarn-global" - readOnly: false - - mountPath: "/.cache" - name: "playwright-cache" - readOnly: false - volumes: - - name: "jenkins-home" - emptyDir: {} - - name: "yarn-global" - emptyDir: {} - - name: "playwright-cache" - emptyDir: {} -""" - -pipeline { - agent { - kubernetes { - label 'glsp-theia-agent-pod' - yaml kubernetes_config - } - } - options { - buildDiscarder logRotator(numToKeepStr: '15') - } - - environment { - YARN_CACHE_FOLDER = "${env.WORKSPACE}/yarn-cache" - SPAWN_WRAP_SHIM_ROOT = "${env.WORKSPACE}" - EMAIL_TO= "glsp-build@eclipse.org" - } - - stages { - stage('Build') { - steps { - timeout(30) { - container('node') { - sh "yarn install --unsafe-perm" - script { - // Fail the step if there are uncommited changes to the yarn.lock file - if (sh(returnStatus: true, script: 'git diff --name-only | grep -q "^yarn.lock"') == 0) { - echo 'The yarn.lock file has uncommited changes!' - error 'The yarn.lock file has uncommited changes!' - } - } - } - } - } - } - - stage('Codechecks (ESLint)'){ - steps { - container('node') { - timeout(30){ - sh "yarn lint:ci" - } - } - } - } - - stage('Deploy (main only)') { - when { - allOf { - branch 'main' - expression { - /* Only trigger the deployment job if the changeset contains changes in - the `packages` or `examples/workflow-theia` directory */ - sh(returnStatus: true, script: 'git diff --name-only HEAD^ | grep -q "^packages\\|examples/workflow-test"') == 0 - } - } - } - steps { - container('node') { - timeout(30) { - withCredentials([string(credentialsId: 'npmjs-token', variable: 'NPM_AUTH_TOKEN')]) { - sh 'printf "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}\n" >> $WORKSPACE/.npmrc' - } - sh 'git config user.email "eclipse-glsp-bot@eclipse.org"' - sh 'git config user.name "eclipse-glsp-bot"' - sh 'yarn publish:next' - } - } - } - } - } - - post { - success { - // Record & publish ESLint issues - recordIssues enabledForFailure: true, publishAllIssues: true, aggregatingResults: true, - tools: [esLint(pattern: 'node_modules/**/*/eslint.xml')], - qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]] - } - failure { - script { - if (env.BRANCH_NAME == 'main') { - echo "Build result FAILURE: Send email notification to ${EMAIL_TO}" - emailext attachLog: true, - from: 'glsp-bot@eclipse.org', - body: 'Job: ${JOB_NAME}
Build Number: ${BUILD_NUMBER}
Build URL: ${BUILD_URL}', - mimeType: 'text/html', subject: 'Build ${JOB_NAME} (#${BUILD_NUMBER}) FAILURE', to: "${EMAIL_TO}" - } - } - } - unstable { - script { - if (env.BRANCH_NAME == 'main') { - echo "Build result UNSTABLE: Send email notification to ${EMAIL_TO}" - emailext attachLog: true, - from: 'glsp-bot@eclipse.org', - body: 'Job: ${JOB_NAME}
Build Number: ${BUILD_NUMBER}
Build URL: ${BUILD_URL}', - mimeType: 'text/html', subject: 'Build ${JOB_NAME} (#${BUILD_NUMBER}) UNSTABLE', to: "${EMAIL_TO}" - } - } - } - fixed { - script { - if (env.BRANCH_NAME == 'main') { - echo "Build back to normal: Send email notification to ${EMAIL_TO}" - emailext attachLog: false, - from: 'glsp-bot@eclipse.org', - body: 'Job: ${JOB_NAME}
Build Number: ${BUILD_NUMBER}
Build URL: ${BUILD_URL}', - mimeType: 'text/html', subject: 'Build ${JOB_NAME} back to normal (#${BUILD_NUMBER})', to: "${EMAIL_TO}" - } - } - } - } -} diff --git a/examples/workflow-test/package.json b/examples/workflow-test/package.json index 38814bb..212d2da 100644 --- a/examples/workflow-test/package.json +++ b/examples/workflow-test/package.json @@ -33,7 +33,6 @@ "build": "tsc -b", "clean": "rimraf --glob lib tsconfig.tsbuildinfo server/*.log", "lint": "eslint --ext .ts,.tsx ./src ./tests", - "lint:ci": "yarn lint -o eslint.xml -f checkstyle", "prepare": "playwright install", "repo": "ts-node ./scripts/repositories.ts", "start:server": "node node_modules/@eclipse-glsp-examples/workflow-server-bundled/wf-glsp-server-node.js", diff --git a/package.json b/package.json index 8c562dd..827e763 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,13 @@ "example": "yarn --cwd ./examples/workflow-test", "generate:index": "lerna run generate:index && yarn lint:fix", "lint": "eslint --ext .ts,.tsx --ignore-pattern '**/repositories/**' .", - "lint:ci": "yarn lint -o eslint.xml -f checkstyle", + "lint:ci": "yarn lint --output-file eslint_report.json --format json", "lint:fix": " yarn lint --fix", "prepare": "lerna run prepare && yarn build", "publish:latest": "lerna publish from-git --no-push", "publish:next": "lerna publish preminor --exact --canary --preid next --dist-tag next --no-git-tag-version --no-push --ignore-scripts --yes", "publish:prepare": "lerna version --ignore-scripts --yes --no-push --exact", + "repo": "yarn example repo", "test": "cd examples/workflow-test && yarn test", "test:standalone": "yarn example test:standalone", "test:theia": "yarn example test:theia", diff --git a/packages/glsp-playwright/package.json b/packages/glsp-playwright/package.json index dc9f807..701650f 100644 --- a/packages/glsp-playwright/package.json +++ b/packages/glsp-playwright/package.json @@ -37,7 +37,6 @@ "generate:index": "glsp generateIndex src -f", "lint": "eslint --ext .ts,.tsx ./src", "lint:all": "yarn lint && yarn circular --no-spinner", - "lint:ci": "yarn lint -o eslint.xml -f checkstyle", "watch": "(concurrently \"tsc -w\" \"tsc-alias -w\")", "watch:alias": "tsc-alias -w" },