Skip to content

GPII-4517: Added workflow for github actions #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/node-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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
- run: ./provisioning/CouchDB.ps1
- 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

- name: Pass linter
run: npx grunt lint

- name: Run node unit tests
run: node tests/UnitTests.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth trying a few acceptance tests? Do they run?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would run, but if we want to run them as they are we'd need to set up couchdb. I can definitely take a look if there's an easy way to set up couchdb in the github-hosted windows images. I think I can even take a look at creating a small github action that sets up couchdb on windows (I already did something similar for our vagrant boxes), but again, I'd need some time.

Another option would be to run the acceptanceTests against a file-based prefsServer, which I think it's not the way we want to test things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yeah, let me give a try at setting up couchdb, I'll keep you posted 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


- name: Run Acceptance builtIn tests
env:
GPII_TEST_COUCH_USE_EXTERNAL: 1
run: node tests/AcceptanceTests.js builtIn
10 changes: 8 additions & 2 deletions gpii/node_modules/gpii-localisation/test/testLanguage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gpii/node_modules/processHandling/test/testProcessHandling.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "0.3.0-dev.20201123T115346Z.7518d0e4f",
"@pokusew/pcsclite": "0.4.18",
"ref": "1.3.4",
"ref-struct": "1.1.0",
Expand Down
31 changes: 20 additions & 11 deletions provisioning/CouchDB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -72,29 +76,34 @@ 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 ..."
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"
Expand Down