From 863511d4ab1f538bfcbb8ab1afefe3c264d9ccc4 Mon Sep 17 00:00:00 2001 From: Pierre-Etienne Poirot Date: Sat, 8 Jul 2023 19:55:33 +0200 Subject: [PATCH 1/4] Add a CI pipeline to run the tests --- .github/workflows/tests.yml | 17 +++++++++++++++++ Cakefile | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..a347d05d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,17 @@ +name: xml2js tests +on: [ push ] +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [ 'current', 'lts/*', 'lts/-1' ] + steps: + - uses: actions/checkout@v3 + - name: Setup Node ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run build + - run: npm run coverage diff --git a/Cakefile b/Cakefile index 83b1e84e..5f150409 100644 --- a/Cakefile +++ b/Cakefile @@ -1,8 +1,8 @@ {spawn, exec} = require 'child_process' -task 'build', 'continually build the JavaScript code', -> +task 'build', 'build the JavaScript code', -> coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' - coffee = spawn coffeeScript, ['-cw', '-o', 'lib', 'src'] + coffee = spawn coffeeScript, ['-c', '-o', 'lib', 'src'] coffee.stdout.on 'data', (data) -> console.log data.toString().trim() task 'doc', 'rebuild the Docco documentation', -> From c232621bd281e95717f3468ac4a4e27c17ca3fcb Mon Sep 17 00:00:00 2001 From: Pierre-Etienne Poirot Date: Sat, 8 Jul 2023 20:38:26 +0200 Subject: [PATCH 2/4] Build the tests in CI --- .github/workflows/tests.yml | 1 + .gitignore | 1 + Cakefile | 4 ++++ package.json | 1 + 4 files changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a347d05d..060979be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,4 +14,5 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm run build + - run: npm run build-tests - run: npm run coverage diff --git a/.gitignore b/.gitignore index 69b51c5f..bdbf7529 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules npm-debug.log .nyc_output coverage +test/*.js \ No newline at end of file diff --git a/Cakefile b/Cakefile index 5f150409..9bdb28c2 100644 --- a/Cakefile +++ b/Cakefile @@ -5,6 +5,10 @@ task 'build', 'build the JavaScript code', -> coffee = spawn coffeeScript, ['-c', '-o', 'lib', 'src'] coffee.stdout.on 'data', (data) -> console.log data.toString().trim() +task 'build-tests', 'build the tests', -> + coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' + coffee = spawn coffeeScript, ['-c', '-o', 'test', 'test'] + task 'doc', 'rebuild the Docco documentation', -> exec([ 'docco src/xml2js.coffee' diff --git a/package.json b/package.json index 7bde0538..f63da5c5 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ }, "scripts": { "build": "cake build", + "build-tests": "cake build-tests", "test": "zap", "coverage": "nyc npm test && nyc report", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", From c446faee6ae1309a85951ae5d71c7373ec80d836 Mon Sep 17 00:00:00 2001 From: Pierre-Etienne Poirot Date: Sun, 30 Jul 2023 12:15:34 +0200 Subject: [PATCH 3/4] Create a separate task for the watch mode --- Cakefile | 6 +++++- package.json | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cakefile b/Cakefile index 9bdb28c2..b957b097 100644 --- a/Cakefile +++ b/Cakefile @@ -1,9 +1,13 @@ {spawn, exec} = require 'child_process' +task 'build-watch', 'continually build the JavaScript code', -> + coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' + coffee = spawn coffeeScript, ['-cw', '-o', 'lib', 'src'] + coffee.stdout.on 'data', (data) -> console.log data.toString().trim() + task 'build', 'build the JavaScript code', -> coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' coffee = spawn coffeeScript, ['-c', '-o', 'lib', 'src'] - coffee.stdout.on 'data', (data) -> console.log data.toString().trim() task 'build-tests', 'build the tests', -> coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' diff --git a/package.json b/package.json index f63da5c5..cb9eddcf 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "scripts": { "build": "cake build", "build-tests": "cake build-tests", + "build-watch": "cake build-watch", "test": "zap", "coverage": "nyc npm test && nyc report", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls", From 668d80013a29e3034fa05c6491e80de8b935bc47 Mon Sep 17 00:00:00 2001 From: Pierre-Etienne Poirot Date: Sun, 30 Jul 2023 12:30:26 +0200 Subject: [PATCH 4/4] Rename the tasks used in CI --- .github/workflows/tests.yml | 4 ++-- Cakefile | 6 +++--- package.json | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 060979be..79c274df 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,6 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: npm ci - - run: npm run build - - run: npm run build-tests + - run: npm run build-ci + - run: npm run build-ci-tests - run: npm run coverage diff --git a/Cakefile b/Cakefile index b957b097..ec9c9c56 100644 --- a/Cakefile +++ b/Cakefile @@ -1,15 +1,15 @@ {spawn, exec} = require 'child_process' -task 'build-watch', 'continually build the JavaScript code', -> +task 'build', 'continually build the JavaScript code', -> coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' coffee = spawn coffeeScript, ['-cw', '-o', 'lib', 'src'] coffee.stdout.on 'data', (data) -> console.log data.toString().trim() -task 'build', 'build the JavaScript code', -> +task 'build-ci', 'build the JavaScript code', -> coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' coffee = spawn coffeeScript, ['-c', '-o', 'lib', 'src'] -task 'build-tests', 'build the tests', -> +task 'build-ci-tests', 'build the tests', -> coffeeScript = if process.platform == 'win32' then 'coffee.cmd' else 'coffee' coffee = spawn coffeeScript, ['-c', '-o', 'test', 'test'] diff --git a/package.json b/package.json index cb9eddcf..ff58405b 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ }, "scripts": { "build": "cake build", - "build-tests": "cake build-tests", - "build-watch": "cake build-watch", + "build-ci": "cake build-ci", + "build-ci-tests": "cake build-ci-tests", "test": "zap", "coverage": "nyc npm test && nyc report", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",