.gitlab-ci.yml 7.79 KB
Newer Older
Florian Friesdorf's avatar
Florian Friesdorf committed
1
stages:
2
  - gen-dependencies
Florian Friesdorf's avatar
Florian Friesdorf committed
3 4 5 6
  - ade
  - build
  - deploy

7
.ade_base: &ade_base
Florian Friesdorf's avatar
Florian Friesdorf committed
8 9 10
  stage: ade
  image: docker
  services:
11
    - docker:dind
Florian Friesdorf's avatar
Florian Friesdorf committed
12 13 14
  script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - apk add --update-cache git
15
    - mv ros-deps tools/ade_image
Florian Friesdorf's avatar
Florian Friesdorf committed
16
    - cd tools/ade_image
17
    - export ADE_SHA=$(find . -type f | sort | xargs sha256sum | sha256sum | rev | cut -c 4- | rev)
Florian Friesdorf's avatar
Florian Friesdorf committed
18 19 20
    - '
      if [[ -n "$FORCE" ]]; then
          chmod og-w . -R;
21 22 23 24
          docker build
              --label ade_image_commit_sha="$CI_COMMIT_SHA"
              --label ade_image_commit_tag="$CI_COMMIT_TAG"
              -t image .;
Florian Friesdorf's avatar
Florian Friesdorf committed
25 26
      else
          (
27 28
              docker pull $CI_REGISTRY_IMAGE$ARCH/ade:change-$ADE_SHA &&
              docker tag $CI_REGISTRY_IMAGE$ARCH/ade:change-$ADE_SHA image
Florian Friesdorf's avatar
Florian Friesdorf committed
29 30
          ) || (
              chmod og-w . -R;
31 32 33 34
              docker build
                  --label ade_image_commit_sha="$CI_COMMIT_SHA"
                  --label ade_image_commit_tag="$CI_COMMIT_TAG"
                  -t image .;
Florian Friesdorf's avatar
Florian Friesdorf committed
35 36 37
          );
      fi
      '
38
    - docker tag image $CI_REGISTRY_IMAGE$ARCH/ade:change-$ADE_SHA
39
    - docker tag image $CI_REGISTRY_IMAGE$ARCH/ade:commit-$CI_COMMIT_SHA
40
    - docker tag image $CI_REGISTRY_IMAGE$ARCH/ade:$CI_COMMIT_REF_NAME
41
    - docker push $CI_REGISTRY_IMAGE$ARCH/ade:change-$ADE_SHA
42
    - docker push $CI_REGISTRY_IMAGE$ARCH/ade:commit-$CI_COMMIT_SHA
43
    - docker push $CI_REGISTRY_IMAGE$ARCH/ade:$CI_COMMIT_REF_NAME
44 45 46
  after_script:
    - docker container rm -f $(docker container ls --filter "status=exited" -q)
    - docker image rm $(docker image ls -q)
Florian Friesdorf's avatar
Florian Friesdorf committed
47

48
.build_barebones_base: &build_barebones_base
Esteve Fernandez's avatar
Esteve Fernandez committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
  stage: build
  image: ubuntu:bionic
  script:
    - 'apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends
          tzdata
          gnupg
      '
    - 'apt-get update && apt-get -y --no-install-recommends install
          sudo
          curl
          gnupg2
          lsb-release
          ca-certificates
      '
    - 'curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -'
    - 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" | tee /etc/apt/sources.list.d/ros2-latest.list'
    - 'apt-get update && apt-get -y --no-install-recommends install
          python3-colcon-common-extensions
          cmake
          build-essential
          python-rosdep
70 71
          git
          clang-tidy
72 73
          ros-dashing-cyclonedds
          ros-dashing-rmw-cyclonedds-cpp
Esteve Fernandez's avatar
Esteve Fernandez committed
74 75 76 77 78 79 80 81 82
      '
    - 'rosdep init && rosdep update'
    - 'rosdep install -y --from . --ignore-src --rosdistro dashing'
    - 'source /opt/ros/dashing/setup.bash'
    - 'colcon build
           --merge-install
           --install-base /opt/AutowareAuto
      '

83
.build_base: &build_base
Florian Friesdorf's avatar
Florian Friesdorf committed
84
  stage: build
85
  image: $CI_REGISTRY_IMAGE$ARCH/ade:commit-$CI_COMMIT_SHA
Florian Friesdorf's avatar
Florian Friesdorf committed
86
  script:
87 88 89 90
    - 'apt-get update && apt-get -y --no-install-recommends install
          git
          clang-tidy
      '
91
    - 'git lfs pull --include="*" --exclude=""'
Florian Friesdorf's avatar
Florian Friesdorf committed
92 93 94 95 96 97 98 99
    # build and test
    - 'colcon build
           --merge-install
           --install-base /opt/AutowareAuto
      '
    - 'colcon test
           --merge-install
           --install-base /opt/AutowareAuto
100
           --return-code-on-test-failure
Florian Friesdorf's avatar
Florian Friesdorf committed
101 102 103 104 105
      '
    - 'colcon test-result --all |grep xml |cut -d":" -f1 |xargs .gitlab-ci/merge-test-results test-results.xml || true'

    # Test package
    - source /opt/AutowareAuto/setup.bash
106
    - 'ros2 run autoware_auto_create_pkg main.py
Florian Friesdorf's avatar
Florian Friesdorf committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
          --pkg-name my_cool_pkg
          --destination /tmp/tmp_ws/src
          --description "My cool package does cool stuff"
          --maintainer "Jane Doe"
          --email "[email protected]"
      '
    - cd /tmp/tmp_ws
    - colcon build --packages-select my_cool_pkg
    - colcon test --packages-select my_cool_pkg
    - colcon test-result --verbose
    - cd -

    # prepare volume artifact
    - mkdir /opt/AutowareAuto/src
    - '(cd src && git archive --format=tar HEAD | (cd /opt/AutowareAuto/src && tar xf -))'
    - cp -a LICENSE /opt/AutowareAuto
    - chmod -R og-w /opt/AutowareAuto
    - tar cfz opt.tar.gz /opt/AutowareAuto
125 126
  after_script:
    - colcon test-result --verbose
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148

.volume_base: &volume_base
  stage: deploy
  image: docker
  services:
    - docker:dind
  script:
    - 'echo -e "*\n!opt.tar.gz" > .dockerignore'
    - |
      cat >Dockerfile <<EOF
      FROM alpine
      ADD opt.tar.gz /
      VOLUME /opt/AutowareAuto
      CMD ["/bin/sh", "-c", "trap 'exit 147' TERM; tail -f /dev/null & wait ${!}"]
      EOF
    - 'docker build
          --label ade_image_commit_sha="$CI_COMMIT_SHA"
          --label ade_image_commit_tag="$CI_COMMIT_TAG"
          -t image .
      '
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker tag image $CI_REGISTRY_IMAGE$ARCH:commit-$CI_COMMIT_SHA
149
    - docker tag image $CI_REGISTRY_IMAGE$ARCH:$CI_COMMIT_REF_NAME
150
    - docker push $CI_REGISTRY_IMAGE$ARCH:commit-$CI_COMMIT_SHA
151
    - docker push $CI_REGISTRY_IMAGE$ARCH:$CI_COMMIT_REF_NAME
152 153 154 155 156 157 158 159 160
  after_script:
    - docker container rm -f $(docker container ls --filter "status=exited" -q)
    - docker image rm $(docker image ls -q)

generate_ros_deps:
  stage: gen-dependencies
  image: ros:dashing
  script:
    - rosdep update
161
    - rosdep install --as-root "apt:false pip:false" --simulate --reinstall --ignore-src -y --from-paths src | sort >> ros-deps
162 163 164 165
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
      - ros-deps
166 167 168 169 170

ade:
  variables:
    ARCH: ""
  <<: *ade_base
171 172 173
  needs:
    - job: generate_ros_deps
      artifacts: true
174 175 176 177 178 179 180

ade_arm64:
  variables:
    ARCH: "/arm64"
  tags:
    - arm64
  <<: *ade_base
181 182 183
  needs:
    - job: generate_ros_deps
      artifacts: true
184 185 186 187
  only:
    - [email protected]/autoware.auto/AutowareAuto

build_barebones:
188 189
  variables:
    RMW_IMPLEMENTATION: rmw_fastrtps_cpp
190
  <<: *build_barebones_base
191 192
  needs:
    - ade
193 194 195 196

build_barebones_arm64:
  tags:
    - arm64
197 198
  variables:
    RMW_IMPLEMENTATION: rmw_fastrtps_cpp
199 200 201
  <<: *build_barebones_base
  only:
    - [email protected]/autoware.auto/AutowareAuto
202 203
  needs:
    - ade_arm64
204 205 206 207

build:
  variables:
    ARCH: ""
208
    RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
209
  <<: *build_base
Florian Friesdorf's avatar
Florian Friesdorf committed
210 211 212 213 214 215 216
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
      - log
      - opt.tar.gz
    reports:
      junit: test-results.xml
217 218
  needs:
    - ade
Florian Friesdorf's avatar
Florian Friesdorf committed
219

220 221 222
build_arm64:
  variables:
    ARCH: "/arm64"
223
    RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
224 225 226 227 228 229 230 231 232 233
  tags:
    - arm64
  <<: *build_base
  artifacts:
    name: "$CI_JOB_NAME$ARCH"
    paths:
      - log
      - opt.tar.gz
  only:
    - [email protected]/autoware.auto/AutowareAuto
234 235
  needs:
    - ade_arm64
Florian Friesdorf's avatar
Florian Friesdorf committed
236 237 238 239 240

coverage:
  stage: build
  image: $CI_REGISTRY_IMAGE/ade:commit-$CI_COMMIT_SHA
  script:
241
    - './tools/coverage/coverage.sh -u'
Florian Friesdorf's avatar
Florian Friesdorf committed
242 243 244 245
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
      - coverage
246
      - log
Florian Friesdorf's avatar
Florian Friesdorf committed
247
  coverage: /\s*lines.*:\s(\d+\.\d+\%\s\(\d+\sof\s\d+.*\))/
248 249
  needs:
    - ade
Florian Friesdorf's avatar
Florian Friesdorf committed
250 251 252 253 254

docs:
  stage: build
  image: $CI_REGISTRY_IMAGE/ade:commit-$CI_COMMIT_SHA
  script:
255
    - docs/.doxygen/build.py
Florian Friesdorf's avatar
Florian Friesdorf committed
256 257 258
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
259
      - docs/_build/html
260 261
  needs:
    - ade
Florian Friesdorf's avatar
Florian Friesdorf committed
262 263 264 265 266

pages:
  stage: deploy
  image: alpine
  script:
267
    - mv docs/_build/html public
Florian Friesdorf's avatar
Florian Friesdorf committed
268 269 270 271 272 273 274
    - mv coverage public
  artifacts:
    name: "$CI_JOB_NAME"
    paths:
      - public
  only:
    - master
275 276 277
  needs:
    - coverage
    - docs
Florian Friesdorf's avatar
Florian Friesdorf committed
278 279 280 281 282

volume:
  stage: deploy
  image: docker
  services:
283
    - docker:dind
284 285
  variables:
    ARCH: ""
286
    RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
287
  <<: *volume_base
288 289 290
  needs:
    - job: build
      artifacts: true
291 292 293 294 295 296 297 298 299 300

volume_arm64:
  stage: deploy
  image: docker
  services:
    - docker:19.03.5-dind
  tags:
    - arm64
  variables:
    ARCH: "/arm64"
301
    RMW_IMPLEMENTATION: rmw_cyclonedds_cpp
302 303 304
  <<: *volume_base
  only:
    - [email protected]/autoware.auto/AutowareAuto
305 306
  needs:
    - build_arm64