From 704de5ad9980ed50b7a9831dbea6576f02939b8e Mon Sep 17 00:00:00 2001 From: lukken <lukken@astron.nl> Date: Wed, 22 Sep 2021 10:10:16 +0000 Subject: [PATCH] L2SS-310: Extend linting with breakpoint, mock and shell checks Adds missing newline eof detection in common file formats as well as finding breakpoint and debugger statements, non-existing mock statements and adding shellcheck for our shell scripts. --- .gitlab-ci.yml | 19 ++++++++++++++++--- README.md | 2 +- devices/clients/README.md | 2 +- devices/integration_test/README.md | 2 +- devices/test-requirements.txt | 3 +++ devices/tox.ini | 2 +- .../tango-prometheus-exporter/get_metrics.sh | 2 +- sbin/run_integration_test.sh | 2 +- 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f7dac6a3..c0c406ef3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,17 +16,30 @@ stages: - static-analysis - unit-tests - integration-tests -linting: +newline_at_eof: + stage: linting + before_script: + - pip3 install -r devices/test-requirements.txt + script: + - flake8 --filename *.sh,*.conf,*.md,*.yml --select=W292 --exclude .tox,.egg-info,docker +python_linting: stage: linting script: - cd devices - tox -e pep8 -static-analysis: +bandit: stage: static-analysis - allow_failure: true script: - cd devices - tox -e bandit +shellcheck: + stage: static-analysis + allow_failure: true + before_script: + - sudo apt-get update + - sudo apt-get install -y shellcheck + script: + - shellheck **/*.sh unit_test: stage: unit-tests before_script: diff --git a/README.md b/README.md index b7b4398a9..192b3edb7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Tango Station Control -Station Control software related to Tango devices. \ No newline at end of file +Station Control software related to Tango devices. diff --git a/devices/clients/README.md b/devices/clients/README.md index 361334446..083420b38 100644 --- a/devices/clients/README.md +++ b/devices/clients/README.md @@ -1,4 +1,4 @@ this folder contains all the comms_client implementations for organisation ### How to add a new client -soon™ \ No newline at end of file +soon™ diff --git a/devices/integration_test/README.md b/devices/integration_test/README.md index 3292bfa00..d4f91ace1 100644 --- a/devices/integration_test/README.md +++ b/devices/integration_test/README.md @@ -23,4 +23,4 @@ $LOFAR20_DIR/sbin/run_integration_test.sh ## Limitations Our makefile will always launch the new container upon creation, resulting in -the integration tests actually being run twice. \ No newline at end of file +the integration tests actually being run twice. diff --git a/devices/test-requirements.txt b/devices/test-requirements.txt index c97375e93..af6d9e421 100644 --- a/devices/test-requirements.txt +++ b/devices/test-requirements.txt @@ -4,6 +4,9 @@ doc8>=0.8.0 # Apache-2.0 flake8>=3.8.0 # MIT +flake8-breakpoint>=1.1.0 # MIT +flake8-debugger>=4.0.0 #MIT +flake8-mock>=0.3 #GPL bandit>=1.6.0 # Apache-2.0 hacking>=3.2.0,<3.3.0 # Apache-2.0 coverage>=5.2.0 # Apache-2.0 diff --git a/devices/tox.ini b/devices/tox.ini index 4869bad04..e9a1fb2c0 100644 --- a/devices/tox.ini +++ b/devices/tox.ini @@ -42,5 +42,5 @@ commands = [flake8] filename = *.py,.stestr.conf,.txt -select = W292 +select = W292,B601,B602,T100,M001 exclude=.tox,.egg-info diff --git a/docker-compose/tango-prometheus-exporter/get_metrics.sh b/docker-compose/tango-prometheus-exporter/get_metrics.sh index b28017289..0401a2564 100755 --- a/docker-compose/tango-prometheus-exporter/get_metrics.sh +++ b/docker-compose/tango-prometheus-exporter/get_metrics.sh @@ -1 +1 @@ -curl $(kubectl get svc -n tango-grafana -o jsonpath='{.items[?(@.metadata.name=="tango-exporter-service-0")].spec.clusterIP}')/metrics \ No newline at end of file +curl $(kubectl get svc -n tango-grafana -o jsonpath='{.items[?(@.metadata.name=="tango-exporter-service-0")].spec.clusterIP}')/metrics diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index d54163625..cebbf1479 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -19,4 +19,4 @@ cd "$LOFAR20_DIR/docker-compose" || exit 1 make start integration-test # Run the integration test with the output displayed on stdout -docker start -a integration-test \ No newline at end of file +docker start -a integration-test -- GitLab