GitHub actions build (#5168)

* Run tests using GitHub Actions

* Node 10

* Test CI fails

* Use npm to run tests

* Fix package json to run tests

* Enable v3 TEST api for both development env and CI

* Run CI on both Node 10 and 12

* Allow downgrading Mongo
This commit is contained in:
Sulka Haro
2019-11-10 21:57:49 +00:00
committed by GitHub
parent 9877a5133e
commit 5bc6799e48
6 changed files with 58 additions and 3 deletions
+32
View File
@@ -0,0 +1,32 @@
name: CI test
on: [push]
jobs:
build:
runs-on: ubuntu-16.04
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Install MongoDB
run: |
wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt-get install -y --allow-downgrades mongodb-org=3.6.14 mongodb-org-server=3.6.14 mongodb-org-shell=3.6.14 mongodb-org-mongos=3.6.14 mongodb-org-tools=3.6.14
- name: Start MongoDB
run: sudo systemctl start mongod
- name: Run tests
run: npm run-script test-ci
+1 -1
View File
@@ -8,8 +8,8 @@ bundle/bundle.out.js
.idea/
*.iml
my.env
my.*.env
*.env
static/bower_components/
.*.sw?
.DS_Store
+7
View File
@@ -0,0 +1,7 @@
CUSTOMCONNSTR_mongo=mongodb://127.0.0.1:27017/testdb
API_SECRET=abcdefghij123
HOSTNAME=localhost
INSECURE_USE_HTTP=true
PORT=1337
NODE_ENV=production
CI=true
+2 -1
View File
@@ -59,6 +59,7 @@ function configure (env, ctx) {
app.set('version', env.version);
app.set('apiVersion', apiConst.API3_VERSION);
app.set('units', env.DISPLAY_UNITS);
app.set('ci', process.env['CI'] ? true: false);
app.set('enabledCollections', ['devicestatus', 'entries', 'food', 'profile', 'settings', 'treatments']);
self.setENVTruthy('API3_SECURITY_ENABLE', apiConst.API3_SECURITY_ENABLE);
@@ -73,7 +74,7 @@ function configure (env, ctx) {
app.get('/version', require('./specific/version')(app, ctx, env));
if (app.get('env') === 'development') { // for development and testing purposes only
if (app.get('env') === 'development' || app.get('ci')) { // for development and testing purposes only
app.get('/test', async function test (req, res) {
try {
+2 -1
View File
@@ -27,7 +27,8 @@
},
"scripts": {
"start": "node server.js",
"test": "env-cmd ./test.env mocha --exit tests/*.test.js",
"test": "env-cmd ./my.test.env mocha --exit tests/*.test.js",
"test-ci": "env-cmd ./ci.test.env mocha --exit tests/*.test.js",
"env": "env",
"postinstall": "webpack --mode production --config webpack.config.js && npm run-script update-buster",
"bundle": "webpack --mode production --config webpack.config.js && npm run-script update-buster",
+14
View File
@@ -0,0 +1,14 @@
'use strict';
require('should');
// This test is included just so we have an easy to template to intentionally cause
// builds to fail
describe('fail', function ( ) {
it('should not fail', function () {
true.should.equal(true);
});
});