diff --git a/ci-templates/auto-rules/no-default.yml b/ci-templates/auto-rules/no-default.yml index 011021ad9f51b2852300b57c1689e0f6135a9b1b..51bac7fddc7a9ac16db95fafe914314b44591be8 100644 --- a/ci-templates/auto-rules/no-default.yml +++ b/ci-templates/auto-rules/no-default.yml @@ -38,6 +38,26 @@ industrial_ci_noetic: - if: $DEFAULT_DISTRO == "noetic" - if: $BUILD_NOETIC + +.py3_template: + rules: + - if: $DEFAULT_DISTRO == "noetic" + when: always + - if: $BUILD_NOETIC + when: always + when: always + +.py2_template: + rules: + - if: $DEFAULT_DISTRO == "kinetic" + when: always + - if: $BUILD_KINETIC + when: always + - if: $DEFAULT_DISTRO == "melodic" + when: always + - if: $BUILD_MELODIC + when: always + ddeploy: extends: .ddeploy rules: diff --git a/ci-templates/core.yml b/ci-templates/core.yml index 8cacbee4740fe12f8807ca502a800f8fd3b1748f..2c198d191f6856a15b17e5383e150fe2eda4e4f2 100644 --- a/ci-templates/core.yml +++ b/ci-templates/core.yml @@ -24,6 +24,7 @@ before_script: include: - ci-templates/syntax-check.yml + - ci-templates/python.yml - ci-templates/industrial-ci-templates.yml default: diff --git a/ci-templates/python.yml b/ci-templates/python.yml new file mode 100644 index 0000000000000000000000000000000000000000..a9d1082ded71b232508afbd63cfccfe5b9cdaf65 --- /dev/null +++ b/ci-templates/python.yml @@ -0,0 +1,63 @@ + +.flake8_template: + stage: build + before_script: ${PYTHON_VERSION} -m pip -q install flake8 + script: ${PYTHON_VERSION} -m flake8 --max-line-length 120 --statistics --show-source . + + +.flake8_extended_template: + stage: .post + before_script: + - ${PYTHON_VERSION} -m pip install flake8 flake8-isort flake8-builtins + # The following flake8 extensions only work on python3 + - ${PYTHON_VERSION} -m pip install flake8-eradicate flake8-functions-names flake8-return flake8-functions || true + script: ${PYTHON_VERSION} -m flake8 --max-line-length 120 --statistics --show-source . + allow_failure: true + +.security_template: + stage: .post + before_script: + - ${PYTHON_VERSION} -m pip install bandit safety + script: + - bandit -r . || RET=1 + - safety check || RET=1 + - exit $RET + when: always + allow_failure: true + +.py3_template: + image: python:3-alpine + variables: + PYTHON_VERSION: python3 + when: never + +.py2_template: + image: python:2-alpine + variables: + PYTHON_VERSION: python2 + when: always + +py3-flake8: + extends: + - .flake8_template + - .py3_template + +py2-flake8: + extends: + - .flake8_template + - .py2_template + +py3-flake8_extended: + extends: + - .flake8_extended_template + - .py3_template + +py2-flake8_extended: + extends: + - .flake8_extended_template + - .py2_template + +py3-security: + extends: + - .security_template + - .py3_template \ No newline at end of file diff --git a/ci-templates/syntax-check.yml b/ci-templates/syntax-check.yml index 3c413c258e9a4392bc67d8d081558080174dc748..f83449568e237e8d818330ee5fb02e446b84b1a4 100644 --- a/ci-templates/syntax-check.yml +++ b/ci-templates/syntax-check.yml @@ -15,45 +15,6 @@ clang_format: CLANG_FORMAT_VERSION: "3.8" when: always -########################################################## -## Several Python checks -########################################################## -flake8: - stage: .post - image: python:3-alpine - before_script: - - pip3 install flake8 - script: - - flake8 --max-line-length 120 --statistics --show-source . - tags: - - docker - when: always - -flake8_extended: - stage: .post - image: python:3-alpine - before_script: - - pip3 install flake8 flake8-isort flake8-builtins flake8-eradicate flake8-functions-names flake8-return flake8-functions - script: - - flake8 --max-line-length 120 --statistics --show-source . - tags: - - docker - when: always - allow_failure: true - -python_security: - stage: .post - image: python:3-alpine - before_script: - - pip3 install bandit safety - script: - - bandit -r . || RET=1 - - safety check || RET=1 - - exit $RET - tags: - - docker - when: always - ########################################################## ## Check for errors in bash/sh scripts ## Uses https://github.com/koalaman/shellcheck