From f0bddf24701f858eeec12636a7fceb746a666d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 16 Nov 2020 13:06:11 +0100 Subject: [PATCH 1/8] GPII-4517: Added workflow for github actions --- .github/workflows/node-tests.yml | 34 +++++++++++++++++++ .../gpii-localisation/test/testLanguage.js | 10 ++++-- .../test/testNativeSettingsHandler.js | 34 +++++++++++-------- .../test/testProcessHandling.js | 4 +-- 4 files changed, 63 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/node-tests.yml diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml new file mode 100644 index 000000000..ab9c9b749 --- /dev/null +++ b/.github/workflows/node-tests.yml @@ -0,0 +1,34 @@ +name: gpii-windows node tests + +on: [push, pull_request] + +jobs: + build: + runs-on: windows-latest + env: + VCTargetsPath: 'C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140' + steps: + - uses: javihernandez/setup-node-nvm@input-arch-field + with: + node-version: "10.11.0" + node-arch: "32" + node-mirror: "https://nodejs.org/download/release/" + + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '2.7.17' + + - name: Install vcbuildtools + run: choco install vcbuildtools -ia '/InstallSelectableItems VisualCppBuildTools_ATLMFC_SDK;VisualCppBuildTools_NETFX_SDK' -y + - name: Install Windows 10 SDK + run: choco install windows-sdk-10-version-1809-all --version=10.0.17763.1 -y + - name: Install MS Build Tools + run: choco install microsoft-build-tools -y + - name: Install VisualCppBuildTools + run: choco install visualcppbuildtools -y + - run: npm config set msvs_version 2015 --global + - run: npm config set python python2.7 + + - run: npm install + - run: node tests/UnitTests.js diff --git a/gpii/node_modules/gpii-localisation/test/testLanguage.js b/gpii/node_modules/gpii-localisation/test/testLanguage.js index 1b060b4f3..35b6eee8b 100644 --- a/gpii/node_modules/gpii-localisation/test/testLanguage.js +++ b/gpii/node_modules/gpii-localisation/test/testLanguage.js @@ -19,9 +19,15 @@ "use strict"; var fluid = require("gpii-universal"); +var os = require("os"); + var jqUnit = fluid.require("node-jqunit"); var gpii = fluid.registerNamespace("gpii"); +// Windows Server 2019 is based on Windows 10 1809, this is 10.0.17763 +// Information on Windows versions: https://en.wikipedia.org/wiki/Windows_10_version_history +var isWindowsServer2019 = (os.release() === "10.0.17763")? true: false; + require("../src/language.js"); fluid.registerNamespace("gpii.tests.windows.language"); @@ -177,7 +183,7 @@ gpii.tests.windows.language.nameTests = fluid.freezeRecursive([ "bg-GB": { "english": "Bulgarian (bg-GB)", "local": "Bulgarian (bg-GB)", - "native": "български (bg-GB)", + "native": isWindowsServer2019? "": "български (bg-GB)", "code": "bg-GB" }, "ta-LK": { @@ -195,7 +201,7 @@ gpii.tests.windows.language.nameTests = fluid.freezeRecursive([ "en-xyz": { "english": "English (en-xyz)", "local": "English (en-xyz)", - "native": "English (en-xyz)", + "native": isWindowsServer2019? "": "English (en-xyz)", "code": "en-xyz" } } diff --git a/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js b/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js index 36af598af..55da648e4 100644 --- a/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js +++ b/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js @@ -453,18 +453,22 @@ gpii.tests.windows.nativeSettingsHandler.volumeApiTest = { } }; -jqUnit.test("Testing nativeSettingsHandler volume API (get and set functions)", function () { - jqUnit.expect(2); - - // Set to initial values: - gpii.windows.nativeSettingsHandler.setImpl(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.init); - // First we test the get functionality - var result = gpii.windows.nativeSettingsHandler.get(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.payload); - // Check results - jqUnit.assertDeepEq("Checking return payload of get", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.expectedResult, gpii.resolveSync(result)); - - // Test set functionality - var result2 = gpii.windows.nativeSettingsHandler.set(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.payload); - // Check results - jqUnit.assertDeepEq("Checking return payload of set", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.expectedResult, gpii.resolveSync(result2)); -}); +// Disabled in CI as in Github-hosted windows server image there's no default audio +// playback device set. Even the Windows Audio services are turned down. +if (!process.env.GITHUB_ACTIONS) { + jqUnit.test("Testing nativeSettingsHandler volume API (get and set functions)", function () { + jqUnit.expect(2); + + // Set to initial values: + gpii.windows.nativeSettingsHandler.setImpl(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.init); + // First we test the get functionality + var result = gpii.windows.nativeSettingsHandler.get(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.payload); + // Check results + jqUnit.assertDeepEq("Checking return payload of get", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.expectedResult, gpii.resolveSync(result)); + + // Test set functionality + var result2 = gpii.windows.nativeSettingsHandler.set(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.payload); + // Check results + jqUnit.assertDeepEq("Checking return payload of set", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.expectedResult, gpii.resolveSync(result2)); + }); +} diff --git a/gpii/node_modules/processHandling/test/testProcessHandling.js b/gpii/node_modules/processHandling/test/testProcessHandling.js index d94d88d0b..b77251771 100644 --- a/gpii/node_modules/processHandling/test/testProcessHandling.js +++ b/gpii/node_modules/processHandling/test/testProcessHandling.js @@ -280,8 +280,8 @@ jqUnit.test("Testing getServiceState", function () { var state = gpii.windows.getServiceState("LSM"); jqUnit.assertEquals("LSM service should be running", "running", state); - // There's a chance it might be running, but who sends faxes anymore? - state = gpii.windows.getServiceState("Fax"); + // Low chances that the Phone Service is Running + state = gpii.windows.getServiceState("PhoneSvc"); jqUnit.assertEquals("Fax service should be stopped", "stopped", state); state = gpii.windows.getServiceState("gpii-unknown"); From bc7943688bb0d377dea82268ebe65d10c2b08be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 16 Nov 2020 13:12:26 +0100 Subject: [PATCH 2/8] GPII-4517: Added lint step --- .github/workflows/node-tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index ab9c9b749..f3063b9d6 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -31,4 +31,9 @@ jobs: - run: npm config set python python2.7 - run: npm install - - run: node tests/UnitTests.js + + - name: Pass linter + run: $(npm bin)/grunt lint + + - name: Run node unit tests + run: node tests/UnitTests.js From bab3770df82765b9e626eae311a59da7da248b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 16 Nov 2020 14:00:55 +0100 Subject: [PATCH 3/8] GPII-4517: Use npx to run locally installed grunt cli when linting --- .github/workflows/node-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index f3063b9d6..5d4ba165e 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -33,7 +33,7 @@ jobs: - run: npm install - name: Pass linter - run: $(npm bin)/grunt lint + run: npx grunt lint - name: Run node unit tests run: node tests/UnitTests.js From 94af4a36f1f3a1c9489f3b389d3f77d4879f61dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 16 Nov 2020 14:05:01 +0100 Subject: [PATCH 4/8] GPII-4517: Linted changes --- .../gpii-localisation/test/testLanguage.js | 6 ++-- .../test/testNativeSettingsHandler.js | 30 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gpii/node_modules/gpii-localisation/test/testLanguage.js b/gpii/node_modules/gpii-localisation/test/testLanguage.js index 35b6eee8b..3fb8035e0 100644 --- a/gpii/node_modules/gpii-localisation/test/testLanguage.js +++ b/gpii/node_modules/gpii-localisation/test/testLanguage.js @@ -26,7 +26,7 @@ var gpii = fluid.registerNamespace("gpii"); // Windows Server 2019 is based on Windows 10 1809, this is 10.0.17763 // Information on Windows versions: https://en.wikipedia.org/wiki/Windows_10_version_history -var isWindowsServer2019 = (os.release() === "10.0.17763")? true: false; +var isWindowsServer2019 = (os.release() === "10.0.17763") ? true : false; require("../src/language.js"); @@ -183,7 +183,7 @@ gpii.tests.windows.language.nameTests = fluid.freezeRecursive([ "bg-GB": { "english": "Bulgarian (bg-GB)", "local": "Bulgarian (bg-GB)", - "native": isWindowsServer2019? "": "български (bg-GB)", + "native": isWindowsServer2019 ? "" : "български (bg-GB)", "code": "bg-GB" }, "ta-LK": { @@ -201,7 +201,7 @@ gpii.tests.windows.language.nameTests = fluid.freezeRecursive([ "en-xyz": { "english": "English (en-xyz)", "local": "English (en-xyz)", - "native": isWindowsServer2019? "": "English (en-xyz)", + "native": isWindowsServer2019 ? "" : "English (en-xyz)", "code": "en-xyz" } } diff --git a/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js b/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js index 55da648e4..e06f1170c 100644 --- a/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js +++ b/gpii/node_modules/nativeSettingsHandler/test/testNativeSettingsHandler.js @@ -456,19 +456,19 @@ gpii.tests.windows.nativeSettingsHandler.volumeApiTest = { // Disabled in CI as in Github-hosted windows server image there's no default audio // playback device set. Even the Windows Audio services are turned down. if (!process.env.GITHUB_ACTIONS) { - jqUnit.test("Testing nativeSettingsHandler volume API (get and set functions)", function () { - jqUnit.expect(2); - - // Set to initial values: - gpii.windows.nativeSettingsHandler.setImpl(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.init); - // First we test the get functionality - var result = gpii.windows.nativeSettingsHandler.get(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.payload); - // Check results - jqUnit.assertDeepEq("Checking return payload of get", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.expectedResult, gpii.resolveSync(result)); - - // Test set functionality - var result2 = gpii.windows.nativeSettingsHandler.set(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.payload); - // Check results - jqUnit.assertDeepEq("Checking return payload of set", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.expectedResult, gpii.resolveSync(result2)); - }); + jqUnit.test("Testing nativeSettingsHandler volume API (get and set functions)", function () { + jqUnit.expect(2); + + // Set to initial values: + gpii.windows.nativeSettingsHandler.setImpl(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.init); + // First we test the get functionality + var result = gpii.windows.nativeSettingsHandler.get(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.payload); + // Check results + jqUnit.assertDeepEq("Checking return payload of get", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.get.expectedResult, gpii.resolveSync(result)); + + // Test set functionality + var result2 = gpii.windows.nativeSettingsHandler.set(gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.payload); + // Check results + jqUnit.assertDeepEq("Checking return payload of set", gpii.tests.windows.nativeSettingsHandler.volumeApiTest.set.expectedResult, gpii.resolveSync(result2)); + }); } From 8e8d1ed53b47dc7c0057e1e616ed225e53676881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 17 Nov 2020 23:51:11 +0100 Subject: [PATCH 5/8] GPII-4517: Updated CouchDB script to work on github-hosted windows --- provisioning/CouchDB.ps1 | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/provisioning/CouchDB.ps1 b/provisioning/CouchDB.ps1 index 51fa14709..6e58461ee 100644 --- a/provisioning/CouchDB.ps1 +++ b/provisioning/CouchDB.ps1 @@ -49,6 +49,10 @@ Function iwr-Retry { } } +# First, let's allow connections to CouchDB ports, 25984 and 25986 +netsh advfirewall firewall add rule name="Open Port 25984" dir=in action=allow protocol=TCP localport=25984 +netsh advfirewall firewall add rule name="Open Port 25986" dir=in action=allow protocol=TCP localport=25986 + Write-Output "Adding CouchDB to the system" $couchDBInstallerURL = "http://archive.apache.org/dist/couchdb/binary/win/2.3.0/couchdb-2.3.0.msi" $couchDBInstaller = Join-Path $originalBuildScriptPath "couchdb-2.3.0.msi" @@ -72,6 +76,18 @@ try { exit 1 } +# Replace the default listening ports +# By default, CouchDB will be installed at C:\CouchDB. +# Port 5986 is already taken by WinRM +Write-Output "Changing default listening ports to 25984 and 25986 ..." +$couchDBConfigFile = Join-Path (Join-Path "C:\CouchDB" "etc") "default.ini" +((Get-Content -path $couchDBConfigFile -Raw) -replace "5984","25984") | Set-Content -Path $couchDBConfigFile +((Get-Content -path $couchDBConfigFile -Raw) -replace "5986","25986") | Set-Content -Path $couchDBConfigFile + +# In addition to that, we must restart CouchDB in order for the changes to take effect +Write-Output "Restarting CouchDB ..." +Restart-Service -Name "Apache CouchDB" + # Set-up CouchDB to run as a single node server as described # here: https://docs.couchdb.org/en/stable/setup/single-node.html Write-Output "Configuring CouchDB ..." @@ -79,22 +95,15 @@ try { # Let's retry the first request until CouchDB is ready. # When the maximum retries is reached, the error is propagated. # - $r1 = iwr-Retry -Method PUT -Uri http://127.0.0.1:5984/_users - $r2 = iwr -Method PUT -Uri http://127.0.0.1:5984/_replicator - $r3 = iwr -Method PUT -Uri http://127.0.0.1:5984/_global_changes + $r1 = iwr-Retry -Method PUT -Uri http://127.0.0.1:25984/_users + $r2 = iwr -Method PUT -Uri http://127.0.0.1:25984/_replicator + $r3 = iwr -Method PUT -Uri http://127.0.0.1:25984/_global_changes } catch { Write-Error "ERROR: CouchDB couldn't be configured. Error was $_" exit 1 } -# Replace the default listening port -# By default, CouchDB will be installed at C:\CouchDB. -Write-Output "Changing default listening port to 25984 ..." -$couchDBConfigFile = Join-Path (Join-Path "C:\CouchDB" "etc") "default.ini" -((Get-Content -path $couchDBConfigFile -Raw) -replace "5984","25984") | Set-Content -Path $couchDBConfigFile - -# In addition to that, we must restart CouchDB in order for the changes to take effect -Write-Output "Restarting CouchDB ..." +Write-Output "Restarting CouchDB again after been configured as a single node ..." Restart-Service -Name "Apache CouchDB" Write-Output "CouchDB is now installed and configured" From 019e5e99a0730c54b7d427ddb2e3fcc804b9e184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 17 Nov 2020 23:52:32 +0100 Subject: [PATCH 6/8] GPII-4517: Updated universal reference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7c01df3d..5bf0f436d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "0.3.0-dev.20200604T131823Z.d6fed9a", + "gpii-universal": "javihernandez/universal#f2972b9deeae48847a4ed951d1ab703b4e7bafc5", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0", From 5156e59ccaaabbf28e6a3da7d19778e5badd38bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Tue, 17 Nov 2020 23:53:07 +0100 Subject: [PATCH 7/8] GPII-4517: Updated workflow to run acceptance tests --- .github/workflows/node-tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/node-tests.yml b/.github/workflows/node-tests.yml index 5d4ba165e..6b2c14f10 100644 --- a/.github/workflows/node-tests.yml +++ b/.github/workflows/node-tests.yml @@ -15,6 +15,7 @@ jobs: node-mirror: "https://nodejs.org/download/release/" - uses: actions/checkout@v2 + - run: ./provisioning/CouchDB.ps1 - uses: actions/setup-python@v2 with: python-version: '2.7.17' @@ -37,3 +38,8 @@ jobs: - name: Run node unit tests run: node tests/UnitTests.js + + - name: Run Acceptance builtIn tests + env: + GPII_TEST_COUCH_USE_EXTERNAL: 1 + run: node tests/AcceptanceTests.js builtIn From 0e050b79fdc44708e9c686c67a72cbb3865cac03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 23 Nov 2020 13:00:19 +0100 Subject: [PATCH 8/8] GPII-4517: Updated universal reference This update includes the bits from https://github.com/GPII/universal/pull/886 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5bf0f436d..791163492 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "edge-js": "10.3.1", "ffi-napi": "2.4.3", - "gpii-universal": "javihernandez/universal#f2972b9deeae48847a4ed951d1ab703b4e7bafc5", + "gpii-universal": "0.3.0-dev.20201123T115346Z.7518d0e4f", "@pokusew/pcsclite": "0.4.18", "ref": "1.3.4", "ref-struct": "1.1.0",