From b3627812f958d7f3eafb3022aabeac5015c18aaa Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 04:48:13 +0200 Subject: [PATCH 01/10] Add nodejs github workflow --- .github/workflows/test.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e912d46 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Node.js CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x, 15.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run build --if-present + - run: npm test From 70235a608a234498d01aaabbdf5fea13dd914a4e Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 04:38:33 +0200 Subject: [PATCH 02/10] Fix specs in CI, add test case --- test/index.test.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/index.test.js b/test/index.test.js index f439829..91d731f 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -5,6 +5,16 @@ const path = require('path'); const compile = require('./helpers/compile'); +before(function(done) { + // The first time the compiler gets run (e.g. in a CI environment), + // some additional packages will be installed in the + // background. This can take awhile and trigger a timeout, so we do + // it here explicitly first. + this.timeout(10000); + compile('basic').then(function(inspect) { + done(); + }); +}); describe('with JSON / reflection', function() { beforeEach(function() { @@ -92,4 +102,16 @@ describe('with imports', function() { done(); }); }); -}); \ No newline at end of file + + it('should fail when the import is not found', function(done) { + compile('import', { + json: true, + // No include paths provided, so the 'import' fixture should + // fail to compile. + }).catch((err) => { + console.log(err); + // Nothing to assert, we're just testing that the error happened. + done(); + }); + }); +}); From 99d09e6d08a0ac46102eaee5d3c6afaaa9464526 Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:14:45 +0200 Subject: [PATCH 03/10] Switch to `npm install` from `npm ci` --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e912d46..4018ae3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,9 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - run: npm ci + # We're ignoring `package-lock.json` since this is an NPM + # package, meaning `npm ci` (the usual installation command) + # isn't appropriate here. + - run: npm install - run: npm run build --if-present - run: npm test From 46512a55b633d00d329f8fa8875e764650a4f8ae Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:17:36 +0200 Subject: [PATCH 04/10] Remove stray console log --- test/index.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/index.test.js b/test/index.test.js index 91d731f..2432ae1 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -109,7 +109,6 @@ describe('with imports', function() { // No include paths provided, so the 'import' fixture should // fail to compile. }).catch((err) => { - console.log(err); // Nothing to assert, we're just testing that the error happened. done(); }); From c9ddba2ffbb31aca45609d58553fbca354bf7b7f Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:20:54 +0200 Subject: [PATCH 05/10] Remove travis config --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f75a771..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: node_js -cache: - directories: - - ~/.npm -notifications: - email: false -node_js: - - '9' - - '8' - - '6' - - '4' -after_success: - - npm run semantic-release -branches: - except: - - /^v\d+\.\d+\.\d+$/ From f92b87be95584a9ba0716314e0a744f029ca5ee5 Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:21:16 +0200 Subject: [PATCH 06/10] Only run builds on PRs --- .github/workflows/{test.yml => pull_request.yml} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename .github/workflows/{test.yml => pull_request.yml} (92%) diff --git a/.github/workflows/test.yml b/.github/workflows/pull_request.yml similarity index 92% rename from .github/workflows/test.yml rename to .github/workflows/pull_request.yml index 4018ae3..6e7e260 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/pull_request.yml @@ -1,8 +1,6 @@ -name: Node.js CI +name: PR Build on: - push: - branches: [ master ] pull_request: branches: [ master ] From 8ab08585030b497e482c984e88a5312c40bf6f01 Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:41:51 +0200 Subject: [PATCH 07/10] Remove Travis badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b7a309c..81af0b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Build Status](https://travis-ci.org/kmontag/protobufjs-loader.svg?branch=master)](https://travis-ci.org/kmontag/protobufjs-loader) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) # protobufjs-loader From 1dd739586e0f9f8326bbc65b032cb5bd39ebd55f Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:42:11 +0200 Subject: [PATCH 08/10] Switch node versions for tests --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6e7e260..2fc5de0 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - node-version: [10.x, 12.x, 14.x, 15.x] + node-version: [10.x, 12.x, 16.x, 18.x] steps: - uses: actions/checkout@v3 From 7c8ea8a4543c90863f4b51b423771c67f894f279 Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:43:15 +0200 Subject: [PATCH 09/10] Add semantic-release action on merge to `master` --- .github/workflows/release.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e9dfc02 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Publish NPM package + +on: + push: + branches: + - master + +jobs: + release: + + name: Release + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '16.x' + - run: npm install + - run: npm run build --if-present + - run: npm test + - run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From a3e2e7bacb25d9cb6d5d731d12e8a9f30a3f9959 Mon Sep 17 00:00:00 2001 From: Kevin Montag Date: Sat, 9 Jul 2022 05:45:51 +0200 Subject: [PATCH 10/10] Remove `semantic-release` script --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 6f74920..6a685e8 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "description": "Webpack loader to translate .proto definitions to ProtoBuf.js modules", "main": "index.js", "scripts": { - "test": "mocha test/*.test.js", - "semantic-release": "semantic-release pre && npm publish && semantic-release post" + "test": "mocha test/*.test.js" }, "keywords": [ "webpack",