industrial-ci-templates.yml 4.56 KB
Newer Older
1
2
3
4
5
6
7
.industrial_ci:
  stage: build
  before_script:
    - apk add --update bash coreutils tar
    - 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 tecnalia-docker-dev.artifact.tecnalia.com -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
8
9
10
  script:
    - .ci_config/gitlab.sh
    - docker push "${ARTIFACT_DOCKER_URL}/flexbotics-industrial-ci:${CI_COMMIT_SHORT_SHA}"
11
12
13
14
15
16
  variables:
    DOCKER_IMAGE: "${ARTIFACT_DOCKER_URL}/flexbotics-base-devel:${ROS_DISTRO}"
    ADDITIONAL_DEBS: curl
    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"
    CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Wno-ignored-attributes -Wno-int-in-bool-context
Jon Azpiazu's avatar
Jon Azpiazu committed
17
    NOT_TEST_BUILD: "true"
18
    DOCKER_COMMIT: "${ARTIFACT_DOCKER_URL}/flexbotics-industrial-ci:${CI_COMMIT_SHORT_SHA}"
Jon Azpiazu's avatar
Jon Azpiazu committed
19
20
21
22
23
    CCACHE_DIR: ${CI_PROJECT_DIR}/ccache
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - ccache
24

25
industrial_ci_test_noetic:
Jon Azpiazu's avatar
Jon Azpiazu committed
26
  stage: .post
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  before_script:
    - apk add --update bash coreutils tar
    - 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 tecnalia-docker-dev.artifact.tecnalia.com -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
    - docker pull "${ARTIFACT_DOCKER_URL}/flexbotics-industrial-ci:${CI_COMMIT_SHORT_SHA}"
  script:
    - .ci_config/gitlab.sh
  variables:
    DOCKER_IMAGE: "${ARTIFACT_DOCKER_URL}/flexbotics-base-devel:${ROS_DISTRO}"
    ADDITIONAL_DEBS: curl
    PARALLEL_BUILDS: 2 # keep this for now, since there seems to be memory limit issues in the ci VM
    CMAKE_ARGS: -DCMAKE_CXX_FLAGS=-Wno-ignored-attributes -Wno-int-in-bool-context
    ROS_DISTRO: noetic
    UPSTREAM_WORKSPACE: .rosinstall
Jon Azpiazu's avatar
Jon Azpiazu committed
42
43
44
45
46
47
48
    CCACHE_DIR: ${CI_PROJECT_DIR}/ccache
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - ccache
  tags:
    - docker
49

50
51
.ddeploy:
  stage: deploy
52
  variables:
53
54
    DOCKER_PUSH_REGISTRY: ${ARTIFACT_DOCKER_URL}
    DOCKER_PUSH_NAME: ${CI_PROJECT_PATH}
Jon Azpiazu's avatar
Jon Azpiazu committed
55
    DOCKER_PUSH_TAG: ${CI_COMMIT_REF_NAME}
56
57
    DDEPLOY_YAML: ddeploy.yaml
  before_script:
Jon Azpiazu's avatar
Jon Azpiazu committed
58
    - apk add --update python3 git py3-pip git-lfs bash curl jq
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    # 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.com > ~/.git-credentials
    # install ddeploy
    - pip install git+ssh://git@git.code.tecnalia.com/tecnalia_robotics/flexbotics/flexbotics_utils/ddeploy.git@v0.1.0
    - docker login ${ARTIFACT_DOCKER_URL} -u ${ARTIFACT_CI_USER} -p ${ARTIFACT_CI_TOKEN}
73
  script:
74
75
76
77
    # Run ddeploy
    - ddeploy --yaml ${DDEPLOY_YAML}
    # Get ID of image created by ddeploy
    - 'DOCKER_ID=$(docker images --format="{{.ID}}" | head -1)'
Jon Azpiazu's avatar
Jon Azpiazu committed
78
    - curl -Ls https://git.code.tecnalia.com/tecnalia_robotics-public/gitlab_templates/raw/master/scripts/enforce_labels.bash | bash -s -- ${DOCKER_ID}
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    # Tag and push with the branch or tag name.
    - echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}"
    - docker tag ${DOCKER_ID} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}
    - docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${DOCKER_PUSH_TAG}
    # Tag and push with commit sha
    - echo "Pushing to ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}"
    - docker tag ${DOCKER_ID} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:${CI_COMMIT_SHA}
    - 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 ${DOCKER_ID} ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest &&
        docker push ${DOCKER_PUSH_REGISTRY}/${DOCKER_PUSH_NAME}:latest;
      fi
94
  rules:
95
96
97
98
    - if: $CI_COMMIT_TAG
      when: always
    - when: manual
      allow_failure: true