Skip to content
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

GitHub actions build #5168

Merged
merged 11 commits into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from 9 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
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ bundle/bundle.out.js
.idea/
*.iml
my.env
my.*.env

*.env
static/bower_components/
.*.sw?
.DS_Store
Expand Down
7 changes: 7 additions & 0 deletions ci.test.env
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion lib/api3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions tests/fail.test.js
Original file line number Diff line number Diff line change
@@ -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);
});

});