diff --git a/contrib/actions/cds-docker-package.yml b/contrib/actions/cds-docker-package.yml deleted file mode 100644 index 203c766405..0000000000 --- a/contrib/actions/cds-docker-package.yml +++ /dev/null @@ -1,144 +0,0 @@ -version: v1.0 -name: CDS_DockerPackage -description: Build image and push it to docker repository -parameters: - dockerOpts: - type: string - description: Docker options, Enter --no-cache --pull if you want for example - dockerRegistry: - type: string - description: Docker Registry. Enter myregistry for build image myregistry/myimage:mytag - dockerRegistryPassword: - type: string - description: Docker Registry Password. Enter password to connect on your docker - registry. - dockerRegistryUsername: - type: string - description: Docker Registry Username. Enter username to connect on your docker - registry. - dockerfileDirectory: - type: string - description: Directory which contains your Dockerfile. - imageName: - type: string - description: Name of your docker image, without tag. Enter myimage for build image - myregistry/myimage:mytag - imageTag: - type: string - default: '{{.cds.version}}' - description: |- - Tag og your docker image. - Enter mytag for build image myregistry/myimage:mytag. {{.cds.version}} is a good tag from CDS. - You can use many tags: firstTag,SecondTag - Example : {{.cds.version}},latest -requirements: -- binary: docker -steps: -- script: - - '#!/bin/bash' - - IMG=`echo {{.imageName}}| tr '[:upper:]' '[:lower:]'` - - GENTAG="cds{{.cds.version}}" - - REGISTRY="{{.dockerRegistry}}" - - USERNAME="{{.dockerRegistryUsername}}" - - PASSWORD="{{.dockerRegistryPassword}}" - - echo "Building ${REGISTRY}/${IMG}:${GENTAG}" - - cd {{.dockerfileDirectory}} - - docker build {{.dockerOpts}} -t ${REGISTRY}/${IMG}:${GENTAG} . - - "" - - IFS=', ' read -r -a tags <<< "{{.imageTag}}" - - for t in "${tags[@]}"; do - - "\tset +e" - - "\tif [[ ! -z \"${USERNAME}\" && ! -z \"${PASSWORD}\" && ! -z \"${REGISTRY}\" ]]; then" - - "\t\techo \"Login to ${REGISTRY}\"" - - "\t\tdocker login -u ${USERNAME} -p ${PASSWORD} ${REGISTRY}" - - "\tfi" - - "" - - "\tTAG=`echo ${t} | sed 's/\\///g'`" - - "\tdocker tag ${REGISTRY}/${IMG}:${GENTAG} ${REGISTRY}/${IMG}:${TAG}" - - "" - - 'echo "Pushing ${REGISTRY}/${IMG}:${TAG}"' - - "\tdocker push ${REGISTRY}/${IMG}:${TAG}" - - "\tif [ $? -ne 0 ]; then" - - "\t\tset -e" - - "\t\techo \"/!\\ Error while pushing to repository. Automatic retry in 60s...\"" - - "\t\tsleep 60" - - "\t\tdocker push ${REGISTRY}/${IMG}:${TAG}" - - "\tfi" - - "" - - "\tset -e" - - "\techo \" ${REGISTRY}/${IMG}:${TAG} is pushed\"" - - "\t#docker rmi -f ${REGISTRY}/${IMG}:${TAG} || true;" - - done - - "" - - IMAGE_ID=`docker images --digests --no-trunc --format "{{.Repository}}:{{.Tag}} - {{.ID}}" | grep "${REGISTRY}/${IMG}:${GENTAG}" | awk '{print $2}'` - - IMAGE_DIGEST=`docker images --digests --no-trunc --format "{{.Repository}}:{{.Tag}} - {{.Digest}}" | grep "${REGISTRY}/${IMG}:${GENTAG}" | awk '{print $2}'` - - "" - - echo "ID=$IMAGE_ID" - - worker export image.id ${IMAGE_ID} - - "" - - echo "DIGEST=$IMAGE_DIGEST" - - worker export image.digest ${IMAGE_DIGEST} - - "" - - '#docker rmi -f ${REGISTRY}/${IMG}:${GENTAG} || true;' -- enabled: false - script: - - '#!/bin/sh' - - set -e - - "" - - IMG=`echo {{.imageName}}| tr '[:upper:]' '[:lower:]'` - - TAG=`echo {{.imageTag}} | sed 's/\///g'` - - echo "Building ${IMG}:${TAG}" - - "" - - cd {{.dockerfileDirectory}} - - docker build {{.dockerOpts}} -t {{.dockerRegistry}}/$IMG:$TAG . -- enabled: false - script: - - '#!/bin/sh' - - "" - - IMG=`echo {{.imageName}}| tr '[:upper:]' '[:lower:]'` - - TAG=`echo {{.imageTag}} | sed 's/\///g'` - - "" - - echo "Pushing {{.dockerRegistry}}/$IMG:$TAG" - - docker push {{.dockerRegistry}}/$IMG:$TAG - - "" - - if [ $? -ne 0 ]; then - - "\tset -e" - - "\techo \"/!\\ Error while pushing to repository. Automatic retry in 60s...\"" - - ' sleep 60' - - ' docker push {{.dockerRegistry}}/$IMG:$TAG' - - fi - - "" - - set -e - - echo " {{.dockerRegistry}}/$IMG:$TAG is pushed" - - "" - - docker rmi -f {{.dockerRegistry}}/$IMG:$TAG || true -- enabled: false - script: - - '#!/bin/bash' - - "" - - IFS=', ' read -r -a tags <<< "{{.imageTag}}" - - "" - - for t in "${tags[@]}"; do - - "" - - "\tIMG=`echo {{.imageName}}| tr '[:upper:]' '[:lower:]'`" - - "\tTAG=`echo ${t} | sed 's/\\///g'`" - - "" - - "\techo \"Pushing {{.dockerRegistry}}/$IMG:$TAG\"" - - "\tdocker push {{.dockerRegistry}}/$IMG:$TAG" - - "" - - "\tif [ $? -ne 0 ]; then" - - "\t\tset -e" - - "\t\techo \"/!\\ Error while pushing to repository. Automatic retry in 60s...\"" - - "\t sleep 60" - - "\t docker push {{.dockerRegistry}}/$IMG:$TAG" - - "\tfi" - - "" - - "\tset -e" - - "\techo \" {{.dockerRegistry}}/$IMG:$TAG is pushed\"" - - "" - - "\tdocker rmi -f {{.dockerRegistry}}/$IMG:$TAG || true;" - - "" - - done - diff --git a/contrib/actions/cds-go-build.yml b/contrib/actions/cds-go-build.yml deleted file mode 100644 index fc466cca01..0000000000 --- a/contrib/actions/cds-go-build.yml +++ /dev/null @@ -1,98 +0,0 @@ -version: v1.0 -name: CDS_GoBuild -description: 'Go Build: compile a go program' -parameters: - architecture: - type: list - default: amd64;386;arm - description: GOARCH - artifactUpload: - type: boolean - default: "false" - description: Upload Binary as CDS Artifact - binary: - type: string - default: '{{.cds.application}}' - description: 'Binary name: Put foo for go build -o foo' - cgoDisabled: - type: boolean - default: "false" - detectRaceCondition: - type: boolean - default: "false" - description: Enable data race detection. It's flag -race - flags: - type: string - description: flags for go build. Put -ldflags "-X main.xyz=abc" for go build -ldflags "-X main.xyz=abc" - os: - type: list - default: linux;darwin;windows - description: GOOS - package: - type: string - description: go package to compile. Put host.ext/foo/bar for go build host.ext/foo/bar - preRun: - type: text - description: 'Pre-command. Example: export CGO_ENABLED=0' - runGoGet: - type: boolean - default: "false" - description: Run go get -u before go build -requirements: -- binary: bash -- binary: go -steps: -- script: - - '#!/bin/bash' - - set -x - - "" - - export GOOS="{{.os}}" - - export GOARCH="{{.architecture}}" - - "" - - if [ ! -d "${GOPATH}/src/{{.package}}" ]; then - - ' echo "directory ''${GOPATH}/src/{{.package}}'' does not exist"' - - "\techo \"Please put your source under ${GOPATH}/src/{{.package}} before running this action\"" - - "\texit 1;" - - fi; - - "" - - cd ${GOPATH}/src/{{.package}} - - "" - - if [ "xtrue" == "x{{.runGoGet}}" ]; then - - "\tgo get -v" - - else - - "\techo \"not running go get ({{.runGoGet}})\";" - - fi; - - "" - - GOARGS="" - - if [ "x" != "x{{.binary}}" ]; then - - ' GOARGS=" -o {{.binary}}"' - - fi; - - "" - - if [ "xtrue" == "x{{.detectRaceCondition}}" ]; then - - ' GOARGS="${GOARGS} -race"' - - fi; - - "" - - if [ "xtrue" == "x{{.cgoDisabled}}" ]; then - - ' export CGO_ENABLED=0' - - ' echo "run with CGO_ENABLED=0";' - - fi; - - "" - - if [ "x" != "x{{.preRun}}" ]; then - - cat << EOF > preRun.sh - - '{{.preRun}}' - - EOF - - chmod +x preRun.sh - - ./preRun.sh - - fi; - - "" - - go build {{.flags}} ${GOARGS} - - "" - - if [ "xtrue" == "x{{.artifactUpload}}" ]; then - - "\tif [ ! -f ${GOPATH}/src/{{.package}}/{{.binary}} ]; then" - - " \techo \"File ${GOPATH}/src/{{.package}}/{{.binary}} not found!\"" - - ' exit 1;' - - "\tfi" - - "\tworker upload \"${GOPATH}/src/{{.package}}/{{.binary}}\"" - - else - - "\techo \"artifact upload: {{.artifactUpload}}. So, artifact is not uploaded\"" - - fi; diff --git a/contrib/actions/cds-nexus-upload.yml b/contrib/actions/cds-nexus-upload.yml deleted file mode 100644 index 53bf43c696..0000000000 --- a/contrib/actions/cds-nexus-upload.yml +++ /dev/null @@ -1,63 +0,0 @@ -version: v1.0 -name: CDS_NexusUpload -description: Upload file on Nexus -parameters: - artifactId: - type: string - default: '{{.cds.application}}' - description: Artifact id of the artifact - extension: - type: string - description: Extension of the artifact - files: - type: string - description: Regex of files you want to upload - groupId: - type: string - default: '{{.cds.application}}' - description: Group id of the artifact - login: - type: string - default: '{{.cds.proj.nexus.login}}' - description: Login for nexus - packaging: - type: string - description: Packaging type of the artifact - password: - type: string - default: '{{.cds.proj.nexus.password}}' - description: Password for nexus - repository: - type: string - description: Nexus repository that the artifact is contained in - url: - type: string - default: '{{.cds.proj.nexus.url}}' - description: Nexus URL - version: - type: string - default: '{{.cds.version}}' - description: Version of the artifact. Supports resolving of 'LATEST', 'RELEASE' - and snapshot versions ('1.0-SNAPSHOT') too. -requirements: -- binary: bash -- binary: curl -steps: -- script: - - '#!/bin/bash' - - set -e - - "" - - echo "Upload to Nexus ({{.url}}) on repository {{.repository}}" - - "" - - for file in `ls {{.files}}` - - do - - "\tif [ -f $file ]" - - "\tthen" - - " \techo \"Upload to Nexus ({{.url}}) the file ${file}\"" - - ' curl --upload-file $file -u {{.login}}:{{.password}} {{.url}} -f' - - "\telse" - - "\t\techo \"File $file does not exist\"" - - "\tfi" - - done - - "" - diff --git a/contrib/actions/cds-perl-test.yml b/contrib/actions/cds-perl-test.yml deleted file mode 100644 index 2366a297d9..0000000000 --- a/contrib/actions/cds-perl-test.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: v1.0 -name: CDS_PerlTest -parameters: - perllib: - type: string - description: PERL_LIB, added to $PERL5LIB - proveOptions: - type: string - default: -r --timer - description: Options passed to prove - testDirectory: - type: string -requirements: -- binary: bash -- binary: perl -- binary: prove -steps: -- script: - - '#!/bin/sh' - - set -e - - "" - - PERL_LIB={{.perllib}} - - "" - - if [ "x${PERL_LIB}" != "x" ]; then - - "\tif [ \"x${PERL5LIB}\" != \"x\" ]; then" - - " \tPERL_LIB=$PERL5LIB:$PERL_LIB" - - ' fi;' - - ' export PERL5LIB=$PERL_LIB;' - - ' echo "set PERL5LIB to $PERL_LIB";' - - fi; - - "" - - cd {{.testDirectory}} - - mkdir -p results - - "" - - prove --formatter=TAP::Formatter::JUnit {{.proveOptions}} > results/resultsUnitsTests.xml - - "" -- always_executed: true - artifactUpload: - path: '{{.testDirectory}}/results/resultsUnitsTests.xml' - tag: '{{.cds.version}}' -- always_executed: true - jUnitReport: '{{.testDirectory}}/results/resultsUnitsTests.xml' - diff --git a/contrib/actions/cds-publish-ovh-metrics.yml b/contrib/actions/cds-publish-ovh-metrics.yml deleted file mode 100644 index 56208a0066..0000000000 --- a/contrib/actions/cds-publish-ovh-metrics.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: v1.0 -name: CDS_PublishOVHMetrics -description: Publish a metric on OVH Metrics. See https://www.ovh.com/fr/data-platforms/metrics/ - and doc on https://docs.ovh.com/gb/en/cloud/metrics/ -parameters: - file: - type: string - description: 'Metrics file to push (optional) See: http://www.warp10.io/apis/ingress/' - labels: - type: text - default: |- - app {{.cds.application}} - env {{.cds.environment}} - description: Labels of your metric (one K/V per line separated by a space) - name: - type: string - default: cds - description: Name of you metric (optional) - region: - type: string - default: gra1-ovh - description: Metrics region - token: - type: string - description: Metrics write token - value: - type: string - default: T - description: 'Value of your metric (T=true) See: http://www.warp10.io/apis/ingress/' -requirements: -- binary: bash -- binary: curl -steps: -- script: - - '#!/bin/bash' - - "" - - set -e - - "" - - if [ "{{.name}}" != "" ]; then - - "" - - labels=`cat << EOF | sed 's/ /%20/g' | sed 's/%20/=/1' | tr '\n' ',' | sed 's/, - *$//' - - '{{.labels}}' - - EOF` - - "" - - echo "// {{.name}}{$labels} {{.value}}" >> .metrics - - "" - - curl -f -X POST https://warp10.{{.region}}.metrics.ovh.net/api/v0/update \ - - ' -H ''X-Warp10-Token: {{.token}}'' \' - - ' --data-binary @.metrics' - - "" - - fi; - - "" - - "" - - if [ "{{.file}}" != "" ]; then - - curl -f -X POST https://warp10.{{.region}}.metrics.ovh.net/api/v0/update \ - - ' -H ''X-Warp10-Token: {{.token}}'' \' - - ' --data-binary @{{.file}}' - - fi; - - "" - diff --git a/contrib/actions/cds-python-pylint.yml b/contrib/actions/cds-python-pylint.yml deleted file mode 100644 index 4099a81b12..0000000000 --- a/contrib/actions/cds-python-pylint.yml +++ /dev/null @@ -1,303 +0,0 @@ -version: v1.0 -name: CDS_PythonPylint -description: |- - Run pylint. - By default, each pylint recommendation will be displayed as a Junit test. - The short errors are fully contained inside the test title, - an arrow (->) will be present if a part of the recommendation is displayed in - the test body. -parameters: - extra_options: - type: string - description: Extra options to pass during pylint invocation. - ignore: - type: string - description: |- - List of ignored files / directory (base name, not path), separated - by a ; - module_path: - type: string - description: |- - List of modules paths (absolute or relative) to launch pylint into, separated by a ;. - If empty, will launch pylint inside the working directory - pylintrc: - type: string - description: |- - Path of the pylintrc file, or its content. - +If your pylintrc file is not used, try to use an absolute path using the variable {{.cds.workspace}} that points to the container default working directory - raw_output: - type: boolean - default: "false" - description: Skip the xunit + Junit step and output a raw pylint result file. - raw_output_file: - type: string - description: File to output the raw result if raw output is checked. If empty, - will only log the results. - xml_output_file: - type: string - default: pylint_result.xml - description: File to output the result xunit xml, it should not be empty. -requirements: -- binary: python3.5 -- binary: virtualenv -steps: -- script: - - '#!/bin/bash' - - set -e - - "" - - '# Setup pylint_venv' - - virtualenv -p python3.5 .pylint_venv - - . .pylint_venv/bin/activate - - "" - - '# Install pylint' - - pip install --upgrade pip - - pip install astroid==1.5.3 pylint==1.8.2 - - "" - - "" -- script: - - '#!.pylint_venv/bin/python3.5' - - import json - - import logging - - import os - - import tempfile - - import xml.etree.cElementTree as ET - - from sys import stdout - - from textwrap import dedent as _dedent - - "" - - from pylint import epylint - - "" - - LOG = logging.getLogger(__name__) - - "" - - 'def dedent(text):' - - ' """' - - ' Remove the common leading tabs on each line of a string' - - "" - - ' :param text: String to clean' - - ' :type text: str' - - ' :return: Cleaned string' - - ' :rtype: str' - - ' """' - - ' return _dedent(text).strip()' - - "" - - "" - - 'def set_logging(level=logging.INFO):' - - ' """' - - ' Setup the script logger.' - - "" - - ' :param level: Logging level' - - ' :type level: python logging level' - - ' """' - - ' logging.basicConfig(level=level)' - - ' LOG.propagate = False' - - "" - - ' std_handler = logging.StreamHandler(stream=stdout)' - - ' formatter = logging.Formatter(''%(asctime)s - %(levelname)s - %(message)s'')' - - ' std_handler.setFormatter(formatter)' - - ' LOG.addHandler(std_handler)' - - "" - - "" - - 'def get_lint_result(module_path=None, ignore=None, pylintrc=None, extra_options=None, - raw_output=False):' - - ' """' - - ' Get the pylint result for a list of modules.' - - "" - - ' :param module_path: List of module paths' - - ' :type module_path: list of str' - - ' :param ignore: list of ignored files / dirs (base name, not path)' - - ' :type ignore: list of str' - - ' :param pylintrc: pylintrc filepath or content' - - ' :type pylintrc: str' - - ' :param extra_options: pylint extra options' - - ' :type extra_options: str' - - ' :param raw_output: Skip the json parsing and output the raw pylint result' - - ' :type raw_output: boolean' - - ' :return: A list of json/raw results' - - ' :rtype: list' - - ' """' - - ' # If pylintrc points to a file, use it, else write a temporary file to store - its value.' - - ' rcfile_path = None' - - ' if pylintrc and os.path.isfile(pylintrc):' - - ' rcfile_path = pylintrc' - - ' elif pylintrc:' - - ' pylintrc_file = tempfile.NamedTemporaryFile("w")' - - ' pylintrc_file.write(pylintrc)' - - ' rcfile_path = pylintrc_file.name' - - ' LOG.debug("Wrote pylintrc content to %s" % rcfile_path)' - - "" - - ' # If the user didn''t provide module path(s), launch pylint in the working - directory' - - ' if not module_path:' - - ' if os.path.isfile("__init__.py"):' - - ' LOG.debug("Using current directory as module")' - - ' module_path = ["."]' - - ' else:' - - ' LOG.error("The current working directory is not a valid python module, - please fill the "' - - ' "module variable with a correct list of modules")' - - ' exit(1)' - - "" - - ' final_result = []' - - ' # For each module, launch pylint' - - ' for module in module_path:' - - "" - - ' # Compute pylint options' - - ' pylint_options = [' - - ' "%s" % module,' - - ' "--persistent=no"' - - ' ]' - - "" - - ' if not raw_output:' - - ' pylint_options.append("--output-format=json")' - - "" - - ' if ignore:' - - ' pylint_options.append("--ignore=%s" % ignore)' - - "" - - ' if rcfile_path:' - - ' pylint_options.append("--rcfile=%s" % rcfile_path)' - - "" - - ' if extra_options:' - - ' pylint_options.append(extra_options)' - - "" - - ' # Launch pylint' - - ' LOG.debug("Launching pylint with options : %s" % " ".join(pylint_options))' - - ' pylint_stdout, pylint_stderr = epylint.py_run(" ".join(pylint_options), - return_std=True)' - - "" - - ' result = pylint_stdout.getvalue()' - - ' if not result and not raw_output:' - - ' result = "{}"' - - "" - - ' err = pylint_stderr.getvalue()' - - "" - - ' # Parse the pylint result, if it fails, it means the pylint run failed - too.' - - ' if not raw_output:' - - ' try:' - - ' file_result_parsed = json.loads(result)' - - ' except json.decoder.JSONDecodeError:' - - ' LOG.error("Pylint output decoding failed \n"' - - ' "Pylint stdout : %s \n"' - - ' "Pylint stderr : %s" % (result, err))' - - ' exit(1)' - - ' else:' - - ' file_result_parsed = [result]' - - "" - - ' final_result += file_result_parsed' - - "" - - ' try:' - - ' pylintrc_file.close()' - - ' except (NameError, AttributeError):' - - ' pass' - - "" - - ' return final_result' - - "" - - "" - - 'def lint(xml_output_file="pylint.xml", raw_output=False, raw_output_file="pylint.txt", - **kwargs):' - - ' """' - - ' Create a xunit file, compatible with CDS Junit parsing with the collected - pylint results' - - "" - - ' :param xml_output_file: File to output the xml' - - ' :type xml_output_file: str' - - ' :param raw_output: Output the pylint raw result' - - ' :type raw_output: boolean' - - ' :param raw_output_file: File to output the raw result' - - ' :type raw_output_file: str' - - ' :param kwargs: Arguments for get_lint_result' - - ' :type kwargs: dict' - - ' """' - - "" - - ' lint_result = get_lint_result(raw_output=raw_output, **kwargs)' - - "" - - ' if raw_output:' - - ' if raw_output_file is not None:' - - ' with open(raw_output_file, "w") as raw_f:' - - ' for line in lint_result:' - - ' raw_f.write(line)' - - ' LOG.info("Wrote raw pylint output to %s" % raw_output_file)' - - ' else:' - - ' LOG.info("Pylint result : \n %s" % "\n".join(lint_result))' - - ' with open(xml_output_file, "w") as xml_f:' - - ' xml_f.write('''')' - - ' LOG.info("Wrote fake xunit test suite to %s" % xml_output_file)' - - "" - - ' # Exit the script accordingly to the pylint result.' - - ' for result in lint_result:' - - ' if result != "":' - - ' LOG.info("Pylint run failed")' - - ' exit(1)' - - ' LOG.info("Pylint run was successful")' - - ' exit(0)' - - "" - - ' # Create the xml tree' - - ' root = ET.Element("testsuite", name="Pylint results")' - - "" - - ' # Create an entry for each test' - - ' for line in lint_result:' - - ' # If the message is on multiple lines, only set the title to the first - line,' - - ' # the following lines will be displayed inside the body.' - - ' # An arrow (->) will be added to right side of the title to indicate - that the rest of the information' - - ' # is located in the body and need a click to be displayed' - - ' message = line["message"].split("\n")' - - ' data = ""' - - ' if len(message) > 1:' - - ' data = dedent("\n".join(message[1:]))' - - ' message = "%s ->" % message[0]' - - ' else:' - - ' message = message[0]' - - "" - - ' msg = "%s %s - Line %d Column %d: %s" % (' - - ' line["type"],' - - ' line["path"],' - - ' line["line"],' - - ' line["column"],' - - ' message' - - ' )' - - "" - - ' LOG.debug("Creating testcase with message \"%s\"" % message)' - - ' testcase = ET.SubElement(root, "testcase", classname=line["module"], - name=msg, time="0.000")' - - ' failure = ET.SubElement(testcase, "failure", message=msg, type=line["type"])' - - "" - - ' # Add body' - - ' failure.append(ET.Comment('' -->'', '']]]]>'') - + '']]>