-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update grpc and mqtt dependencies (#7)
* Update grpc and mqtt packages * Update grpc server start * update mosquitto and fix tests * Use beta release of osem api models * Set options close to old grpc.load * Add ghcr workflows * Update build workflow * Add tests for mqtts and ws * Add config parameter for mqtts test url * Add lint and test jobs * Build image only if lint and build was successful * Fix workflow error * Set env variable for mqtts test client * Update on push expression
- Loading branch information
Showing
18 changed files
with
1,322 additions
and
1,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: Build and publish to Github Container Registry | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
tags: [ 'v*.*.*' ] | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
|
||
lint: | ||
name: Lint code | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node.js 14 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: | | ||
echo "##[set-output name=dir;]$(yarn cache dir)" | ||
- name: Restore yarn cache | ||
uses: actions/cache@v2.1.6 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install project dependencies | ||
run: | | ||
yarn --prefer-offline --pure-lockfile | ||
- name: Run eslint | ||
run: | | ||
yarn run lint:ci | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Node.js 14 | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: | | ||
echo "##[set-output name=dir;]$(yarn cache dir)" | ||
- name: Restore yarn cache | ||
uses: actions/cache@v2.1.6 | ||
id: yarn-cache | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install project dependencies | ||
run: | | ||
yarn --prefer-offline --pure-lockfile | ||
- name: Execute tests | ||
run: | | ||
export MQTTS_TEST_URL=${{ secrets.MQTTS_URL }} | ||
yarn test | ||
build-and-push-images: | ||
runs-on: ubuntu-latest | ||
# Depends on lint and test jobs | ||
needs: [lint, test] | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
flavor: | | ||
latest=auto | ||
prefix= | ||
suffix= | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Purge Pull Request Image | ||
|
||
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#registry_package | ||
# Run cleanup job if a new package was published or updated | ||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
purge_pr_image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Purge Pull Request Image | ||
uses: vlaurin/action-ghcr-prune@v0.1.0 | ||
with: | ||
token: ${{ secrets.GHCR_TOKEN}} | ||
organization: ${{ github.repository_owner}} | ||
container: ${{ github.event.repository.name }} | ||
tag-regex: /^pr-${{github.event.pull_request.number}}$/ | ||
dry-run: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Docker Registry Cleanup | ||
|
||
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#registry_package | ||
# Run cleanup job if a new package was published or updated | ||
on: | ||
registry_package: | ||
|
||
jobs: | ||
purge_untagged_images: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: clean packages | ||
uses: vlaurin/action-ghcr-prune@v0.1.0 | ||
with: | ||
token: ${{ secrets.GHCR_TOKEN}} | ||
organization: ${{ github.repository_owner}} | ||
container: ${{ github.event.repository.name }} | ||
untagged: true | ||
dry-run: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,8 @@ | |
"server_cert": "", | ||
"server_key": "" | ||
} | ||
}, | ||
"mqtts_test_client:": { | ||
"url": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const config = require('config').get('mqtts_test_client'); | ||
|
||
module.exports = function mqttsBox ( | ||
// parameter destructuring | ||
{ enabled, url, topic, connectionOptions, decodeOptions, messageFormat } = { | ||
// defaults | ||
enabled: true, | ||
url: config.get('url'), | ||
topic: 'generalTestTopic', | ||
messageFormat: 'csv', | ||
} | ||
) { | ||
return { | ||
name: 'mqttsTestSenseBox', | ||
location: [7.62, 51.96], | ||
exposure: 'outdoor', | ||
model: 'homeEthernet', | ||
mqtt: { | ||
enabled, | ||
url, | ||
topic, | ||
connectionOptions, | ||
decodeOptions, | ||
messageFormat, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.