.gitlab-ci.yml 8.57 KB
Newer Older
1
image: claudioandre/settings:job-502.6_fedora.dev  # temporarily pinned to old tag
2 3 4
stages:
  - build
  - test
5
  - manual
6
  - review
7
  - deploy
8

9 10 11 12 13 14 15 16 17 18 19
.Log files: &log_files  [./*.log, _build/meson-logs/]

.Build logs: &save_build_logs
  artifacts:
    name: log
    when: always
    paths: *log_files

.Git Untracked files: &save_untracked_files
  artifacts:
    name: untracked
20
    paths: [$(pwd)]
21 22
    expire_in: 3h30min

23 24 25 26
.Show Info: &environment_information
  build-aux/ci/ci-helper.sh "INFO" &&
  build-aux/ci/ci-helper.sh "GIT_INFO"

27 28 29 30 31 32
.Build procedure: &build_procedure
  echo "== Building ==" &&
  rm -rf _build/ &&
  meson . _build ${BUILD_OPTS} &&
  ninja -C _build 2>&1 | tee compilation.log

33 34 35 36
.Run Tests: &run_tests
  echo "== Testing ==" &&
  ninja -C _build test

37 38 39 40 41 42 43 44
##
# Stage: Build
#
# Checks if GNOME Control Center is properly building and installing. This is the
# most important stage of the CI, and no MR should ever be merged if it breaks
# any of them.
##
build:
45
  <<: *save_untracked_files
46
  stage: build
47

48
  script:
49
    - *environment_information
50
    - *build_procedure
51

52 53
    - echo "== Installing =="
    - ninja -C _build install
54

55
    - echo "== Report =="
56
    - build-aux/ci/ci-helper.sh "WARNINGS"
57

58 59 60
    # Save all but git-related files
    - rm -rf .git .gitignore .gitmodules

61 62 63 64 65 66
##
# Stage: Test
#
# Runs the unit tests.
##
test:
67
  <<: *save_build_logs
68
  stage: test
69

70 71 72
  dependencies:
    - build

73
  script:
74
    - *environment_information
75

76 77
    - |
      if [[ -n "${CI_COMMIT_TAG}" ]]; then
78 79
        *run_tests

80 81 82 83 84 85
        echo "== Distro Test =="
        ninja dist -C _build
      else
        echo "== Testing =="
        meson test -C _build --verbose --no-stdsplit
      fi
Claudio André's avatar
Claudio André committed
86

87 88 89 90
  except:
    variables:
      - $CI_COMMIT_TITLE =~ /^Update.*translation$/

91 92
# Runs the coverage test.
coverage:
93
  <<: *save_build_logs
94
  stage: test
95
  variables:
96
    BUILD_OPTS: "-Db_coverage=true"
97
    coverage: '/^Lines:.\d+.\d+.(\d+\.\d+\%)/'
98 99
  only:
    - master@GNOME/gnome-control-center
100 101

  script:
102
    - *environment_information
103
    - *build_procedure
104
    - *run_tests
105 106 107

    - ninja -C _build coverage-html

108 109 110 111 112
    # Parse the report to get the coverage result
    - |
      echo == Coverage ==
      sed -e 's/<[^>]*>//g' _build/meson-logs/coveragereport/index.html | tr -d ' \t' | grep -A3 -P '^Lines:$'  | tr '\n' ' '; echo

113 114 115 116
  except:
    variables:
      - $CI_COMMIT_TITLE =~ /^Update.*translation$/

117 118 119
# Runs the address sanitizer.
# - below, at the "sanitizers section"

120
##
121
# Stage: Deploy
122
#
123
# Publishes the Coverage Report generated above
124 125
##
pages:
126
  stage: deploy
127 128 129 130 131 132 133 134 135 136
  dependencies:
    - coverage
  script:
    - mv _build/meson-logs/coveragereport/ public/
  artifacts:
    paths:
      - public
  only:
    - master@GNOME/gnome-control-center

137 138 139 140 141
  except:
    variables:
      - $CRON_TASK == "BUILD_CI_IMAGES"
      - $CI_COMMIT_TITLE =~ /^Update.*translation$/

142
##
143
# Stage: Manual
Claudio André's avatar
Claudio André committed
144
#
145
# Creates a flatpak
Claudio André's avatar
Claudio André committed
146
##
147
flatpak:
148
  stage: manual
149
  image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
Claudio André's avatar
Claudio André committed
150 151 152 153
  artifacts:
    name: package
    paths:
    - $(pwd)/*.flatpak
154
    expire_in: 2 days
Claudio André's avatar
Claudio André committed
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169

  variables:
    APPID: "org.gnome.SettingsDevel"
    BUNDLE: "org.gnome.SettingsDevel.flatpak"
    MANIFEST_PATH: "org.gnome.Settings.json"
    PATCHES: "build-aux/flatpak/*.patch"
    PROJECT_FILE: "build-aux/flatpak/org.gnome.Settings.json"
    PROJECT_ID: "org.gnome.Settings"
    PROJECT_NAME: "gnome-control-center.git"
    RUNTIME_REPO: "https://sdk.gnome.org/gnome-nightly.flatpakrepo"

  script:
    - echo "== Flatpak packaging =="

    # Move needed files to the root folder
170
    - cp ${PATCHES} . || true
Claudio André's avatar
Claudio André committed
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
    - cp ${PROJECT_FILE} ${MANIFEST_PATH}

    # Make it a develoment manifest
    - sed -i -n "p; s/$PROJECT_NAME//p" ${MANIFEST_PATH}
    - >
      sed -i "s,\"app-id\" : \"$PROJECT_ID\",\"app-id\" : \"<<ID>>\",g" ${MANIFEST_PATH}
    - >
      sed -i "s,\"url\" : \"https://gitlab.gnome.org/GNOME/$PROJECT_NAME\",\"branch\" : \"<<current>>\"\,,g" ${MANIFEST_PATH}
    - >
      sed -i "s,\"url\" : \"https://gitlab.gnome.org/GNOME/\",\"path\" : \".\",g" ${MANIFEST_PATH}

    # Adjust the manifest to HEAD
    - sed -i "s,<<ID>>,$APPID,g" ${MANIFEST_PATH}
    - sed -i "s,<<current>>,origin/$CI_COMMIT_REF_NAME,g" ${MANIFEST_PATH}

    - flatpak-builder --bundle-sources --repo=devel build ${MANIFEST_PATH}
    - flatpak build-bundle devel ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${APPID}

189 190 191
  cache:
    paths:
    - .flatpak-builder/cache
192 193 194 195
  when: manual
  except:
    - tags
    - gnome-3-.*
196
    - master@GNOME/gnome-control-center
197

198 199 200 201 202 203 204 205 206 207 208 209 210 211
review:
  stage: review
  dependencies:
    - flatpak

  when: manual
  variables:
    BUNDLE: "org.gnome.SettingsDevel.flatpak"
  script:
    - echo "Generating flatpak deployment"
  artifacts:
    paths:
        - ${BUNDLE}
    expire_in: 30 days
Claudio André's avatar
Claudio André committed
212 213 214
  environment:
    name: review/$CI_COMMIT_REF_NAME
    url: https://gitlab.gnome.org/$CI_PROJECT_PATH/-/jobs/$CI_JOB_ID/artifacts/raw/${BUNDLE}
215 216 217 218
    on_stop: stop_review
  except:
    - tags
    - gnome-3-.*
219
    - master@GNOME/gnome-control-center
220 221 222 223 224

stop_review:
  stage: review
  script:
    - echo "Stopping flatpak deployment"
Claudio André's avatar
Claudio André committed
225
  when: manual
226 227 228
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop
229

230
# Runs the sanitizers [address, thread, undefined, and memory].
231 232
.sanitizer: &sanitizer
  <<: *save_build_logs
233 234
  stage: manual
  when: manual
235 236 237
  script:
    - *environment_information
    - *build_procedure
238
    - *run_tests
239

240 241 242 243
  except:
    variables:
      - $CI_COMMIT_TITLE =~ /^Update.*translation$/

244 245 246 247 248 249 250
asan:
  <<: *sanitizer
  stage: test
  when: on_success
  variables:
    BUILD_OPTS: "-Db_sanitize=address"
    LSAN_OPTIONS: "suppressions=${CI_PROJECT_DIR}/build-aux/ci/lsan.supp"
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266

tsan:
  <<: *sanitizer
  variables:
    BUILD_OPTS: "-Db_sanitize=thread"

ubsan:
  <<: *sanitizer
  variables:
    BUILD_OPTS: "-Db_sanitize=undefined"

msan:
  <<: *sanitizer
  variables:
    BUILD_OPTS: "-Db_sanitize=memory"
    CC: "clang"
267

268
# Runs multiarch build test.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
.qemu: &multiarch
  <<: *save_build_logs
  image: docker:latest
  services:
    - docker:dind

  script:
    # Register QEMU archs
    - docker run --rm --privileged multiarch/qemu-user-static:register --reset

    # Run the multiarch test job using QEMU
    - 'docker run -v $(pwd):/cwd $IMAGE bash -e -c "cd /cwd &&
         echo == Building == &&
         rm -rf _build/ &&
         meson . _build ${BUILD_OPTS} &&
         ninja -C _build 2>&1 | tee compilation.log &&

         echo == Testing == &&
         ninja -C _build test"
    '

290 291 292 293
  except:
    variables:
      - $CI_COMMIT_TITLE =~ /^Update.*translation$/

294 295
armv8:
  <<: *multiarch
296 297
  stage: manual
  when: manual
298 299 300 301 302 303
  variables:
    DOCKER_DRIVER: overlay
    IMAGE: "claudioandre/settings:fedora.aarch64"

ppc64le:
  <<: *multiarch
304 305
  stage: manual
  when: manual
306
  allow_failure: true
307 308 309
  variables:
    DOCKER_DRIVER: overlay
    IMAGE: "claudioandre/settings:fedora.ppc64le"
310 311 312 313 314 315

#############################################
#          Create CI Docker Images          #
#############################################
.Docker image template: &create_docker_image
  image: docker:latest
316
  stage: deploy
317 318 319 320 321 322 323 324 325
  services:
    - docker:dind
  only:
    variables:
      - $CRON_TASK == "BUILD_CI_IMAGES"

  script:
    # Skip the build (if requested)
    - |
326
      if [[ -z "${CI_COMMIT_MESSAGE##*[skip images]*}" && -z "${CI_COMMIT_MESSAGE##*[$NAME]*}" ]]; then
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
        echo "== Nothing to do =="
        exit 0
      fi

    # Get multiarch stuff
    - |
      if [[ -n "${TARGET_ARCH}" ]]; then
        docker run --rm --privileged multiarch/qemu-user-static:register --reset
        wget https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0/x86_64_qemu-${TARGET_ARCH}-static.tar.gz
      fi

    # Build using the Dockerfile
    - docker build -f "$DOCKERFILE" -t "$CI_REGISTRY_IMAGE:$NAME" .

    # Prepare to publish
    - docker tag "$CI_REGISTRY_IMAGE:$NAME" "$CI_REGISTRY_IMAGE:job-"$CI_JOB_ID"_$NAME"
    - docker images
    - docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}

    # Publish (if running on a schedule)
    - |
      if [[ "${CI_PIPELINE_SOURCE}" == "schedule" ]]; then
        docker push "$CI_REGISTRY_IMAGE"
      fi

fedora.dev:
  <<: *create_docker_image
  variables:
    DOCKER_DRIVER: overlay
    DOCKERFILE: "build-aux/ci/Dockerfile.fedora.rawhide"
    NAME: "fedora.dev"

fedora.aarch64:
  <<: *create_docker_image
  variables:
    DOCKER_DRIVER: overlay
    DOCKERFILE: "build-aux/ci/Dockerfile.arm64v8.fedora.rawhide"
    NAME: "fedora.aarch64"
    TARGET_ARCH: "aarch64"

fedora.ppc64le:
  <<: *create_docker_image
  variables:
    DOCKER_DRIVER: overlay
    DOCKERFILE: "build-aux/ci/Dockerfile.ppc64le.fedora.rawhide"
    NAME: "fedora.ppc64le"
    TARGET_ARCH: "ppc64le"