From 0116f6acd3f5d5ad5312c9b971728ea27feedd7b Mon Sep 17 00:00:00 2001 From: ubergesundheit Date: Wed, 21 Feb 2018 12:59:54 +0100 Subject: [PATCH] run tests by travis, hopefully fix apidoc build --- .dockerignore | 2 ++ .npmignore | 3 +++ .scripts/deploy-docs.sh | 9 +++++---- .scripts/run-tests.sh | 4 ++-- .travis.yml | 18 +++++++++++------- apidoc.json | 25 +++++++++++++++++++++++++ apidoc/introduction.md | 32 ++++++++++++++++++++++++++++++++ package.json | 21 --------------------- 8 files changed, 80 insertions(+), 34 deletions(-) create mode 100644 apidoc.json create mode 100644 apidoc/introduction.md diff --git a/.dockerignore b/.dockerignore index bb4532e4..b80fafff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -15,3 +15,5 @@ version.js *.log .github tests +apidoc +apidoc.json diff --git a/.npmignore b/.npmignore index 4ad7a158..2ad1dc4b 100644 --- a/.npmignore +++ b/.npmignore @@ -21,3 +21,6 @@ mongo-data .env doc/ version.js + +apidoc +apidoc.json diff --git a/.scripts/deploy-docs.sh b/.scripts/deploy-docs.sh index 2f84f151..fdd7bbb9 100755 --- a/.scripts/deploy-docs.sh +++ b/.scripts/deploy-docs.sh @@ -3,10 +3,8 @@ set -euo pipefail IFS=$'\n\t' -currentBranch=$(git branch | grep -e "^*" | cut -d' ' -f 2) - -if [ "$currentBranch" != "master" ]; then - echo "Docs can only be built from 'master' branch" +if [[ -n "${TRAVIS_TAG}" ]]; then + echo "Docs can only be built from tags" exit 0 fi @@ -16,6 +14,9 @@ cd "$TRAVIS_BUILD_DIR" # install apidocs npm install -g apidoc@0.17.6 +# append the current version +sed -i "1 s|$| ${TRAVIS_TAG}|" apidoc/introduction.md + # run apidoc apidoc -i . -f js -e node_modules diff --git a/.scripts/run-tests.sh b/.scripts/run-tests.sh index bb204704..cae940fb 100755 --- a/.scripts/run-tests.sh +++ b/.scripts/run-tests.sh @@ -36,8 +36,8 @@ case "$cmd" in esac mailer_tag=$(git rev-parse --abbrev-ref HEAD) -if [[ "$mailer_tag" == "master" || "$mailer_tag" == "development" ]]; then - export SENSEBOX_MAILER_TAG="$mailer_tag" +if [[ "$mailer_tag" == "master" ]]; then + export SENSEBOX_MAILER_TAG="latest" else export SENSEBOX_MAILER_TAG="development" fi diff --git a/.travis.yml b/.travis.yml index b9983b24..3364d4a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,21 @@ -sudo: false +sudo: required + +services: + - docker + +git: + depth: 1 language: node_js node_js: - - "6" + - "8" install: true -script: ./.scripts/deploy-docs.sh +script: +- ./.scripts/run-tests.sh +- ./.scripts/deploy-docs.sh env: global: - GITHUB_REPO: "sensebox/openSenseMap-API" - secure: "B1S19gMUgYsGSDcQGu9iXyC2Gv/I0Saw64cthMPXck4Scbog6vAQ4b8Zp2LvgcnfYGv+714KCrv1AunF0xdt/7CNi4426cyvmB8uNV5fZRaSrCq6iWOzqI616OLY7jwJ7Fu21PL7RgwZjoe4JKxY8XoSqnoDdZgclblL96ALfSY=" - -branches: - only: - - master diff --git a/apidoc.json b/apidoc.json new file mode 100644 index 00000000..8f7dff95 --- /dev/null +++ b/apidoc.json @@ -0,0 +1,25 @@ +{ + "name": "", + "title": "openSenseMap API documentation", + "url": "https://api.opensensemap.org", + "order": [ + "register", + "getBox", + "getBoxes", + "postNewBox", + "updateBox", + "deleteBox", + "getScript", + "postNewMeasurement", + "getMeasurements", + "getData", + "calculateIdw" + ], + "template": { + "withCompare": false + }, + "header": { + "title": "Introduction", + "filename": "apidoc/introduction.md" + } +} diff --git a/apidoc/introduction.md b/apidoc/introduction.md new file mode 100644 index 00000000..1c543a29 --- /dev/null +++ b/apidoc/introduction.md @@ -0,0 +1,32 @@ +![openSenseMap API](https://raw.githubusercontent.com/sensebox/resources/master/images/openSenseMap_API_github.png) + +
Documentation of the routes and methods to manage [users](#api-Users), [stations (also called boxes or senseBoxes)](#api-Boxes), and [measurements](#api-Measurements) in the openSenseMap API. +You can find the API running at [https://api.opensensemap.org/](https://api.opensensemap.org/). + +## Timestamps + +Please note that the API handles every timestamp in [Coordinated universal time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) time zone. Timestamps in parameters should be in RFC 3339 notation. + +Timestamp without Milliseconds: + + 2018-02-01T23:18:02Z + +Timestamp with Milliseconds: + + 2018-02-01T23:18:02.412Z + +## IDs + +All stations and sensors of stations receive a unique public identifier. These identifiers are exactly 24 character long and only contain digits and characters a to f. + +Example: + + 5a8d1c25bc2d41001927a265 + +## Source code and Licenses + +You can find the whole source code of the API at GitHub in the [sensebox/openSenseMap-API](https://github.com/sensebox/openSenseMap-API) repository. You can obtain the code under the MIT License. + +The data obtainable through the openSenseMap API at [https://api.opensensemap.org/](https://api.opensensemap.org/) is licensed under the [Public Domain Dedication and License 1.0](https://opendatacommons.org/licenses/pddl/summary/). + +If you there is something unclear or there is a mistake in this documentation please open an [issue](https://github.com/sensebox/openSenseMap-API/issues/new) in the GitHub repository. diff --git a/package.json b/package.json index c0ba6103..67b0732e 100644 --- a/package.json +++ b/package.json @@ -27,26 +27,5 @@ "mocha": "^5.0.0", "mqtt": "^2.15.1", "randomgeojson": "^1.0.0" - }, - "apidoc": { - "name": "openSenseMap API documentation", - "description": "methods to manage senseBoxes and get/post measurements", - "title": "openSenseMap API documentation", - "url": "https://api.opensensemap.org", - "order": [ - "getBox", - "getBoxes", - "postNewBox", - "updateBox", - "deleteBox", - "getScript", - "postNewMeasurement", - "getMeasurements", - "getData", - "calculateIdw" - ], - "template": { - "withCompare": false - } } }