Skip to content

Commit

Permalink
Merge pull request #6650 from nightscout/dev
Browse files Browse the repository at this point in the history
Release 14.1.0
  • Loading branch information
sulkaharo authored Jan 6, 2021
2 parents 695e98b + 46e4d17 commit 3eeacc3
Show file tree
Hide file tree
Showing 146 changed files with 20,891 additions and 17,923 deletions.
113 changes: 86 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,93 @@
name: CI test
name: CI test and publish Docker image

on: [push, pull_request]
on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev

jobs:
build:

runs-on: ubuntu-16.04

test:
name: Run Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
node-version: [12.x, 14.x]
mongodb-version: [4.2, 4.4]

steps:
- name: Git Checkout
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB ${{ matrix.mongodb-version }}
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Install dependencies
run: npm install
- name: Run Tests
run: npm run-script test-ci
- name: Send Coverage
run: npm run-script coverage

publish_dev:
name: Publish dev branch to Docker Hub
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
env:
DOCKER_IMAGE: nightscout/cgm-remote-monitor
steps:
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Clean git Checkout
if: success()
uses: actions/checkout@v2
- name: Build, tag and push the dev Docker image
if: success()
run: |
docker build --no-cache=true -t ${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }} .
docker image push ${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }}
docker tag ${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }} ${{ env.DOCKER_IMAGE }}:latest_dev
docker image push ${{ env.DOCKER_IMAGE }}:latest_dev
publish_master:
name: Publish master branch to Docker Hub
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
env:
DOCKER_IMAGE: nightscout/cgm-remote-monitor
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-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt-get install -y --allow-downgrades mongodb-org=4.4.0 mongodb-org-server=4.4.0 mongodb-org-shell=4.4.0 mongodb-org-mongos=4.4.0 mongodb-org-tools=4.4.0
- name: Start MongoDB
run: sudo systemctl start mongod
- name: Run Tests
run: npm run-script test-ci
- name: Send Coverage
run: npm run-script coverage
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Clean git Checkout
if: success()
uses: actions/checkout@v2
- name: get-npm-version
if: success()
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: Build, tag and push the master Docker image
if: success()
run: |
docker build --no-cache=true -t ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }} .
docker image push ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }}
docker tag ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }} ${{ env.DOCKER_IMAGE }}:latest
docker image push ${{ env.DOCKER_IMAGE }}:latest
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.16.0
14.15.3
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

42 changes: 4 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
- [List of Contributors](#list-of-contributors)
- [Core developers, contributing developers, coordinators and documentation writers](#core-developers-contributing-developers-coordinators-and-documentation-writers)
- [Plugin contributors](#plugin-contributors)
- [Translators](#translators)
- [List of all contributors](#list-of-all-contributors)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand All @@ -36,6 +35,10 @@
[discord-img]: https://img.shields.io/discord/629952586895851530?label=discord%20chat
[discord-url]: https://discord.gg/rTKhrqz

## Translations

Please visit our [project in Crowdin](https://crowdin.com/project/nightscout) to translate Nigthscout. If you want to add a new language, please get in touch with the dev team in [Discord][discord-url].

## Installation for development

Nightscout is a Node.js application. The basic installation of the software for local purposes is:
Expand Down Expand Up @@ -188,8 +191,6 @@ Also if you can't code, it's possible to contribute by improving the documentati
| Core developers: | [@jasoncalabrese] [@MilosKozak] [@PieterGit] [@sulkaharo] |
| Former Core developers: (not active): | [@bewest] |
| Contributing developers: | [@jpcunningh] [@scottleibrand] [@komarserjio] [@jweismann] |
| Release coordination 0.10.x: | [@PieterGit] [@sulkaharo] |
| Release coordination 0.11.x: | [@PieterGit] |
| Issue/Pull request coordination: | Please volunteer |
| Cleaning up git fork spam: | Please volunteer |
| Documentation writers: | [@andrew-warrington] [@unsoluble] [@tynbendad] [@danamlewis] [@rarneson] |
Expand Down Expand Up @@ -230,41 +231,6 @@ Also if you can't code, it's possible to contribute by improving the documentati
| [`upbat` (Uploader Battery)](README.md#upbat-uploader-battery)| [@jpcunningh] | Please volunteer |
| [`xdrip-js` (xDrip-js)](README.md#xdrip-js-xdrip-js)| [@jpcunningh] | Please volunteer |
### Translators
See `/translations` of your Nightscout, to view the current translation coverage and the missing items.
Languages with less than 90% coverage will be removed in a future Nightscout versions.
| Language | List of translators | Status
| ------------- | -------------------- |-------------------- |
| Български (`bg`) |Please volunteer| OK |
| Čeština (`cs`) |Please volunteer|OK |
| Deutsch (`de`) |[@viderehh] [@herzogmedia] |OK |
| Dansk (`dk`) | [@janrpn] |OK |
| Ελληνικά (`el`)|Please volunteer|Needs attention: 68.5%|
| English (`en`)|Please volunteer|OK|
| Español (`es`) |Please volunteer|OK|
| Suomi (`fi`)|[@sulkaharo] |OK|
| Français (`fr`)|Please volunteer|OK|
| עברית (`he`)| [@jakebloom] |OK|
| Hrvatski (`hr`)|[@OpossumGit]|OK|
| Italiano (`it`)|Please volunteer|OK|
| 日本語 (`ja`)|[@LuminaryXion]|Working on this|
| 한국어 (`ko`)|Please volunteer|Needs attention: 80.6%|
| Norsk (Bokmål) (`nb`)|Please volunteer|OK|
| Nederlands (`nl`)|[@PieterGit]|OK|
| Polski (`pl`)|[@Bartlomiejsz]|OK|
| Português (Brasil) (`pt`)|Please volunteer|OK|
| Română (`ro`)|Please volunteer|OK|
| Русский (`ru`)|[@apanasef]|OK|
| Slovenčina (`sk`)|Please volunteer|OK|
| Svenska (`sv`)|Please volunteer|OK|
| Türkçe (`tr`)|[@diabetlum]|OK|
| 中文(简体) (`zh_cn`) | [@jizhongwen]|OK|
| 中文(繁體) (`zh_tw`) | [@jizhongwen]|Needs attention: 25.0%
| 日本語 (`ja_jp`) | [@LuminaryXion]|
### List of all contributors
| Contribution area | List of contributors |
| ------------------------------------- | -------------------- |
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.example → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:10-alpine
FROM node:14.15.3-alpine

MAINTAINER Nightscout Contributors
LABEL maintainer="Nightscout Contributors"

RUN mkdir -p /opt/app
ADD . /opt/app
Expand Down
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MONGO_SETTINGS=MONGO_CONNECTION=${MONGO_CONNECTION} \
# coverage reporter's ability to instrument the tests correctly.
# Hard coding it to the local with our pinned version is bigger for
# initial installs, but ensures a consistent environment everywhere.
# On Travis, ./node_modules/.bin and other `nvm` and `npm` bundles are
# On GA, ./node_modules/.bin and other `nvm` and `npm` bundles are
# inserted into the default `$PATH` enviroinment, making pointing to
# the unwrapped mocha executable necessary.
MOCHA=./node_modules/mocha/bin/_mocha
Expand All @@ -25,7 +25,7 @@ ANALYZED=./coverage/lcov.info
# Following token deprecated
# export CODACY_REPO_TOKEN=e29ae5cf671f4f918912d9864316207c

DOCKER_IMAGE=nightscout/cgm-remote-monitor-travis
DOCKER_IMAGE=nightscout/cgm-remote-monitor

all: test

Expand All @@ -48,7 +48,7 @@ test_onebyone:
test:
${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap ${TESTS}

travis:
ci_tests:
python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
# NODE_ENV=test ${MONGO_SETTINGS} \
# ${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}
Expand All @@ -57,28 +57,25 @@ travis:
docker_release:
# Get the version from the package.json file
$(eval DOCKER_TAG=$(shell cat package.json | jq '.version' | tr -d '"'))
$(eval NODE_VERSION=$(shell cat .nvmrc))
$(eval BRANCH=$(lastword $(subst /, ,$(GITHUB_REF))))
#
# Create a Dockerfile that contains the correct NodeJS version
cat Dockerfile.example | sed -e "s/^FROM node:.*/FROM node:${NODE_VERSION}/" > Dockerfile
#
# Rebuild the image. We do this with no-cache so that we have all security upgrades,
# since that's more important than fewer layers in the Docker image.
docker build --no-cache=true -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
# Push an image to Docker Hub with the version from package.json:
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
#
# Push the master branch to Docker hub as 'latest'
if [ "$(TRAVIS_BRANCH)" = "master" ]; then \
if [ "$(BRANCH)" = "master" ]; then \
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest && \
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest; \
fi
#
# Push the dev branch to Docker Hub as 'latest_dev'
if [ "$(TRAVIS_BRANCH)" = "dev" ]; then \
if [ "$(BRANCH)" = "dev" ]; then \
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest_dev && \
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest_dev; \
fi
rm -f Dockerfile

.PHONY: all coverage docker_release report test travis
.PHONY: all coverage docker_release report test ci_tests
9 changes: 4 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ function create (env, ctx) {
// serve the static content
app.use(staticFiles);

app.use('/translations', express.static('translations', {
maxAge
}));

if (ctx.bootErrors && ctx.bootErrors.length > 0) {
const bootErrorView = require('./lib/server/booterror')(env, ctx);
bootErrorView.setLocals(app.locals);
Expand Down Expand Up @@ -220,11 +224,6 @@ function create (env, ctx) {
, title: 'Nightscout reporting'
, type: 'report'
}
, "/translations": {
file: "translationsindex.html"
, title: 'Nightscout translations'
, type: 'translations'
}
, "/split": {
file: "frame.html"
, title: '8-user view'
Expand Down
7 changes: 5 additions & 2 deletions bundle/bundle.reports.source.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import './bundle.source';

window.Nightscout.report_plugins = require('../lib/report_plugins/')();
console.info('Nightscout report bundle start');

window.Nightscout.report_plugins_preinit = require('../lib/report_plugins/');
window.Nightscout.predictions = require('../lib/report/predictions');
window.Nightscout.reportclient = require('../lib/report/reportclient');

console.info('Nightscout report bundle ready');

// Needed for Hot Module Replacement
if(typeof(module.hot) !== 'undefined') {
module.hot.accept()
}
}
2 changes: 1 addition & 1 deletion bundle/bundle.source.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ console.info('Nightscout bundle ready');
// Needed for Hot Module Replacement
if(typeof(module.hot) !== 'undefined') {
module.hot.accept()
}
}
3 changes: 3 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
files:
- source: /translations/en/*.json
translation: /translations/%locale_with_underscore%.json
2 changes: 1 addition & 1 deletion docs/plugins/alexa-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ If you use Authentication Roles, you will need to add a token to the end of your
1. In your Nightscout Admin Tools, add a new subject and give it the "readable" role.
- If you **really** would like to be super specific, you could create a new role and set the permissions to `api:*:read`.
1. After the new subject is created, copy the "Access Token" value for the new row in your subject table (**don't** copy the link, just copy the text).
1. At the end of your Nighscout URL, add `?token={yourtoken}`, where `{yourtoken}` is the Access Token you just copied. Your new URL should look like `https://{yourdomain}/api/v1/googlehome?token={yourtoken}`.
1. At the end of your Nighscout URL, add `?token={yourtoken}`, where `{yourtoken}` is the Access Token you just copied. Your new URL should look like `https://{yourdomain}/api/v1/alexa?token={yourtoken}`.

### Test your skill out with the test tool

Expand Down
Binary file added docs/plugins/google-home-templates/de-DE.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/admin_plugins/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = init;
var $status = null;

roles.actions = [{
description: 'Each role will have a 1 or more permissions. The <em>*</em> permission is a wildcard, permissions are a hierarchy using <em>:</em> as a seperator.'
description: 'Each role will have a 1 or more permissions. The <em>*</em> permission is a wildcard, permissions are a hierarchy using <em>:</em> as a separator.'
, buttonLabel: 'Add new Role'
, init: function init (client, callback) {
$status = $('#admin_' + roles.name + '_0_status');
Expand Down
4 changes: 3 additions & 1 deletion lib/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ function create (env, ctx) {
// Only allow access to the API if API_SECRET is set on the server.
app.disable('api');
if (env.api_secret) {
console.log('API_SECRET', env.api_secret);
console.log('API_SECRET present, enabling API');
app.enable('api');
} else {
console.log('API_SECRET not found, API disabled');
}

if (env.settings.enable) {
Expand Down
6 changes: 5 additions & 1 deletion lib/api/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function configure (app, wares, env, ctx) {

var authToken = req.query.token || req.query.secret || '';

function getRemoteIP (req) {
return req.headers['x-forwarded-for'] || req.connection.remoteAddress;
}

var date = new Date();
var info = { status: 'ok'
, name: app.get('name')
Expand All @@ -31,7 +35,7 @@ function configure (app, wares, env, ctx) {
, boluscalcEnabled: app.enabled('api') && env.settings.enable.indexOf('boluscalc') > -1
, settings: settings
, extendedSettings: extended
, authorized: ctx.authorization.authorize(authToken)
, authorized: ctx.authorization.authorize(authToken, getRemoteIP(req))
, runtimeState: ctx.runtimeState
};

Expand Down
Loading

0 comments on commit 3eeacc3

Please sign in to comment.