Skip to content

Commit

Permalink
Merge branch 'master' into fgalan-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Nov 25, 2020
2 parents d09bf4b + 14d26d5 commit 4021af4
Show file tree
Hide file tree
Showing 49 changed files with 1,884 additions and 662 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# editorconfig.org
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true

[*.{json,yml,md,babelrc,eslintrc,remarkrc}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.{js}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "tamia",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"no-shadow": 0,
"valid-jsdoc": 0
}
}
101 changes: 101 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: CI
'on':
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint-dockerfile:
name: Lint Dockerfile
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Run Hadolint Dockerfile Linter
uses: burdzwastaken/hadolint-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HADOLINT_ACTION_DOCKERFILE_FOLDER: docker

lint-markdown:
name: Lint Markdown
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Run Remark Markdown Linter
run: |
npm install
npm run lint:md
- name: Run Textlint Markdown Linter
run: npm run lint:text

lint-code:
name: Lint JavaScript
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Run EsLint Node.js Linter
run: |
npm install
npm run lint
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:3.6
ports:
- 27017:27017
strategy:
matrix:
node-version:
- 10.x
- 12.x
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: 'Install Node.js ${{ matrix.node-version }}'
uses: actions/setup-node@v1
with:
node-version: '${{ matrix.node-version }}'
- name: 'Unit Tests with Node.js ${{ matrix.node-version }}'
run: |
npm install
npm test
code-coverage:
name: Coveralls Code Coverage
runs-on: ubuntu-latest
needs: unit-test
services:
mongodb:
image: mongo:3.6
ports:
- 27017:27017
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: 'Test Coverage with Node.js 12.x'
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: |
npm install
npm run test:coverage
- name: Push to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.idea/
/doc/
/coverage/
/.nyc_output/
/site
/report/
/.c9revisions/
Expand All @@ -13,3 +14,4 @@
.metadata
npm-debug.log
package-lock.json
.eslintcache
32 changes: 0 additions & 32 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .textlintrc
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@
]
}
}
}
}
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- Update Docker security practices (Add HEALTHCHECK, Use Anonymous User, Use two-stage build)
- Overall update of dev package dependencies
- Update codebase to use ES6
- Remove JSHint and jshint overrides
- Add esLint using standard tamia presets
- Replace var with let/const
- Fix or disable eslint errors
- Set Nodejs 10 as minimum version in packages.json (effectively removing Nodev8 from supported versions)
- Allow to configure id field in received callbacks from Sigfox
- Use nock lib to mock exchanges with a context broker during tests (and avoid depending on a running one)

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[![License: APGL](https://img.shields.io/github/license/telefonicaid/sigfox-iotagent.svg)](https://opensource.org/licenses/AGPL-3.0)
[![Docker badge](https://img.shields.io/docker/pulls/fiware/sigfox-iotagent.svg)](https://hub.docker.com/r/fiware/sigfox-iotagent/)
[![Support badge](https://nexus.lab.fiware.org/repository/raw/public/badges/stackoverflow/iot-agents.svg)](https://stackoverflow.com/questions/tagged/fiware+iot)
<br/> [![Documentation badge](https://img.shields.io/readthedocs/iotagent-sigfox.svg)](https://iotagent-sigfox.rtfd.io)
[![Build badge](https://img.shields.io/travis/telefonicaid/sigfox-iotagent.svg)](https://travis-ci.org/telefonicaid/sigfox-iotagent/)
<br/> [![Documentation badge](https://img.shields.io/readthedocs/iotagent-sigfox.svg)](https://iotagent-sigfox.readthedocs.io)
[![CI](https://github.com/telefonicaid/sigfox-iotagent/workflows/CI/badge.svg)](https://github.com/telefonicaid/sigfox-iotagent/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/telefonicaid/sigfox-iotagent/badge.svg?branch=master)](https://coveralls.io/github/telefonicaid/sigfox-iotagent?branch=master)
![Status](https://nexus.lab.fiware.org/repository/raw/public/badges/statuses/incubating.svg)

Expand All @@ -20,7 +20,7 @@ library's GitHub repository.
This project is part of [FIWARE](https://www.fiware.org/). For more information check the FIWARE Catalogue entry for the
[IoT Agents](https://github.com/Fiware/catalogue/tree/master/iot-agents).

| :books: [Documentation](https://iotagent-sigfox.rtfd.io) | :whale: [Docker Hub](https://hub.docker.com/r/fiware/sigfox-iotagent) | :dart: [Roadmap](https://github.com/telefonicaid/sigfox-iotagent/blob/master/doc/roadmap.md) |
| :books: [Documentation](https://iotagent-sigfox.readthedocs.io) | :whale: [Docker Hub](https://hub.docker.com/r/fiware/sigfox-iotagent) | :dart: [Roadmap](https://github.com/telefonicaid/sigfox-iotagent/blob/master/docs/roadmap.md) |
| -------------------------------------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |


Expand Down Expand Up @@ -75,8 +75,8 @@ Information about how to use the IoT Agent can be found in the [User & Programme
## API

Apiary reference for the Configuration API can be found
[here](http://docs.telefonicaiotiotagents.apiary.io/#reference/configuration-api) More information about IoT Agents and
their APIs can be found in the IoT Agent Library [documentation](https://iotagent-node-lib.rtfd.io/).
[here](https://telefonicaiotiotagents.docs.apiary.io/#reference/configuration-api) More information about IoT Agents and
their APIs can be found in the IoT Agent Library [documentation](https://iotagent-node-lib.readthedocs.io/).

## Testing

Expand Down
55 changes: 55 additions & 0 deletions bin/healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env node

/*
* Copyright 2020 Telefonica Investigación y Desarrollo, S.A.U
*
* This file is part of sigfox-iotagent
*
* sigfox-iotagent is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* sigfox-iotagent is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with sigfox-iotagent.
* If not, seehttp://www.gnu.org/licenses/.
*
* For those usages not covered by the GNU Affero General Public License
* please contact with::[daniel.moranjimenez at telefonica.com]
*/

const http = require('http');
const port = process.env.IOTA_NORTH_PORT || '4041';
const path = process.env.HEALTHCHECK_PATH || '/iot/about';
const httpCode = process.env.HEALTHCHECK_CODE || 200;

const options = {
host: 'localhost',
port,
timeout: 2000,
method: 'GET',
path
};

const request = http.request(options, (result) => {
// eslint-disable-next-line no-console
console.info(`Performed health check, result ${result.statusCode}`);
if (result.statusCode === httpCode) {
process.exit(0);
} else {
process.exit(1);
}
});

request.on('error', (err) => {
// eslint-disable-next-line no-console
console.error(`An error occurred while performing health check, error: ${err}`);
process.exit(1);
});

request.end();
20 changes: 12 additions & 8 deletions bin/iotagent-sigfox
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@
* For those usages not covered by the GNU Affero General Public License
* please contact with::[daniel.moranjimenez at telefonica.com]
*/
'use strict';

var iotAgent = require('../lib/iotagentCore'),
context = {
op: 'IoTAgentSIGFOX.Executable'
},
logger = require('logops');

const iotAgent = require('../lib/iotagentCore');
const iotAgentLib = require('iotagent-node-lib');
const info = require('../package.json');
const context = {
op: 'IoTAgentSIGFOX.Executable'
};
const logger = require('logops');

function start() {
var config;
let config;

if (process.argv.length === 3) {
config = require('../' + process.argv[2]);
} else {
config = require('../config');
}

iotAgent.start(config, function (error) {
config.iota.iotaVersion = info.version;

iotAgentLib.startServer(config, iotAgent, function (error) {
if (error) {
logger.error(context, 'Error starting Sigfox IoT Agent: [%s] Exiting process',
JSON.stringify(error));
Expand Down
Loading

0 comments on commit 4021af4

Please sign in to comment.