Skip to content

Commit

Permalink
Add deploy job (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aschen authored Apr 7, 2021
1 parent 0a2555e commit ef4dc2c
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 13 deletions.
23 changes: 23 additions & 0 deletions .github/actions/dead-links/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Dead Links
description: Run Dead Links Tests
runs:
using: "composite"
steps:
- name: Install deps
run: npm ci
shell: bash
- name: Prepare documentation
run: npm run doc:prepare
shell: bash
- name: Install docs repositories
run: npx kuzdoc iterate-repos:install --repos_path doc/framework/.repos/
shell: bash
- name: Link kuzdoc
run: npx kuzdoc framework:link -d /official-plugins/device-manager/1/ -v 1
shell: bash
- name: Install typhoeus
run: sudo gem install typhoeus
shell: bash
- name: Run dead links tests
run: cd doc/framework/ && HYDRA_MAX_CONCURRENCY=20 ruby .ci/dead-links.rb -p src/official-plugins/device-manager/1/
shell: bash
53 changes: 53 additions & 0 deletions .github/actions/doc-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy Documentation
description: Build doc, upload it to S3 and invalidate Cloudfront cache

inputs:
AWS_ACCESS_KEY_ID:
description: AWS Access key ID
required: true
AWS_SECRET_ACCESS_KEY:
description: AWS secret key
required: true
S3_BUCKET:
description: S3 bucket name
required: true
CLOUDFRONT_ID:
description: Cloudfront distribution ID
required: true
REGION:
description: AWS default region
required: true
FRAMEWORK_BRANCH:
description: Documentation framework branch to use
required: true

runs:
using: "composite"
steps:
- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install python python-pip
pip install awscli --upgrade --user
shell: bash
- name: Build documentation
run: |
rm -rf doc/framework
npm install --production=false
npm run doc:prepare
npm run doc:build
env:
NODE_ENV: production
FRAMEWORK_BRANCH: ${{ inputs.FRAMEWORK_BRANCH }}
shell: bash
- name: Deploy documentation
run: |
npm run doc:upload
npm run doc:cloudfront
env:
AWS_DEFAULT_REGION: ${{ inputs.REGION }}
AWS_ACCESS_KEY_ID: ${{ inputs.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.AWS_SECRET_ACCESS_KEY }}
S3_BUCKET: ${{ inputs.S3_BUCKET }}
CLOUDFRONT_DISTRIBUTION_ID: ${{ inputs.CLOUDFRONT_ID }}
shell: bash
21 changes: 21 additions & 0 deletions .github/workflows/pull_request.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,24 @@ jobs:
with:
node-version: "12"
- uses: ./.github/actions/functional-test

documentation-dead-links:
name: Dead links
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v1.4.4
with:
node-version: "12"
- uses: ./.github/actions/dead-links
50 changes: 50 additions & 0 deletions .github/workflows/push_master.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,53 @@ jobs:
with:
node-version: "12"
- uses: ./.github/actions/functional-test

documentation-dead-links:
name: Dead links
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v1.4.4
with:
node-version: "12"
- uses: ./.github/actions/dead-links

documentation-production:
name: Deployment Doc Prod
runs-on: ubuntu-18.04
needs: [functional-tests, documentation-dead-links]
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v1
with:
node-version: "12"
- uses: ./.github/actions/doc-deploy
with:
REGION: us-west-2
S3_BUCKET: docs.kuzzle.io
CLOUDFRONT_ID: E3D6RP0POLCJMM
FRAMEWORK_BRANCH: master
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2 changes: 1 addition & 1 deletion doc/1/classes/decoder/decode/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: Decoder abstract class abstract decode() method

This method must be implemented in order to decode the payload.

It has to return a promise resolving to a [DeviceContent](/kuzzle-iot-platform/device-manager/1/types/device-content) with the following information:
It has to return a promise resolving to a [DeviceContent](/official-plugins/device-manager/1/types/device-content) with the following information:
- `reference`: device identifier
- `measures`: measures received in the payload
- `qos`: additional information about device state like battery, etc. (optional)
Expand Down
2 changes: 1 addition & 1 deletion doc/1/guides/assets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ By default, for each measurement type the following information are copied in ad
}
```

It is possible to override the [Decoder.copyToAsset](/kuzzle-iot-platform/device-manager/1/classes/decoder/copy-to-asset) method to choose what to copy into the asset.
It is possible to override the [Decoder.copyToAsset](/official-plugins/device-manager/1/classes/decoder/copy-to-asset) method to choose what to copy into the asset.
2 changes: 1 addition & 1 deletion doc/1/guides/decoders/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ You can then use lifecycle hooks to modify a payload while it's been processed
- `beforeUpdate`: Enrichment hook executed before updating a device
- `afterUpdate`: Hook executed after updating a device

See also: [Decoder abstract class](/kuzzle-iot-platform/device-manager/1/classes/decoder).
See also: [Decoder abstract class](/official-plugins/device-manager/1/classes/decoder).

## Saving raw payloads

Expand Down
10 changes: 5 additions & 5 deletions doc/1/guides/devices/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,28 @@ deviceManager.mappings.devices.measures = {

## Attach to a tenant

Devices can be attached to tenant by using the [device-manager/device:attach](/kuzzle-iot-platform/device-manager/1/controllers/device/attach) API action.
Devices can be attached to tenant by using the [device-manager/device:attach](/official-plugins/device-manager/1/controllers/device/attach) API action.

When attached, the device document is copied inside the `devices` collection of the tenant index.

## Attach to multiple tenant

Multiple different Devices can also be attached to multiple defferents tenant by using the [device-manager/device:mAttach](/kuzzle-iot-platform/device-manager/1/controllers/device/m-attach) API action.
Multiple different Devices can also be attached to multiple defferents tenant by using the [device-manager/device:mAttach](/official-plugins/device-manager/1/controllers/device/m-attach) API action.

The format used can be either __CSV__ in the form of a string in the format `tenantId,deviceId\nmytenantId,mydeviceId` or __JSON__ in the form of an array of objects `"records": [{ "tenantId": "mytenantId", "deviceId": "mydeviceId"}]`.

When attached, all devices documents are copied inside the `devices` collections of all different tenant index.

## Detach a sensor from a tenant

Sensors can be detached to tenant by using the [device-manager/sensor:detach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/detach) API action.
Sensors can be detached to tenant by using the [device-manager/sensor:detach](/official-plugins/device-manager/1/controllers/sensor/detach) API action.

When detached, the sensor document is deleted from the `sensors` collection of the tenant index.

the `tenantId` property is set to `null` in the `device-manager` index.
## Detach multiple sensors from multiple tenants

Multiple different Sensors can also be detached to multiple defferents tenant by using the [device-manager/sensor:mDetach](/kuzzle-iot-platform/device-manager/1/controllers/sensor/mDetach) API action.
Multiple different Sensors can also be detached to multiple defferents tenant by using the [device-manager/sensor:mDetach](/official-plugins/device-manager/1/controllers/sensor/mDetach) API action.

The format used can be either __CSV__ in the form of a string in the format "tenantId,sensorId,mysensorId" or __JSON__ in the form of an array of objects.

Expand All @@ -137,7 +137,7 @@ The `tenantId` property is set to `null` for all of them in the `device-manager`

## Link to an asset

Devices can be linked to an asset by using the [device-manager/device:link](/kuzzle-iot-platform/device-manager/1/controllers/device/link) API action.
Devices can be linked to an asset by using the [device-manager/device:link](/official-plugins/device-manager/1/controllers/device/link) API action.

When linked, the device measures are copied inside the asset document.

Expand Down
2 changes: 1 addition & 1 deletion doc/1/guides/multi-tenancy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The plugin is designed to work with several tenants, each with their own devices

Each tenant has its own index with the required collections.

It is possible to manage its holders with the [device-manager/engine](/kuzzle-iot-platform/device-manager/1/controllers/engine) controller.
It is possible to manage its holders with the [device-manager/engine](/official-plugins/device-manager/1/controllers/engine) controller.

::: info
When used with the multi-tenant plugin, the collections needed by the device-manager are automatically created when creating a new tenant with the multi-tenant plugin.
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"clean": "touch index.ts && npm run build | grep TSFILE | cut -d' ' -f 2 | xargs rm",
"package:create": "npm run build && npm pack",
"doc:prepare": "npx kuzdoc framework:install",
"doc:dev": "npx kuzdoc repo:dev -d /kuzzle-iot-platform/device-manager/1/ -v 1",
"doc:build": "npx kuzdoc repo:build -d /kuzzle-iot-platform/device-manager/1/ -v 1",
"doc:upload": "npx kuzdoc repo:deploy -d /kuzzle-iot-platform/device-manager/1/ -v 1",
"doc:cloudfront": "npx kuzdoc repo:cloudfront -d /kuzzle-iot-platform/device-manager/1/*",
"doc:dev": "npx kuzdoc repo:dev -d /official-plugins/device-manager/1/ -v 1",
"doc:build": "npx kuzdoc repo:build -d /official-plugins/device-manager/1/ -v 1",
"doc:upload": "npx kuzdoc repo:deploy -d /official-plugins/device-manager/1/ -v 1",
"doc:cloudfront": "npx kuzdoc repo:cloudfront -d /official-plugins/device-manager/1/*",
"doc:deploy": "npm run doc:upload && npm run doc:cloudfront"
},
"license": "Apache-2.0",
Expand Down

0 comments on commit ef4dc2c

Please sign in to comment.