Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • miguel.prada/gitlab_templates
  • tecnalia_robotics-public/gitlab_templates
2 results
Show changes
Commits on Source (113)
Showing
with 389 additions and 247 deletions
shellcheck: shellcheck:
image: tecnalia-docker-dev.artifact.tecnalia.com/koalaman/shellcheck-alpine image: tecnalia-docker-dev.artifact.tecnalia.dev/koalaman/shellcheck-alpine
script: shellcheck deploy/base/ros_entrypoint.bash scripts/*sh script: shellcheck scripts/*sh
tags: tags:
- docker - docker
# The ignored rules in hadolint checks are
# DL3006 Always tag the version of an image explicitly
# One of the Dockerfiles uses a temporary image which isn't important to tag
# and the other uses a tagged image through an ARG, which apparently is not
# properly recognized.
# DL3008 Pin versions in apt-get install
# A bit overkill
dockerfiles:
image: tecnalia-docker-dev.artifact.tecnalia.com/hadolint/hadolint:latest-debian
script:
- RET=0
- hadolint --ignore DL3006 --ignore DL3008 --ignore DL3059 deploy/base/Dockerfile || RET=1
- hadolint --ignore DL3006 --ignore DL3008 --ignore DL3059 deploy/dev/Dockerfile || RET=1
- exit $RET
tags:
- docker
yamllint: yamllint:
image: tecnalia-docker-dev.artifact.tecnalia.com/sdesbure/yamllint image: tecnalia-docker-dev.artifact.tecnalia.dev/sdesbure/yamllint
script: yamllint $(find . -name '*.yml' -o -name '*.yaml') script: yamllint $(find . -name '*.yml' -o -name '*.yaml')
tags: tags:
- docker - docker
...@@ -36,3 +20,30 @@ deploy_devcontainer: ...@@ -36,3 +20,30 @@ deploy_devcontainer:
expire_in: 1 year expire_in: 1 year
tags: tags:
- docker - docker
.simple_ros_test:
variables:
TEMPLATES_PIPELINE_REF: $CI_COMMIT_REF_NAME
trigger:
project: tecnalia_robotics/ci_test_repos/simple_ros_test
strategy: depend
simple_ros_melodic_test:
extends: .simple_ros_test
variables:
TEMPLATE_TO_USE: ci-templates/auto-rules/melodic-default.yml
simple_ros_noetic_test:
extends: .simple_ros_test
variables:
TEMPLATE_TO_USE: ci-templates/auto-rules/noetic-default.yml
simple_ros_core_with_noetic_test:
extends: .simple_ros_test
variables:
TEMPLATE_TO_USE: test/core_with_noetic.yml
simple_ros_auto_rules_melodic_noetic_test:
extends: .simple_ros_test
variables:
TEMPLATE_TO_USE: test/auto_rules_melodic_noetic.yml
...@@ -9,11 +9,3 @@ include::ci-templates/README.adoc[leveloffset=+1] ...@@ -9,11 +9,3 @@ include::ci-templates/README.adoc[leveloffset=+1]
== Custom `rosdep` definitions == Custom `rosdep` definitions
Custom `rosdep` definitions for the packages hosted in our internal debian repository are declared in link:rosdistro/rosdep_tecnalia.yaml[]. Custom `rosdep` definitions for the packages hosted in our internal debian repository are declared in link:rosdistro/rosdep_tecnalia.yaml[].
== Deployment image build resources
Resources required for building the deployment docker images are also hosted in this repository.
This basically boils down to:
- link:scripts/pre-deploy-cleanup.bash[] is run in the `.industrial_ci_deploy` template before commiting to an image
- link:deploy/Dockerfile[] is used to perform some additional cleanup and install link:deploy/ros_entrypoint.bash[] as entrypoint script on top of the `industrial_ci` image
...@@ -17,18 +17,20 @@ The Core pipeline, defined in link:ci-templates/core.yml[], has the following st ...@@ -17,18 +17,20 @@ The Core pipeline, defined in link:ci-templates/core.yml[], has the following st
** If the package has `.rosinstall` dependencies, they can be installed using the variable `UPSTREAM_WORKSPACE` ** If the package has `.rosinstall` dependencies, they can be installed using the variable `UPSTREAM_WORKSPACE`
** Uses `flexbotics-base-devel:${ROS_DISTRO}` as a starting image ** Uses `flexbotics-base-devel:${ROS_DISTRO}` as a starting image
** Runs link:scripts/ci_run_entry_points.sh[] in the `AFTER_SETUP_TARGET_WORKSPACE` stage, which in turn finds and runs every `ci_entry_script.bash` script found in the target repo. ** Runs link:scripts/ci_run_entry_points.sh[] in the `AFTER_SETUP_TARGET_WORKSPACE` stage, which in turn finds and runs every `ci_entry_script.bash` script found in the target repo.
* `.industrial_ci_deploy` template, which: - Stage: `deploy`
** Runs `industrial_ci` by extending `.industrial_ci` * `.ddeploy` template (see https://git.code.tecnalia.dev/tecnalia_robotics/flexbotics/flexbotics_utils/ddeploy[the ddeploy repo]), which:
** Runs some cleanup in the `industrial_ci` context (e.g. delete sources) ** Is run automatically for tags, but can also be run manually on normal commits
** Commits image used by `industrial_ci` ** Calls `ddeploy` to generate the docker image
** Builds deployment image on top of it and push it to our registry ** Renames the image created by ddeploy with different tags and pushes them to the registry.
*** Tag `${COMMIT_SHA}` (hash of commit)
*** Tag `${CI_COMMIT_REF_NAME}` (branch or tag name)
*** Tag `latest` only on the default branch
- Stage: `.post` - Stage: `.post`
* Check `bash`/`sh` script syntax * Check `bash`/`sh` script syntax
* Check Markdown and AsciiDoc syntax * Check Markdown and AsciiDoc syntax
* Check files have no trailing whitespace and are `UTF-8` encoded * Check files have no trailing whitespace and are `UTF-8` encoded
* Check that `C++` files follow this link:clang-format[] * Check that `C++` files follow this link:clang-format[]
It is important to note that both templates set the variable `GIT_LFS_SKIP_SMUDGE`, which means that when the repositories are cloned/fetched, the files hosted using Git LFS will not be downloaded. An example on how to explicitely fetch the files from LFS can be found in the https://git.code.tecnalia.com/tecnalia_robotics/common_config/blob/e93dbe6379d94e6a895a33c59bf17ccab26eacf9/.gitlab-ci.yml#L132[common_config repository].
== Manual Jobs == Manual Jobs
...@@ -52,3 +54,11 @@ The auto rules also allow for using variables to explicitely activate each job: ...@@ -52,3 +54,11 @@ The auto rules also allow for using variables to explicitely activate each job:
```yml ```yml
include::examples/build_vars.yml[] include::examples/build_vars.yml[]
``` ```
If a `ddeploy.yaml` file exists, the auto-rules will add a job extending the `.ddeploy` template defined
== LFS
By default, lfs files are not downloaded. If you need to add LFS, include the link:ci-templates/lfs-pull.yml[] along with anything else:
```yml
include::examples/include_lfs.yml[]
```
\ No newline at end of file
include: ci-templates/auto-rules/no-default.yml
variables:
DEFAULT_DISTRO: humble
include: ci-templates/auto-rules/no-default.yml
variables:
DEFAULT_DISTRO: jazzy
...@@ -2,40 +2,29 @@ include: ci-templates/core.yml ...@@ -2,40 +2,29 @@ include: ci-templates/core.yml
workflow: workflow:
rules: rules:
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_NAME =~ /^kinetic-.*/ - if: $CI_COMMIT_REF_NAME =~ /^kinetic-.*/
variables: variables:
DEFAULT_DISTRO: "kinetic" DEFAULT_DISTRO: "kinetic"
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_NAME =~ /^melodic-.*/ - if: $CI_COMMIT_REF_NAME =~ /^melodic-.*/
variables: variables:
DEFAULT_DISTRO: "melodic" DEFAULT_DISTRO: "melodic"
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_NAME =~ /^noetic-.*/ - if: $CI_COMMIT_REF_NAME =~ /^noetic-.*/
variables: variables:
DEFAULT_DISTRO: "noetic" DEFAULT_DISTRO: "noetic"
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^kinetic-.*/ - if: $CI_COMMIT_REF_NAME =~ /^humble-.*/
variables: variables:
DEFAULT_DISTRO: "kinetic" DEFAULT_DISTRO: "humble"
DEPLOY: "true" - if: $CI_COMMIT_REF_NAME =~ /^jazzy-.*/
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^melodic-.*/
variables:
DEFAULT_DISTRO: "melodic"
DEPLOY: "true"
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^noetic-.*/
variables: variables:
DEFAULT_DISTRO: "noetic" DEFAULT_DISTRO: "jazzy"
DEPLOY: "true"
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
variables:
DEPLOY: "true"
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
industrial_ci_kinetic: industrial_ci_kinetic:
extends: .industrial_ci extends: .industrial_ci
variables: variables:
ROS_DISTRO: kinetic ROS_DISTRO: kinetic
rules: rules:
- if: $DEPLOY
when: never
- if: $DEFAULT_DISTRO == "kinetic" - if: $DEFAULT_DISTRO == "kinetic"
- if: $BUILD_KINETIC - if: $BUILD_KINETIC
...@@ -44,8 +33,6 @@ industrial_ci_melodic: ...@@ -44,8 +33,6 @@ industrial_ci_melodic:
variables: variables:
ROS_DISTRO: melodic ROS_DISTRO: melodic
rules: rules:
- if: $DEPLOY
when: never
- if: $DEFAULT_DISTRO == "melodic" - if: $DEFAULT_DISTRO == "melodic"
- if: $BUILD_MELODIC - if: $BUILD_MELODIC
...@@ -54,32 +41,79 @@ industrial_ci_noetic: ...@@ -54,32 +41,79 @@ industrial_ci_noetic:
variables: variables:
ROS_DISTRO: noetic ROS_DISTRO: noetic
rules: rules:
- if: $DEPLOY
when: never
- if: $DEFAULT_DISTRO == "noetic" - if: $DEFAULT_DISTRO == "noetic"
- if: $BUILD_NOETIC - if: $BUILD_NOETIC
industrial_ci_humble:
extends: .industrial_ci
variables:
ROS_DISTRO: humble
rules:
- if: $DEFAULT_DISTRO == "humble"
- if: $BUILD_HUMBLE
industrial_kinetic_deploy: industrial_ci_jazzy:
extends: extends: .industrial_ci
- industrial_ci_kinetic variables:
- .industrial_ci_deploy ROS_DISTRO: jazzy
rules: rules:
- if: $DEPLOY && $DEFAULT_DISTRO == "kinetic" - if: $DEFAULT_DISTRO == "jazzy"
- if: $DEPLOY && $BUILD_KINETIC - if: $BUILD_JAZZY
industrial_melodic_deploy: .py3_rules:
rules:
- if: $DEFAULT_DISTRO == "noetic"
when: always
- if: $BUILD_NOETIC
when: always
- if: $DEFAULT_DISTRO == "humble"
when: always
- if: $BUILD_HUMBLE
when: always
- if: $DEFAULT_DISTRO == "jazzy"
when: always
- if: $BUILD_JAZZY
when: always
py3-flake8:
extends:
- .py3_rules
- .py3-flake8
py3-flake8_extended:
extends: extends:
- industrial_ci_melodic - .py3_rules
- .industrial_ci_deploy - .py3-flake8_extended
py3-security:
extends:
- .py3_rules
- .py3-security
.py2_rules:
rules: rules:
- if: $DEPLOY && $DEFAULT_DISTRO == "melodic" - if: $DEFAULT_DISTRO == "kinetic"
- if: $DEPLOY && $BUILD_MELODIC when: always
- if: $BUILD_KINETIC
when: always
- if: $DEFAULT_DISTRO == "melodic"
when: always
- if: $BUILD_MELODIC
when: always
industrial_noetic_deploy: py2-flake8:
extends: extends:
- industrial_ci_noetic - .py2_rules
- .industrial_ci_deploy - .py2-flake8
ddeploy:
extends: .ddeploy
rules: rules:
- if: $DEPLOY && $DEFAULT_DISTRO == "noetic" - if: $CI_COMMIT_TAG
- if: $DEPLOY && $BUILD_NOETIC exists:
- ddeploy.yaml
when: always
- exists:
- ddeploy.yaml
when: manual
allow_failure: true
include: ci-templates/auto-rules/with-rosinstall/no-default.yml
variables:
DEFAULT_DISTRO: humble
include: ci-templates/auto-rules/with-rosinstall/no-default.yml
variables:
DEFAULT_DISTRO: jazzy
image: tecnalia-docker-dev.artifact.tecnalia.com/docker:git image: tecnalia-docker-dev.artifact.tecnalia.dev/docker:git
workflow: workflow:
...@@ -10,19 +10,14 @@ variables: ...@@ -10,19 +10,14 @@ variables:
TMPDIR: /builds/${CI_PROJECT_NAMESPACE} TMPDIR: /builds/${CI_PROJECT_NAMESPACE}
GIT_LFS_SKIP_SMUDGE: 1 # Avoid fetching the files from LFS when doing git fetch GIT_LFS_SKIP_SMUDGE: 1 # Avoid fetching the files from LFS when doing git fetch
services:
- name: tecnalia-docker-dev.artifact.tecnalia.com/docker:dind
alias: docker
stages: stages:
- build - build
- deploy
before_script:
- apk add --update bash coreutils tar wget
- docker login tecnalia-docker-dev.artifact.tecnalia.com -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
include: include:
- ci-templates/syntax-check.yml - ci-templates/syntax-check.yml
- ci-templates/python.yml
- ci-templates/industrial-ci-templates.yml - ci-templates/industrial-ci-templates.yml
default: default:
......
include:
- project: tecnalia_robotics-public/gitlab_templates
file:
- ci-templates/auto-rules/kinetic-default.yml
- ci-templates/lfs-pull.yml
...@@ -3,7 +3,7 @@ include: ...@@ -3,7 +3,7 @@ include:
file: ci-templates/core.yml file: ci-templates/core.yml
industrial_ci_kinetic: industrial_ci_kinetic:
extends: .industrial-ci extends: .industrial_ci
variables: variables:
ROS_DISTRO: kinetic ROS_DISTRO: kinetic
UPSTREAM_WORKSPACE: .rosinstall UPSTREAM_WORKSPACE: .rosinstall
variables:
GITLAB_TEMPLATES_BRANCH: master
.industrial_ci: .industrial_ci:
stage: build stage: build
services:
- name: tecnalia-docker-dev.artifact.tecnalia.dev/docker:dind
alias: docker
before_script: before_script:
- apk add --update bash coreutils tar - apk add --update bash coreutils tar
- git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .ci_config - git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .ci_config
- docker login ${ARTIFACT_DOCKER_URL} -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN} - docker login ${ARTIFACT_DOCKER_URL} -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
- docker login tecnalia-docker-dev.artifact.tecnalia.com -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN} - docker login tecnalia-docker-dev.artifact.tecnalia.dev -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
script: .ci_config/gitlab.sh script: .ci_config/gitlab.sh
variables: variables:
DOCKER_IMAGE: "${ARTIFACT_DOCKER_URL}/flexbotics-base-devel:${ROS_DISTRO}" DOCKER_IMAGE: "${ARTIFACT_DOCKER_URL}/flexbotics-base-devel:${ROS_DISTRO}"
ADDITIONAL_DEBS: curl ADDITIONAL_DEBS: curl
PARALLEL_BUILDS: 2 # keep this for now, since there seems to be memory limit issues in the ci VM PARALLEL_BUILDS: 2 # keep this for now, since there seems to be memory limit issues in the ci VM
AFTER_SETUP_TARGET_WORKSPACE: "rosenv && bash <(curl -Ls https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/ci_run_entry_points.sh) $$current_ws" AFTER_SETUP_TARGET_WORKSPACE: "rosenv && bash <(curl -Ls https://git.code.tecnalia.dev/tecnalia_robotics-public/gitlab_templates/raw/${GITLAB_TEMPLATES_BRANCH}/scripts/ci_run_entry_points.sh) $$current_ws"
CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Wno-ignored-attributes -Wno-int-in-bool-context CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Wno-ignored-attributes -Wno-int-in-bool-context -Wno-dev
.industrial_ci_deploy: .ddeploy:
extends: .industrial_ci stage: deploy
services:
- name: tecnalia-docker-dev.artifact.tecnalia.dev/docker:dind
alias: docker
variables: variables:
AFTER_SCRIPT: "wget -q -O - https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/pre-deploy-cleanup.bash | bash" DOCKER_PUSH_REGISTRY: ${ARTIFACT_DOCKER_URL}
DOCKER_COMMIT: industrial_ci_image DOCKER_PUSH_NAME: ${CI_PROJECT_PATH}
DOCKER_PUSH_TAG: ${CI_COMMIT_REF_NAME}
DOCKER_PUSH_USER: ${ARTIFACT_CI_USER}
DOCKER_PUSH_TOKEN: ${ARTIFACT_CI_TOKEN}
DDEPLOY_YAML: ddeploy.yaml
before_script:
- apk add --update python3 git py3-pip git-lfs bash curl jq
# forward the SSH authentication into the Docker executor
- "which ssh-agent || ( apk update && apk add openssh-client )"
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- echo "$SSH_SERVER_HOSTKEYS" > ~/.ssh/known_hosts
- chmod 700 ~/.ssh
# setup LFS authentication
- git lfs install
- git config --global credential.helper store
- echo https://$ARTIFACT_CI_USER:$ARTIFACT_CI_TOKEN@artifact.tecnalia.dev > ~/.git-credentials
- find . -type f -name .lfsconfig -exec sh -c 'cd "$(dirname "{}")" && git lfs pull' \;
- find . -type f -name .lfsconfig -exec sh -c 'cd "$(dirname "{}")" && git lfs ls-files' \;
# install ddeploy
- pip install --break-system-packages git+ssh://git@git.code.tecnalia.dev/tecnalia_robotics/flexbotics/flexbotics_utils/ddeploy.git@v0.2.0
- echo "Logging into docker registry ${ARTIFACT_DOCKER_URL} for user ${ARTIFACT_CI_USER}"
- docker login ${ARTIFACT_DOCKER_URL} -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
- echo "Logging into docker registry ${DOCKER_PUSH_REGISTRY} for user ${DOCKER_PUSH_USER}"
- docker login ${DOCKER_PUSH_REGISTRY} -u ${DOCKER_PUSH_USER} -p ${DOCKER_PUSH_TOKEN}
script: script:
- .ci_config/gitlab.sh # Run ddeploy
- cd $(mktemp -d) - GIT_LFS_SKIP_SMUDGE=0 ddeploy --yaml ${DDEPLOY_YAML}
- wget https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/-/archive/master/gitlab_templates-master.zip # Get the full name of the most recently built image
- unzip gitlab_templates-master.zip && cd gitlab_templates-master/deploy - 'DDEPLOY_IMAGE_NAME=$(docker images --format="{{.Repository}}:{{.Tag}}" | head -1)'
- cd base - curl -Ls https://git.code.tecnalia.dev/tecnalia_robotics-public/gitlab_templates/raw/${GITLAB_TEMPLATES_BRANCH}/scripts/enforce_labels.bash | bash -s -- ${DDEPLOY_IMAGE_NAME}
- chmod a+x ros_entrypoint.bash # Tag and push with the branch or tag name.
- docker build -t ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME} . - echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}"
- docker push ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME} - docker tag ${DDEPLOY_IMAGE_NAME} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}
- cd .. - docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}
- cd dev # Tag and push with commit sha
- docker build --build-arg APPLICATION_IMAGE=${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME} -t ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME}-dev . - echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}"
- docker push ${ARTIFACT_DOCKER_URL}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME}-dev - docker tag ${DDEPLOY_IMAGE_NAME} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}
- cd .. - docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}
# Tag and push with latest only if it's on the default branch
- >
if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest"
docker tag ${DDEPLOY_IMAGE_NAME} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest &&
docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest;
fi
rules: rules:
- if: $DEPLOY - if: $CI_COMMIT_TAG
when: always
- when: manual
allow_failure: true
.lfs-pull-script: &lfs-pull-script
"find $$current_ws -type f -name .lfsconfig -execdir git lfs pull \\; ;\
find $$current_ws -type f -name .lfsconfig -execdir git lfs ls-files \\; ;"
.industrial_ci:
variables:
AFTER_INIT: "bash <(curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh);\
apt install -qq -y git-lfs; \
git config --global credential.helper store; \
echo https://$ARTIFACT_CI_USER:$ARTIFACT_CI_TOKEN@artifact.tecnalia.dev > ~/.git-credentials ;"
BEFORE_INSTALL_UPSTREAM_DEPENDENCIES: *lfs-pull-script
BEFORE_INSTALL_TARGET_DEPENDENCIES: *lfs-pull-script
BEFORE_INSTALL_DOWNSTREAM_DEPENDENCIES: *lfs-pull-script
.flake8_template:
stage: build
before_script: ${PYTHON_VERSION} -m pip -q install flake8
script:
- find . -type f -executable ! -name "*.*" -exec awk ' /^#!.*python/{print FILENAME} {nextfile}' {} + > /tmp/python_files # python files with no extension but with shebang
- find . -type f -name "*.py" >> /tmp/python_files
- sort /tmp/python_files | uniq | xargs ${PYTHON_VERSION} -m flake8 --max-line-length 120 --statistics --show-source
.flake8_extended_template:
extends: .flake8_template
stage: .post
before_script:
- ${PYTHON_VERSION} -m pip install flake8 flake8-isort flake8-builtins flake8-eradicate flake8-functions-names flake8-return flake8-functions
allow_failure: true
.security_template:
stage: .post
before_script:
- ${PYTHON_VERSION} -m pip install bandit
script:
- bandit -r .
allow_failure: true
.py3_template:
image: python:3-alpine
variables:
PYTHON_VERSION: python3
.py2_template:
image: python:2-alpine
variables:
PYTHON_VERSION: python2
.py3-flake8:
extends:
- .flake8_template
- .py3_template
.py2-flake8:
extends:
- .flake8_template
- .py2_template
.py3-flake8_extended:
extends:
- .flake8_extended_template
- .py3_template
.py3-security:
extends:
- .security_template
- .py3_template
variables:
GITLAB_TEMPLATES_BRANCH: master
########################################################## ##########################################################
## Check formating of C and C++ files using clang-format ## Check formating of C and C++ files using clang-format
########################################################## ##########################################################
clang_format: clang_format:
stage: .post stage: .post
services:
- name: tecnalia-docker-dev.artifact.tecnalia.dev/docker:dind
alias: docker
before_script: before_script:
- apk add --update bash coreutils tar wget - apk add --update bash coreutils tar wget
- git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .ci_config -b legacy - git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .ci_config
- wget https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/clang-format -O .clang-format - wget https://git.code.tecnalia.dev/tecnalia_robotics-public/gitlab_templates/raw/${GITLAB_TEMPLATES_BRANCH}/clang-format -O .clang-format
script: .ci_config/gitlab.sh script: .ci_config/gitlab.sh
variables: variables:
ROS_DISTRO: kinetic ROS_DISTRO: noetic
CLANG_FORMAT_CHECK: file CLANG_FORMAT_CHECK: file
CLANG_FORMAT_VERSION: "3.8" CLANG_FORMAT_VERSION: 10
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
##########################################################
python_syntax:
before_script:
- apk add --update python2
stage: build
script: python -m compileall -q .
when: always when: always
########################################################## ##########################################################
...@@ -50,7 +44,9 @@ bash_syntax: ...@@ -50,7 +44,9 @@ bash_syntax:
########################################################## ##########################################################
markdown_syntax: markdown_syntax:
stage: .post stage: .post
script: docker run -v ${PWD}:/ac tecnalia-docker-dev.artifact.tecnalia.com/cytopia/awesome-ci syntax-markdown --path=/ac --extension=md --ignore=.ci_config --custom="-r ~MD013,~MD014" image: tecnalia-docker-dev.artifact.tecnalia.dev/cytopia/awesome-ci
script:
- syntax-markdown --path=${PWD} --extension=md --ignore=.ci_config --custom="-r ~MD013,~MD014"
when: always when: always
########################################################## ##########################################################
...@@ -61,10 +57,11 @@ markdown_syntax: ...@@ -61,10 +57,11 @@ markdown_syntax:
########################################################## ##########################################################
file_syntax: file_syntax:
stage: .post stage: .post
image: tecnalia-docker-dev.artifact.tecnalia.dev/cytopia/awesome-ci
script: script:
- RET=0 - RET=0
- docker run -v ${PWD}:/ac tecnalia-docker-dev.artifact.tecnalia.com/cytopia/awesome-ci file-trailing-space --path=/ac --extension=py,txt,cpp,h,md,sh,bash,xml,launch --ignore=.ci_config || RET=1 - file-trailing-space --path=${PWD} --extension=py,txt,cpp,h,md,sh,bash,xml,launch --ignore=.ci_config || RET=1
- docker run -v ${PWD}:/ac tecnalia-docker-dev.artifact.tecnalia.com/cytopia/awesome-ci file-utf8 --path=/ac --extension=py,txt,cpp,h,md,sh,bash,xml,launch --ignore=.ci_config || RET=1 - file-utf8 --path=${PWD} --extension=py,txt,cpp,h,md,sh,bash,xml,launch --ignore=.ci_config || RET=1
- exit $RET - exit $RET
when: always when: always
...@@ -75,9 +72,9 @@ file_syntax: ...@@ -75,9 +72,9 @@ file_syntax:
########################################################## ##########################################################
adoc_syntax: adoc_syntax:
stage: .post stage: .post
image: tecnalia-docker-dev.artifact.tecnalia.com/alpine image: tecnalia-docker-dev.artifact.tecnalia.dev/alpine
before_script: before_script:
- apk add --update curl asciidoctor bash - apk add --update curl asciidoctor bash
script: script:
- curl -Ls https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/asciidoctor_syntax_check.bash | bash -s -- . - curl -Ls https://git.code.tecnalia.dev/tecnalia_robotics-public/gitlab_templates/raw/${GITLAB_TEMPLATES_BRANCH}/scripts/asciidoctor_syntax_check.bash | bash -s -- .
when: always when: always
--- ---
# Format file from: https://github.com/davetcoleman/roscpp_code_format (bfa4ea78b4ac856da07458c8824bf5eb327ea693) # Format file from: https://github.com/PickNikRobotics/roscpp_code_format (75a84b075d648828b7aa64094699e5ab5cc7adb7)
BasedOnStyle: Google BasedOnStyle: Google
AccessModifierOffset: -2 AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2 ConstructorInitializerIndentWidth: 2
...@@ -9,9 +9,8 @@ AllowAllParametersOfDeclarationOnNextLine: false ...@@ -9,9 +9,8 @@ AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: false BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true BreakConstructorInitializersBeforeComma: true
......
FROM industrial_ci_image
RUN rm -rf /root/ici /root/src
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
ros-kinetic-rosbash \
&& rm -rf /var/lib/apt/lists/*
COPY ./ros_entrypoint.bash /
ENTRYPOINT ["/ros_entrypoint.bash"]
CMD ["bash"]
#!/bin/bash
set -e
# setup application environment
# shellcheck disable=SC1091
source "/root/target_ws/install/setup.bash"
exec "$@"
ARG APPLICATION_IMAGE
FROM ${APPLICATION_IMAGE}
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
apt-transport-https \
curl \
libasound2 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
&& mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
&& sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
code \
&& rm -rf /var/lib/apt/lists/*
RUN echo "alias code='code --user-data-dir /root'" >> /root/.bashrc
RUN code --user-data-dir /root \
--install-extension ms-iot.vscode-ros \
--install-extension joaompinto.asciidoctor-vscode \
--install-extension ms-python.python \
--install-extension ms-vscode.cpptools \
--install-extension ms-azuretools.vscode-docker \
--install-extension twxs.cmake
apriltag:
ubuntu:
xenial: [apriltag]
cvkit:
ubuntu:
xenial: [cvkit]
dynamixel: dynamixel:
ubuntu: [libdynamixel-dev] ubuntu: [libdynamixel-dev]
k4a-tools:
ubuntu:
focal: [k4a-tools]
libhalcon-dev: libhalcon-dev:
ubuntu: [libhalcon-dev] ubuntu: [libhalcon-dev]
libk4a1.3:
ubuntu:
focal: [libk4a1.3]
libk4a1.3-dev:
ubuntu:
focal: [libk4a1.3-dev]
libopenvdb_fork_dev:
ubuntu:
focal: [libopenvdb-fork-dev]
libpcl-1.8.1: libpcl-1.8.1:
ubuntu: ubuntu:
xenial: [libpcl1.8.1] xenial: [libpcl1.8.1]
libsoundio1:
ubuntu: [libsoundio1]
libvdbfusion_dev:
ubuntu:
focal: [libvdbfusion-dev]
open3d-ros-helper-pip:
ubuntu:
pip:
packages: [open3d_ros_helper]
peak: peak:
ubuntu: [libpeak-dev] ubuntu: [libpeak-dev]
phoxicontrol: phoxicontrol:
ubuntu: ubuntu:
bionic: [phoxicontrol] bionic: [phoxicontrol]
focal: [phoxicontrol]
robotnik_base_hw_lib: rc_apps_msgs:
ubuntu: [ros-kinetic-robotnik-base-hw-lib] ubuntu:
xenial: [ros-kinetic-rc-apps-msgs]
telicam-sdk:
ubuntu: [telicam-sdk]
telicam-1.1.0:
ubuntu: [libtelicam-sdk-1.1.0]
zivid:
ubuntu: [zivid]
zivid_telicam_driver:
ubuntu: [zivid-telicam-driver]
zivid_camera:
ubuntu: [ros-kinetic-zivid-camera]
rccomm_utils: rc_bagthrottler:
ubuntu: ubuntu:
xenial: [rccomm-utils] xenial: [ros-kinetic-rc-bagthrottler]
rc_parameter_collection_ros_proxy: rc_comm_utils:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-parameter-collection-ros-proxy] xenial: [ros-kinetic-rc-comm-utils]
rcimage_smoothing: rc_cv_utils:
ubuntu: ubuntu:
xenial: [rcimage-smoothing] xenial: [ros-kinetic-rc-cv-utils]
rcimagesync: rc_diagnostic:
ubuntu: ubuntu:
xenial: [rcimagesync] xenial: [ros-kinetic-rc-diagnostic]
cvkit: rc_dynamics_api:
ubuntu: ubuntu:
xenial: [cvkit] xenial: [ros-kinetic-rc-dynamics-api]
rcconsole: rc_genicam_api:
ubuntu: ubuntu:
xenial: [rcconsole] xenial: [ros-kinetic-rc-genicam-api]
rc_imagesync: rc_imagesync:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-imagesync] xenial: [ros-kinetic-rc-imagesync]
rcobjectdetection_common: rc_parameter_collection_ros_proxy:
ubuntu:
xenial: [rcobjectdetection-common]
rcsys_utils:
ubuntu: ubuntu:
xenial: [rcsys-utils] xenial: [ros-kinetic-rc-parameter-collection-ros-proxy]
rcapps_msgs: rc_statemachine:
ubuntu: ubuntu:
xenial: [rcapps-msgs] xenial: [ros-kinetic-rc-statemachine]
rcstatemachine: rc_visard_driver:
ubuntu: ubuntu:
xenial: [rcstatemachine] xenial: [ros-kinetic-rc-visard-driver]
rcparameter_collection: rcapps_msgs:
ubuntu: ubuntu:
xenial: [rcparameter-collection] xenial: [rcapps-msgs]
rc_tagdetection: rccomm_utils:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-tagdetection] xenial: [rccomm-utils]
rc_comm_utils: rcconsole:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-comm-utils] xenial: [rcconsole]
rcimage: rcimage:
ubuntu: ubuntu:
xenial: [rcimage] xenial: [rcimage]
rc_bagthrottler: rcimage_smoothing:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-bagthrottler] xenial: [rcimage-smoothing]
rc_visard_driver: rcimagesync:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-visard-driver] xenial: [rcimagesync]
rctagdetection: rcobjectdetection_common:
ubuntu: ubuntu:
xenial: [rctagdetection] xenial: [rcobjectdetection-common]
rc_objectdetection_shape: rcobjectdetection_shape_thomas:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-objectdetection-shape] xenial: [rcobjectdetection-shape-thomas]
rc_statemachine: rcobjectrendering:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-statemachine] xenial: [rcobjectrendering]
apriltag: rcparameter_collection:
ubuntu: ubuntu:
xenial: [apriltag] xenial: [rcparameter-collection]
rc_dynamics_api: rcstatemachine:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-dynamics-api] xenial: [rcstatemachine]
rc_apps_msgs: rcsys_utils:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-apps-msgs] xenial: [rcsys-utils]
rc_genicam_api: rctagdetection:
ubuntu: ubuntu:
xenial: [ros-kinetic-rc-genicam-api] xenial: [rctagdetection]
rcobjectrendering: robotnik_base_hw_lib:
ubuntu: ubuntu: [ros-kinetic-robotnik-base-hw-lib]
xenial: [rcobjectrendering]
rc_diagnostic: telicam-1.1.0:
ubuntu: ubuntu: [libtelicam-sdk-1.1.0]
xenial: [ros-kinetic-rc-diagnostic]
rcobjectdetection_shape_thomas: telicam-sdk:
ubuntu: ubuntu: [telicam-sdk]
xenial: [rcobjectdetection-shape-thomas]
rc_cv_utils: zivid:
ubuntu: ubuntu: [zivid]
xenial: [ros-kinetic-rc-cv-utils]
zivid1.8:
ubuntu: [zivid1.8]
zivid_telicam_driver:
ubuntu: [zivid-telicam-driver]