From 470bc2290ce5146e19d32ddf8c361cdaaba62103 Mon Sep 17 00:00:00 2001
From: Jon Azpiazu <jon.azpiazu@tecnalia.com>
Date: Mon, 13 Jun 2022 15:43:34 +0200
Subject: [PATCH] New jobs to substitute the old Python check

---
 ci-templates/syntax-check.yml | 45 ++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/ci-templates/syntax-check.yml b/ci-templates/syntax-check.yml
index 4ecbab1..3c413c2 100644
--- a/ci-templates/syntax-check.yml
+++ b/ci-templates/syntax-check.yml
@@ -16,16 +16,43 @@ clang_format:
   when: always
 
 ##########################################################
-## Simple check for basic Python syntax errors; this is much less thorough than
-## other options like pylint, but much faster and less strict
+## Several Python checks
 ##########################################################
-python_syntax:
-  image: alpine:3.15 # python2 is no longer available in alpine:3.16
-  before_script:
-    - apk add --update python2
-  stage: build
-  script: python -m compileall -q .
-  when: always
+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
-- 
GitLab