Compare commits

..

13 Commits

Author SHA1 Message Date
semantic-release-bot
49a8693fc0 chore(release): 1.7.5 [skip ci]
## [1.7.5](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.4...v1.7.5) (2021-05-09)

### Build

* push all tags instead of just latest ([b143379](b143379f20))
2021-05-09 03:55:28 +00:00
b143379f20 Build: push all tags instead of just latest 2021-05-09 03:53:17 +00:00
semantic-release-bot
534a8b805e chore(release): 1.7.4 [skip ci]
## [1.7.4](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.3...v1.7.4) (2021-05-09)

### Build

* cleanup long install line ([de1d073](de1d073c6d))

### ci

* Add git to node image ([6eb2d01](6eb2d0145e))
* change semantic release image to alpine to save space, updated to node 16 ([b1ca049](b1ca0497b0))
* Update DinD base to 20.10.6 and semantic release to node:15.  Also pin sonar-scanner-cli to 4.6 ([589fb4f](589fb4fcf7))
2021-05-09 03:44:55 +00:00
de1d073c6d Build: cleanup long install line 2021-05-09 03:42:44 +00:00
d3e34871aa Update .releaserc.yml 2021-05-09 03:35:18 +00:00
3e8aead632 Update .releaserc.yml 2021-05-09 03:27:45 +00:00
9498554758 Merge branch 'update-semantic-release' into 'master'
Update semantic release

See merge request erichardson/py-eagle-mqtt!4
2021-05-09 03:24:02 +00:00
c2167d5d97 Update semantic release 2021-05-09 03:24:02 +00:00
6eb2d0145e ci: Add git to node image 2021-05-09 03:01:59 +00:00
b1ca0497b0 ci: change semantic release image to alpine to save space, updated to node 16 2021-05-09 02:48:42 +00:00
589fb4fcf7 ci: Update DinD base to 20.10.6 and semantic release to node:15. Also pin sonar-scanner-cli to 4.6 2021-05-09 02:41:44 +00:00
51213c51e0 Merge branch 'add-trivy-scanner' into 'master'
Add Trivy scanner stage

See merge request erichardson/py-eagle-mqtt!3
2021-05-09 02:37:51 +00:00
da20bbe045 Add Trivy scanner stage 2021-05-09 02:37:51 +00:00
5 changed files with 168 additions and 103 deletions

View File

@@ -11,12 +11,14 @@ stages:
- push_dockerhub - push_dockerhub
.docker_base: .docker_base:
image: docker:18.09.7-dind image: docker:20.10.6-dind
services: services:
- docker:18.09.7-dind - name: docker:20.10.6-dind
command: ["--tls=false"]
variables: variables:
DOCKER_DRIVER: overlay DOCKER_DRIVER: overlay
DOCKER_HOST: tcp://localhost:2375/ DOCKER_HOST: tcp://127.0.0.1:2375/
DOCKER_TLS_CERTDIR: ""
IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
FF_GITLAB_REGISTRY_HELPER_IMAGE: 1 FF_GITLAB_REGISTRY_HELPER_IMAGE: 1
before_script: before_script:
@@ -68,10 +70,10 @@ push dockerhub:
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:latest - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_DOCKERHUB_IMAGE:latest
- docker login -u "$CI_DOCKERHUB_USER" -p "$CI_DOCKERHUB_PASSWORD" $CI_DOCKERHUB_REGISTRY - docker login -u "$CI_DOCKERHUB_USER" -p "$CI_DOCKERHUB_PASSWORD" $CI_DOCKERHUB_REGISTRY
- docker push $CI_DOCKERHUB_IMAGE - docker push $CI_DOCKERHUB_IMAGE --all-tags
release: release:
image: node:13 image: node:16-alpine3.13
stage: release stage: release
only: only:
refs: refs:
@@ -83,7 +85,9 @@ release:
- /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ - /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
script: script:
- touch CHANGELOG.md - touch CHANGELOG.md
- npm install @semantic-release/gitlab @semantic-release/changelog @semantic-release/git - apk add --no-cache git
- npm install @semantic-release/gitlab @semantic-release/changelog
@semantic-release/git conventional-changelog-eslint
- npx semantic-release - npx semantic-release
artifacts: artifacts:
paths: paths:
@@ -95,8 +99,9 @@ include:
- template: Security/SAST.gitlab-ci.yml - template: Security/SAST.gitlab-ci.yml
sonarqube-check: sonarqube-check:
stage: test
image: image:
name: sonarsource/sonar-scanner-cli:latest name: sonarsource/sonar-scanner-cli:4.6
entrypoint: [""] entrypoint: [""]
variables: variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
@@ -110,3 +115,30 @@ sonarqube-check:
allow_failure: true allow_failure: true
only: only:
- master # or the name of your main branch - master # or the name of your main branch
- branches
trivy:
stage: test
extends:
- .docker_base
before_script:
- export TRIVY_VERSION=$(wget -qO - "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
- echo $TRIVY_VERSION
- wget --no-verbose https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz -O - | tar -zxvf -
allow_failure: true
script:
# Build image
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA ./Docker/
# Build report
- ./trivy --exit-code 0 --cache-dir .trivycache/ --no-progress --format template --template "@contrib/gitlab.tpl" -o gl-container-scanning-report.json image $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# Print report
- ./trivy --exit-code 0 --cache-dir .trivycache/ --no-progress --severity HIGH image $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# Fail on severe vulnerabilities
- ./trivy --exit-code 1 --cache-dir .trivycache/ --severity CRITICAL --no-progress image $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
cache:
paths:
- .trivycache/
# Enables https://docs.gitlab.com/ee/user/application_security/container_scanning/ (Container Scanning report is available on GitLab EE Ultimate or GitLab.com Gold)
artifacts:
reports:
container_scanning: gl-container-scanning-report.json

View File

@@ -1,6 +1,38 @@
plugins: plugins:
- "@semantic-release/commit-analyzer" - - "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator" - preset: eslint
releaseRules:
- tag: Breaking
release: major
- tag: Build
release: patch
- tag: Chore
release: minor
- tag: Fix
release: patch
- tag: New
release: minor
- tag: Update
release: minor
- tag: Upgrade
release: minor
- - "@semantic-release/release-notes-generator"
- preset: eslint
releaseRules:
- tag: Breaking
release: major
- tag: Build
release: patch
- tag: Chore
release: minor
- tag: Fix
release: patch
- tag: New
release: minor
- tag: Update
release: minor
- tag: Upgrade
release: minor
- - "@semantic-release/changelog" - - "@semantic-release/changelog"
- changelogFile: CHANGELOG.md - changelogFile: CHANGELOG.md
- "@semantic-release/gitlab" - "@semantic-release/gitlab"

View File

@@ -1,3 +1,23 @@
## [1.7.5](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.4...v1.7.5) (2021-05-09)
### Build
* push all tags instead of just latest ([b143379](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/b143379f2018f410677a9646234e7b483d9277d3))
## [1.7.4](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.3...v1.7.4) (2021-05-09)
### Build
* cleanup long install line ([de1d073](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/de1d073c6daf5d43fb7d9b7dafddd3b0cbcffc9b))
### ci
* Add git to node image ([6eb2d01](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/6eb2d0145eff50c3243a364d821e769ae2ee06c9))
* change semantic release image to alpine to save space, updated to node 16 ([b1ca049](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/b1ca0497b0b51e0c50ca1e5f99e5c8abd4224d53))
* Update DinD base to 20.10.6 and semantic release to node:15. Also pin sonar-scanner-cli to 4.6 ([589fb4f](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/commit/589fb4fcf7841d3c5f08327d7fb5d5c107562ed6))
## [1.7.3](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.2...v1.7.3) (2021-04-12) ## [1.7.3](https://gitlab.evanrichardsonphotography.com/erichardson/py-eagle-mqtt/compare/v1.7.2...v1.7.3) (2021-04-12)

View File

@@ -22,7 +22,6 @@ import json
import bottle as B import bottle as B
import tHome as T import tHome as T
#=========================================================================== #===========================================================================
def meter( client, data, cfg ): def meter( client, data, cfg ):
msg = { msg = {
@@ -31,8 +30,7 @@ def meter(client, data, cfg):
"produced" : data.Produced, # kWh "produced" : data.Produced, # kWh
} }
return cfg.mqttEnergy, msg return ( cfg.mqttEnergy, msg )
#=========================================================================== #===========================================================================
def instant( client, data, cfg ): def instant( client, data, cfg ):
@@ -41,8 +39,7 @@ def instant(client, data, cfg):
"power" : data.Power * 1000, # W "power" : data.Power * 1000, # W
} }
return cfg.mqttPower, msg return ( cfg.mqttPower, msg )
#=========================================================================== #===========================================================================
def price( client, data, cfg ): def price( client, data, cfg ):
@@ -51,18 +48,7 @@ def price(client, data, cfg):
"price" : data.Price, "price" : data.Price,
"tier" : data.Tier, "tier" : data.Tier,
} }
return cfg.mqttPrice, msg return ( cfg.mqttPrice, msg )
# ===========================================================================
def network(client, data, cfg):
msg = {
"status": data.Status,
"description": data.Description,
"linkstrength": data.LinkStrength
}
return cfg.mqttNetwork, msg
#=========================================================================== #===========================================================================
handlers = { handlers = {
@@ -73,14 +59,13 @@ handlers = {
"InstantaneousDemand" : instant, "InstantaneousDemand" : instant,
#"MessageCluster" : #"MessageCluster" :
#"MeterInfo" : #"MeterInfo" :
"NetworkInfo": network, #"NetworkInfo" :
"PriceCluster" : price, "PriceCluster" : price,
#"Reading" : #"Reading" :
#"ScheduleInfo" : #"ScheduleInfo" :
#"TimeCluster" : #"TimeCluster" :
} }
#=========================================================================== #===========================================================================
@B.post( '/' ) @B.post( '/' )
@@ -105,7 +90,6 @@ def root_post():
return "ok" return "ok"
#=========================================================================== #===========================================================================
# #
# Main applications script # Main applications script

View File

@@ -23,9 +23,6 @@ mqttPrice = 'power/elec/Home/price'
#Current rate label (returns rate label from meter) #Current rate label (returns rate label from meter)
mqttRateLabel = 'power/elec/Home/ratelabel' mqttRateLabel = 'power/elec/Home/ratelabel'
#Network Info Topic (returns status, description and link strength from meter)
mqttNetwork = 'power/elec/Home/network'
#=========================================================================== #===========================================================================
# #
# Logging configuration. Env variables are allowed in the file name. # Logging configuration. Env variables are allowed in the file name.