From 2e79ea276d03762264fda57ee2a4c793a3432276 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 2 Nov 2022 13:41:48 +0100 Subject: [PATCH 1/3] add publish pipeline & cleanup ci --- .github/workflows/pr-chat.yml | 25 ++++++++++++++++++ .github/workflows/tests.yml | 21 +++++++++++++++ .travis.yml | 5 ---- .vscode/settings.json | 9 +++++++ README.md | 3 ++- build/pipeline.yml | 48 +++++++++++++++++++++++++++++++++++ package.json | 4 +-- 7 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/pr-chat.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml create mode 100644 .vscode/settings.json create mode 100644 build/pipeline.yml diff --git a/.github/workflows/pr-chat.yml b/.github/workflows/pr-chat.yml new file mode 100644 index 0000000..3910279 --- /dev/null +++ b/.github/workflows/pr-chat.yml @@ -0,0 +1,25 @@ +name: PR Chat +on: + pull_request_target: + types: [opened, ready_for_review, closed] + +jobs: + main: + runs-on: ubuntu-latest + if: ${{ !github.event.pull_request.draft }} + steps: + - name: Checkout Actions + uses: actions/checkout@v2 + with: + repository: "microsoft/vscode-github-triage-actions" + ref: stable + path: ./actions + - name: Install Actions + run: npm install --production --prefix ./actions + - name: Run Code Review Chat + uses: ./actions/code-review-chat + with: + token: ${{secrets.GITHUB_TOKEN}} + slack_token: ${{ secrets.SLACK_TOKEN }} + slack_bot_name: "VSCodeBot" + notification_channel: codereview diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6a36701 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,21 @@ +on: [push] + +name: Tests + +jobs: + build: + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Install root project dependencies + run: npm install + - name: Build and run tests + run: npm test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3b203ef..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -sudo: false - -node_js: - - "16" diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5dddcad --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "git.branchProtection": [ + "main" + ], + "git.branchProtectionPrompt": "alwaysCommitToNewBranch", + "git.branchRandomName.enable": true, + "githubPullRequests.assignCreated": "${user}", + "githubPullRequests.defaultMergeMethod": "squash" +} \ No newline at end of file diff --git a/README.md b/README.md index 7440435..5fd92d9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Scanner and parser for JSON with comments. [![npm Package](https://img.shields.io/npm/v/jsonc-parser.svg?style=flat-square)](https://www.npmjs.org/package/jsonc-parser) [![NPM Downloads](https://img.shields.io/npm/dm/jsonc-parser.svg)](https://npmjs.org/package/jsonc-parser) -[![Build Status](https://travis-ci.org/microsoft/node-jsonc-parser.svg?branch=main)](https://travis-ci.org/Microsoft/node-jsonc-parser) +[![Build Status](https://github.com/microsoft/node-jsonc-parser/workflows/Tests/badge.svg)](https://github.com/microsoft/node-jsonc-parser/workflows/Tests) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) Why? ---- diff --git a/build/pipeline.yml b/build/pipeline.yml new file mode 100644 index 0000000..e2e011f --- /dev/null +++ b/build/pipeline.yml @@ -0,0 +1,48 @@ +name: $(Date:yyyyMMdd)$(Rev:.r) + +trigger: + branches: + include: + - main +pr: none + +resources: + repositories: + - repository: templates + type: github + name: microsoft/vscode-engineering + ref: main + endpoint: Monaco + +parameters: + - name: publishPackage + displayName: 🚀 Publish jsonc-parser + type: boolean + default: false + +extends: + template: azure-pipelines/npm-package/pipeline.yml@templates + parameters: + npmPackages: + - name: jsonc-parser + + buildPlatforms: + - name: Linux + nodeVersions: + - 16.x + - name: MacOS + nodeVersions: + - 16.x + - name: Windows + nodeVersions: + - 16.x + + buildSteps: + - script: npm i + displayName: Install dependencies + + testSteps: + - script: npm test + displayName: Test npm package + + publishPackage: ${{ parameters.publishPackage }} diff --git a/package.json b/package.json index 448d814..6944044 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,6 @@ "clean": "rimraf lib", "watch": "tsc -w -p ./src", "test": "npm run compile && mocha ./lib/umd/test", - "lint": "eslint src/**/*.ts", - "preversion": "npm test", - "postversion": "git push && git push --tags" + "lint": "eslint src/**/*.ts" } } From c8e534c4f95aaec8f63a648f8f17171757f6386c Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Wed, 2 Nov 2022 15:06:58 +0100 Subject: [PATCH 2/3] remove tag updating in post-publish --- .vscode/launch.json | 1 + build/post-publish.js | 41 ----------------------------------------- package.json | 1 - 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 build/post-publish.js diff --git a/.vscode/launch.json b/.vscode/launch.json index 21a22ca..ec67fbb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,6 +8,7 @@ "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", "stopOnEntry": false, "args": [ + "./lib/umd/test", "--timeout", "999999", "--colors" diff --git a/build/post-publish.js b/build/post-publish.js deleted file mode 100644 index e523eaf..0000000 --- a/build/post-publish.js +++ /dev/null @@ -1,41 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -const cp = require('child_process'); -const path = require('path'); -const fs = require('fs'); -const readline = require('readline'); -const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'; - -function updateNextTag() { - - // read package.json from the current working directory - var packageJSON = JSON.parse(fs.readFileSync('package.json').toString()); - var name = packageJSON.name; - var version = packageJSON.version; - if (version.indexOf('next') !== -1) { - return; - } - - opts = {}; - opts.stdio = 'inherit'; - - console.log(name + ": set 'next' tag to latest version"); - - const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); - - rl.question('Enter OTP token: ', (token) => { - const result = cp.spawnSync(npm, ['--otp', token, 'dist-tags', 'add', name + '@' + version, 'next'], opts); - - rl.close(); - - if (result.error || result.status !== 0) { - process.exit(1); - } - }); -} - -updateNextTag(); - diff --git a/package.json b/package.json index 6944044..a854e57 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ }, "scripts": { "prepublishOnly": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs", - "postpublish": "node ./build/post-publish.js", "compile": "tsc -p ./src && npm run lint", "compile-esm": "tsc -p ./src/tsconfig.esm.json", "remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js", From 1d8d1101086a0f70f9975550adc12b78ffea8f13 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Thu, 3 Nov 2022 14:09:23 +0100 Subject: [PATCH 3/3] use prepack, update pipeline --- build/pipeline.yml | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/pipeline.yml b/build/pipeline.yml index e2e011f..d56cd8e 100644 --- a/build/pipeline.yml +++ b/build/pipeline.yml @@ -26,7 +26,7 @@ extends: npmPackages: - name: jsonc-parser - buildPlatforms: + testPlatforms: - name: Linux nodeVersions: - 16.x @@ -38,10 +38,12 @@ extends: - 16.x buildSteps: - - script: npm i + - script: npm ci displayName: Install dependencies testSteps: + - script: npm ci + displayName: Install dependencies - script: npm test displayName: Test npm package diff --git a/package.json b/package.json index a854e57..497fa80 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "rimraf": "^3.0.2" }, "scripts": { - "prepublishOnly": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs", + "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs", "compile": "tsc -p ./src && npm run lint", "compile-esm": "tsc -p ./src/tsconfig.esm.json", "remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js",