Commit 264f3139 authored by GridexX's avatar GridexX Committed by Thomas Boni
Browse files

chore: remove r2 template and associated jobs



Signed-off-by: default avatarGridexX <arsene582@gmail.com>
parent 0d96b8e7
Loading
Loading
Loading
Loading
+0 −41
Original line number Diff line number Diff line
@@ -63,47 +63,6 @@ ci_linter:
    - changes:
      - "jobs/**/*${JOB_FILES_EXTENSION}"

job_structure:
  image: python:${IMAGE_TAG_PYTHON_ALPINE}
  stage: static_tests
  variables:
    PIPENV_PIPFILE: tools/job_structure/Pipfile
    JOB_LOGFILE: "job_structure.log"
    PYTHONPATH: "./:$PYTHONPATH"
  before_script:
    - pip install --ignore-installed distlib pipenv
    - pipenv install
  script:
    - pipenv run python3 tools/job_structure/job_structure.py
  artifacts:
    expose_as: "job_structure"
    paths:
      - ${JOB_LOGFILE}
    when: always
  rules:
    - changes:
      - jobs/**/*

job_customs:
  image: python:${IMAGE_TAG_PYTHON_ALPINE}
  stage: static_tests
  variables:
    PIPENV_PIPFILE: tools/job_customs/Pipfile
    JOB_LOGFILE: "job_customs.log"
    PYTHONPATH: "./:$PYTHONPATH"
  before_script:
    - pip install --ignore-installed distlib pipenv
    - pipenv install
  script:
    - pipenv run python3 tools/job_customs/job_customs.py
  artifacts:
    expose_as: "jobs_customs"
    paths:
      - ${JOB_LOGFILE}
  rules:
    - changes:
      - jobs/**/*

.job_image_scan:
  image: docker:20.10
  stage: static_tests

tools/job_customs/Pipfile

deleted100644 → 0
+0 −10
Original line number Diff line number Diff line
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[requires]
python_version = "3"

[packages]
pyyaml = "==5.3.1"

tools/job_customs/Pipfile.lock

deleted100644 → 0
+0 −40
Original line number Diff line number Diff line
{
    "_meta": {
        "hash": {
            "sha256": "ac0ce3b857220356672b701f08dc6413e0373a41f9442ca3479b74651dd8f21d"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "pyyaml": {
            "hashes": [
                "sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97",
                "sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76",
                "sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2",
                "sha256:6034f55dab5fea9e53f436aa68fa3ace2634918e8b5994d82f3621c04ff5ed2e",
                "sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648",
                "sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf",
                "sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f",
                "sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2",
                "sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee",
                "sha256:ad9c67312c84def58f3c04504727ca879cb0013b2517c85a9a253f0cb6380c0a",
                "sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d",
                "sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c",
                "sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a"
            ],
            "index": "pypi",
            "version": "==5.3.1"
        }
    },
    "develop": {}
}

tools/job_customs/job_customs.py

deleted100644 → 0
+0 −91
Original line number Diff line number Diff line
#!/usr/bin/env python3

import os
import logging
import sys
import yaml
import argparse
import re

# Import the Config module and set the path to run the script from root project
# /!\ This instruction is only working if you run this script from the root of the project
sys.path.insert(0, "./")
from tools.utils.utils import Config
utils = Config()


patterns = [
    "git commit",
    "git push"
]

scripts = [
    "before_script",
    "script",
    "after_script"
]

def argparse_setup():
    """Setup argparse

    Return
    ------
    obj
        Python object with arguments parsed
    """
    parser = argparse.ArgumentParser()
    return parser.parse_args()

if __name__ == "__main__":
    """Main function, verify if the script part of every job isn't modifying the code with patterns
    Return
    ------
    0
        If no code was modified during the script
    1
        If the code is modified during the script
    """

    # Setup argparse
    args = argparse_setup()

    # Setup logging
    logging.basicConfig(
        level=logging.INFO,
        format="%(asctime)s [%(levelname)s] %(message)s",
        handlers=[
            logging.FileHandler(utils.LOGFILE_NAME),
            logging.StreamHandler()
        ]
    )

    return_code = utils.EXIT_SUCCESS
    for job in os.listdir(utils.JOBS_DIR):

        logging.info("Getting the script for job %s", job)

        data = {}
        with open(f"{utils.JOBS_DIR}/{job}/{job}{utils.JOBS_EXTENSION}", 'r') as file:
            data = yaml.load(file, Loader=yaml.FullLoader)

        for script in scripts:

            try:
                if script in data[job].keys():
                    for line in data[job][script]:
                        if any(re.match(pattern, line) for pattern in patterns):
                            logging.error("Code modification discovered in script of job %s", job)
                            return_code = utils.EXIT_FAILURE
                elif "extends" in data[job].keys():
                    if script in data[data[job]['extends']].keys():
                        for line in data[data[job]['extends']][script]:
                            if any(re.match(pattern, line) for pattern in patterns):
                                logging.error("Code modification discovered in script of job %s", job)
                                return_code = utils.EXIT_FAILURE
            # If the extended job isn't in the file, it produce a KeyError
            except KeyError :
                logging.warning('The job %s extends a job not declared in the file, we aren\'t able to check what %s does',
                                job, script)
                # TODO: check images from included jobs ==> https://gitlab.com/r2devops/hub/-/issues/282

    sys.exit(return_code)

tools/job_structure/Pipfile

deleted100644 → 0
+0 −10
Original line number Diff line number Diff line
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[requires]
python_version = "3"

[packages]
pyyaml = "==5.3.1"
Loading