From 97b5775c1f0b9af9edd8d46b7dd565d74e9451b6 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 16:42:07 +0000 Subject: [PATCH 1/8] ci: Add a separate "docs" stage Don't build the API reference on deploy; build it in a separate job, instead, so we can run it on all pipelines, and deploy it only for master. --- .gitlab-ci.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5d8aea5315..1e066f15c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,9 @@ stages: - style-check - build - - deploy + - docs - flatpak + - deploy .cache-paths: &cache-paths paths: @@ -166,18 +167,26 @@ flatpak-master:icon-browser: APPID: org.gtk.IconBrowser4 <<: *flatpak-master -pages: +reference: image: registry.gitlab.gnome.org/gnome/gtk/fedora:v13 - stage: deploy + stage: docs variables: EXTRA_MESON_FLAGS: "--buildtype=release" script: - meson ${COMMON_MESON_FLAGS} -Dgtk_doc=true _build - ninja -C _build gdk4-doc gsk4-doc gtk4-doc - - mkdir -p public/ - - mv _build/docs/reference/gdk/html/ public/gdk/ - - mv _build/docs/reference/gsk/html/ public/gsk/ - - mv _build/docs/reference/gtk/html/ public/gtk/ + - mkdir -p _reference/ + - mv _build/docs/reference/gdk/html/ _reference/gdk/ + - mv _build/docs/reference/gsk/html/ _reference/gsk/ + - mv _build/docs/reference/gtk/html/ _reference/gtk/ + artifacts: + paths: + - _reference + +pages: + stage: deploy + script: + - mv _reference/ public/ artifacts: paths: - public From 8a6d5a77bbd16edf0c0a1f227521903c0eaa0a3c Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 17:13:39 +0000 Subject: [PATCH 2/8] ci: Fix style check script Propagate the exit status from clang-format-diff.py to avoid it being overwritten by the `echo` at the end of the script. --- .gitlab-ci/run-style-check-diff.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/run-style-check-diff.sh b/.gitlab-ci/run-style-check-diff.sh index e6f54f93c6..35a1bb4a39 100755 --- a/.gitlab-ci/run-style-check-diff.sh +++ b/.gitlab-ci/run-style-check-diff.sh @@ -1,6 +1,6 @@ #!/bin/bash -set +e +set -e # We need to add a new remote for the upstream master, since this script could # be running in a personal fork of the repository which has out of date branches. @@ -13,8 +13,9 @@ git fetch upstream # # `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in # a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise. -newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}) <(git rev-list --first-parent HEAD) | head -1) +newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1) git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1 +exit_status=$? # The style check is not infallible. The clang-format configuration cannot # perfectly describe GTK’s coding style: in particular, it cannot align @@ -32,3 +33,5 @@ echo " https://gitlab.gnome.org/GNOME/gtk/blob/master/docs/CODING-STYLE" echo "Warnings from this tool can be ignored in favour of the documented " echo "coding style, or in favour of matching the style of existing" echo "surrounding code." + +exit ${exit_status} From a87966b2bf0ae3cc9f3abf30f3e58467bb2926f7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 17:15:00 +0000 Subject: [PATCH 3/8] ci: Rename the "style-check" phase to "analysis" We want to re-use it for other jobs. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e066f15c3..83d2db9a05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ stages: - - style-check + - analysis - build - docs - flatpak @@ -28,7 +28,7 @@ variables: style-check-diff: extends: .only-default image: registry.gitlab.gnome.org/gnome/gtk/fedora:v13 - stage: style-check + stage: analysis allow_failure: true script: - .gitlab-ci/run-style-check-diff.sh From 382340c15840522524fd9ef1d56527f0074c0eee Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 17:18:23 +0000 Subject: [PATCH 4/8] ci: Add clang-analyzer to the fedora build image --- .gitlab-ci/fedora.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index 1a0ca24dec..10cb2f7f6a 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -9,6 +9,7 @@ RUN dnf -y install \ cairo-gobject-devel \ ccache \ clang \ + clang-analyzer \ colord-devel \ cups-devel \ dbus-daemon \ From 92d86c4a9f198f67347cf8a6f96a3d08e89d84a0 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 17:19:08 +0000 Subject: [PATCH 5/8] ci: Update all fedora images to v14 --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83d2db9a05..f435e3d417 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,14 +27,14 @@ variables: style-check-diff: extends: .only-default - image: registry.gitlab.gnome.org/gnome/gtk/fedora:v13 + image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 stage: analysis allow_failure: true script: - .gitlab-ci/run-style-check-diff.sh fedora-x86_64: - image: registry.gitlab.gnome.org/gnome/gtk/fedora:v13 + image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 stage: build variables: EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both" @@ -66,7 +66,7 @@ fedora-x86_64: <<: *cache-paths release-build: - image: registry.gitlab.gnome.org/gnome/gtk/fedora:v13 + image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 stage: build variables: EXTRA_MESON_FLAGS: "--buildtype=release" @@ -168,7 +168,7 @@ flatpak-master:icon-browser: <<: *flatpak-master reference: - image: registry.gitlab.gnome.org/gnome/gtk/fedora:v13 + image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 stage: docs variables: EXTRA_MESON_FLAGS: "--buildtype=release" From d9608a03572e061f04c5c5b84b3baf97a93be21f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 17:57:46 +0000 Subject: [PATCH 6/8] ci: Move style-check to .pre phase We want the style checks running at the start of the CI pipeline, no need to have a specific phase for it. --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f435e3d417..1166c50f2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,4 @@ stages: - - analysis - build - docs - flatpak @@ -28,7 +27,7 @@ variables: style-check-diff: extends: .only-default image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 - stage: analysis + stage: .pre allow_failure: true script: - .gitlab-ci/run-style-check-diff.sh From 7bc50b746600646b5cbadcd614f4a0b90a3a35fa Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 19:05:07 +0000 Subject: [PATCH 7/8] ci: Update the docker wrapper script Do a better job at detecting whether we have Docker installed. --- .gitlab-ci/run-docker.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh index dc9647bd4b..ef0f56154e 100755 --- a/.gitlab-ci/run-docker.sh +++ b/.gitlab-ci/run-docker.sh @@ -85,20 +85,25 @@ else base_version="v$base_version" fi -TAG="registry.gitlab.gnome.org/gnome/gtk/${base}:${base_version}" +if [ ! -x "$(command -v docker)" ] || [ docker --help |& grep -q podman ]; then + # Docker is actually implemented by podman, and its OCI output + # is incompatible with some of the dockerd instances on GitLab + # CI runners. + echo "Using: Podman" + format="--format docker" + CMD="podman" +else + echo "Using: Docker" + format="" + CMD="sudo socker" +fi + +REGISTRY="registry.gitlab.gnome.org" +TAG="${REGISTRY}/gnome/gtk/${base}:${base_version}" if [ $build == 1 ]; then - if docker --help |& grep -q podman; then - # Docker is actually implemented by podman, and its OCI output - # is incompatible with some of the dockerd instances on GitLab - # CI runners. - format="--format docker" - else - format="" - fi - echo -e "\e[1;32mBUILDING\e[0m: ${base} as ${TAG}" - sudo docker build \ + ${CMD} build \ ${format} \ --build-arg HOST_USER_ID="$UID" \ --tag "${TAG}" \ @@ -110,16 +115,16 @@ if [ $push == 1 ]; then echo -e "\e[1;32mPUSHING\e[0m: ${base} as ${TAG}" if [ $no_login == 0 ]; then - sudo docker login registry.gitlab.gnome.org + ${CMD} login ${REGISTRY} fi - sudo docker push $TAG + ${CMD} push ${TAG} exit $? fi if [ $run == 1 ]; then echo -e "\e[1;32mRUNNING\e[0m: ${base} as ${TAG}" - sudo docker run \ + ${CMD} run \ --rm \ --volume "$(pwd)/..:/home/user/app" \ --workdir "/home/user/app" \ From 341b2a3d39c2a68ba603c8eb6b983f08a3aac65d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 25 Feb 2020 19:06:39 +0000 Subject: [PATCH 8/8] ci: Add a static analysis job Use the Clang static analysis tool. For the time being, we're going to allow it to fail, but the plan is to fix every issue it raises. --- .gitlab-ci.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1166c50f2e..c497040add 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - build + - analysis - docs - flatpak - deploy @@ -166,13 +167,26 @@ flatpak-master:icon-browser: APPID: org.gtk.IconBrowser4 <<: *flatpak-master +static-scan: + image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 + stage: analysis + variables: + EXTRA_MESON_FLAGS: "--buildtype=debug" + script: + - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} _scan_build + - ninja -C _scan_build scan-build + artifacts: + paths: + - _scan_build/meson-logs + allow_failure: true + reference: image: registry.gitlab.gnome.org/gnome/gtk/fedora:v14 stage: docs variables: EXTRA_MESON_FLAGS: "--buildtype=release" script: - - meson ${COMMON_MESON_FLAGS} -Dgtk_doc=true _build + - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} -Dgtk_doc=true _build - ninja -C _build gdk4-doc gsk4-doc gtk4-doc - mkdir -p _reference/ - mv _build/docs/reference/gdk/html/ _reference/gdk/