[at-spi2-core: 16/32] Initial scripts for continuous integration (CI)
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core: 16/32] Initial scripts for continuous integration (CI)
- Date: Tue, 14 Dec 2021 22:30:57 +0000 (UTC)
commit 50da2d038cbdd621c3f4a3a563028529771df5f1
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Dec 13 16:48:13 2021 -0600
Initial scripts for continuous integration (CI)
.gitlab-ci.yml | 214 +++++++++++++++++++++++++++++++++++
.gitlab-ci/gen-coverage.sh | 30 +++++
.gitlab-ci/lcovrc | 13 +++
.gitlab-ci/run-style-check.sh | 33 ++++++
.gitlab-ci/run-tests.sh | 16 +++
.gitlab-ci/search-common-ancestor.sh | 36 ++++++
6 files changed, 342 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..a9ec9823
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,214 @@
+variables:
+
+stages:
+# - style-check
+ - build
+ - analysis
+ - docs
+ - deploy
+
+.only-default:
+ variables:
+ PROJECT_DEPS:
+ gcc
+ dbus-1
+ dbus-1-devel
+ gettext
+ git
+ glib2-devel
+ gobject-introspection-devel
+ gsettings-desktop-schemas
+ itstool
+ libxml2-devel
+ libxkbcommon-devel
+ libXi-devel
+ libXtst-devel
+ meson
+ ninja
+ python38
+ python38-gobject
+ only:
+ - merge_requests
+ - branches
+ except:
+ - tags
+
+# style-check-diff:
+# extends: .only-default
+# image: fedora:latest
+# stage: style-check
+# script:
+# - dnf install -y clang-tools-extra curl diffutils git
+# - sh -x ./.gitlab-ci/run-style-check.sh
+
+# Recipe for setting up the build
+# @PROJECT_DEPS: the dependencies of the project (on openSUSE)
+# @MESON_VERSION: the version of Meson required by the project
+.build-setup:
+ image: opensuse/tumbleweed
+ extends: .only-default
+ before_script:
+ - zypper refresh
+ - zypper install -y ${PROJECT_DEPS} ${EXTRA_DEPS}
+
+# Default build recipe
+# @PROJECT_DEPS: the dependencies of the project (on openSUSE)
+# @MESON_VERSION: the version of Meson required by the project
+# @MESON_EXTRA_FLAGS: extra arguments for the meson setup invocation
+.build-default:
+ image: opensuse/tumbleweed
+ extends: .only-default
+ before_script:
+ - zypper refresh
+ - zypper install -y ${PROJECT_DEPS} ${EXTRA_DEPS}
+ script:
+ - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build .
+ - meson compile -C _build
+ - meson install -C _build
+ - dbus-run-session -- .gitlab-ci/run-tests.sh
+ artifacts:
+ reports:
+ junit: "_build/meson-logs/testlog.junit.xml"
+ when: always
+ name: "at-spi2-core-${CI_COMMIT_REF_NAME}"
+ paths:
+ - "${CI_PROJECT_DIR}/_build/meson-logs"
+ - "${CI_PROJECT_DIR}/_build/atspi/Atspi-2.0.gir"
+
+# Inherit to build the API reference via gi-docgen
+# @PROJECT_DEPS: the dependencies of the project (on Fedora)
+# @MESON_VERSION: the version of Meson required by the project
+# @MESON_EXTRA_FLAGS: extra arguments for the meson setup invocation
+# @DOCS_FLAGS: doc-related arguments for the meson setup invocation
+# @DOCS_PATH: the docs output directory under the build directory
+# .gidocgen-build:
+# image: fedora:latest
+# before_script:
+# - export PATH="$HOME/.local/bin:$PATH"
+# - dnf install -y python3 python3-pip python3-wheel gobject-introspection-devel graphviz ninja-build
redhat-rpm-config
+# - dnf install -y ${PROJECT_DEPS}
+# - pip3 install --user meson==${MESON_VERSION} gi-docgen jinja2 Markdown markupsafe pygments toml
typogrify
+# script:
+# - meson setup ${MESON_EXTRA_FLAGS} ${DOCS_FLAGS} _docs .
+# - meson compile -C _docs
+# - |
+# pushd "_docs/${DOCS_PATH}" > /dev/null
+# tar cf ${CI_PROJECT_NAME}-docs.tar .
+# popd > /dev/null
+# - mv _docs/${DOCS_PATH}/${CI_PROJECT_NAME}-docs.tar .
+# artifacts:
+# when: always
+# name: 'Documentation'
+# expose_as: 'Download the API reference'
+# paths:
+# - ${CI_PROJECT_NAME}-docs.tar
+
+opensuse-x86_64:
+ extends: .build-default
+ stage: build
+ needs: []
+ variables:
+ MESON_EXTRA_FLAGS: "--buildtype=debug" # -Dwerror=true
+
+static-scan:
+ extends: .build-setup
+ stage: analysis
+ needs: []
+ variables:
+ EXTRA_DEPS:
+ clang
+ clang-tools
+ MESON_EXTRA_FLAGS: "--buildtype=debug -Dintrospection=no -Ddocs=false"
+ script:
+ - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _scan_build .
+ - ninja -C _scan_build scan-build
+ artifacts:
+ name: "at-spi2-core-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
+ when: always
+ paths:
+ - "_scan_build/meson-logs/scanbuild"
+
+asan-build:
+ extends: .build-setup
+ stage: analysis
+ needs: []
+ variables:
+ EXTRA_DEPS:
+ clang-tools
+ libasan6
+ MESON_EXTRA_FLAGS: "--buildtype=debug -Db_sanitize=address -Db_lundef=false -Dintrospection=no
-Ddocs=false"
+ script:
+ - CC=clang meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build .
+ - meson compile -C _build
+ - dbus-run-session -- .gitlab-ci/run-tests.sh
+ artifacts:
+ name: "at-spi2-core-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
+ when: always
+ paths:
+ - "_asan_build/meson-logs"
+ allow_failure: true
+
+coverage:
+ extends: .build-setup
+ stage: analysis
+ needs: []
+ variables:
+ EXTRA_DEPS:
+ lcov
+ MESON_EXTRA_FLAGS: "--buildtype=debug -Ddocs=false -Dintrospection=no"
+ CFLAGS: "-coverage -ftest-coverage -fprofile-arcs"
+ script:
+ - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build .
+ - meson compile -C _build
+ - meson install -C _build
+ - mkdir -p _coverage
+ - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file
"_coverage/${CI_JOB_NAME}-baseline.lcov"
+ - dbus-run-session -- .gitlab-ci/run-tests.sh
+ - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file
"_coverage/${CI_JOB_NAME}.lcov"
+ - bash -x .gitlab-ci/gen-coverage.sh
+ coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
+ artifacts:
+ name: "at-spi2-core-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
+ when: always
+ paths:
+ - "_build/meson-logs"
+ - "_coverage"
+
+# reference:
+# stage: docs
+# needs: []
+# extends: .gidocgen-build
+# variables:
+# PROJECT_DEPS:
+# gdk-pixbuf2-devel
+# geocode-glib-devel
+# gettext
+# git
+# gobject-introspection-devel
+# itstool
+# libsoup-devel
+# libxml2-devel
+# ninja-build
+# pylint
+# python3
+# python3-gobject
+# python3-pip
+# python3-wheel
+# redhat-rpm-config
+# vala
+# MESON_VERSION: "0.55.3"
+# DOCS_FLAGS: -Dgtk_doc=true
+# DOCS_PATH: doc/libgweather-4.0
+#
+# pages:
+# stage: deploy
+# needs: ['reference']
+# script:
+# - mkdir public && cd public
+# - tar xf ../${CI_PROJECT_NAME}-docs.tar
+# artifacts:
+# paths:
+# - public
+# only:
+# - master
+# - main
diff --git a/.gitlab-ci/gen-coverage.sh b/.gitlab-ci/gen-coverage.sh
new file mode 100644
index 00000000..39492565
--- /dev/null
+++ b/.gitlab-ci/gen-coverage.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+
+for path in _coverage/*.lcov; do
+ lcov --config-file .gitlab-ci/lcovrc -r "${path}" '*/_build/*' -o "$(pwd)/${path}"
+ lcov --config-file .gitlab-ci/lcovrc -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}"
+done
+
+genhtml \
+ --ignore-errors=source \
+ --config-file .gitlab-ci/lcovrc \
+ _coverage/*.lcov \
+ -o _coverage/coverage
+
+cd _coverage
+rm -f ./*.lcov
+
+cat >index.html <<EOL
+<html>
+<head><title>at-spi2-core Coverage</title></head>
+<body>
+<div>
+<ul>
+<li><a href="coverage/index.html">Coverage report</a></li>
+</ul>
+</div>
+</body>
+</html>
+EOL
diff --git a/.gitlab-ci/lcovrc b/.gitlab-ci/lcovrc
new file mode 100644
index 00000000..ac5997b7
--- /dev/null
+++ b/.gitlab-ci/lcovrc
@@ -0,0 +1,13 @@
+# lcov and genhtml configuration
+# See http://ltp.sourceforge.net/coverage/lcov/lcovrc.5.php
+
+# Always enable branch coverage
+lcov_branch_coverage = 1
+
+# Exclude precondition assertions, as we can never reasonably get full branch
+# coverage of them, as they should never normally fail.
+# See https://github.com/linux-test-project/lcov/issues/44
+lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_
+
+# Similarly for unreachable assertions.
+lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached
diff --git a/.gitlab-ci/run-style-check.sh b/.gitlab-ci/run-style-check.sh
new file mode 100755
index 00000000..9d741bcc
--- /dev/null
+++ b/.gitlab-ci/run-style-check.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+set -e
+
+ancestor_horizon=28 # days (4 weeks)
+
+# Wrap everything in a subshell so we can propagate the exit status.
+(
+
+source .gitlab-ci/search-common-ancestor.sh
+
+git diff -U0 --no-color "${newest_common_ancestor_sha}" atspi/*.c bus/*.c dbind/*.c registryd/*.c test/*.c |
clang-format-diff -p1 > format-diff.log
+
+)
+exit_status=$?
+
+[ ${exit_status} == 0 ] || exit ${exit_status}
+
+format_diff="$(<format-diff.log)"
+
+if [ -n "${format_diff}" ]; then
+ echo 'body=```diff' > format.log
+ cat format-diff.log >> format.log
+ echo '```' >> format.log
+ [ -n "$CI_MERGE_REQUEST_IID" ] && curl \
+ --request POST \
+ --header "Private-Token: $STYLE_CHECK_TOKEN" \
+ --data-urlencode "$(<format.log)" \
+ https://gitlab.gnome.org/api/v4/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes \
+ --insecure
+ unlink format.log
+ exit 1
+fi
diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh
new file mode 100755
index 00000000..366bdc3a
--- /dev/null
+++ b/.gitlab-ci/run-tests.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+echo "About to run the tests. First we'll launch the accessibility bus by calling GetAddress:"
+
+dbus-send --print-reply --session --dest=org.a11y.Bus /org/a11y/bus org.a11y.Bus.GetAddress
+
+ps auxwww
+
+echo "Now running the tests:"
+
+meson test -C _build
+
+echo "After the tests - calling GetAddress again:"
+
+dbus-send --print-reply --session --dest=org.a11y.Bus /org/a11y/bus org.a11y.Bus.GetAddress
+
diff --git a/.gitlab-ci/search-common-ancestor.sh b/.gitlab-ci/search-common-ancestor.sh
new file mode 100755
index 00000000..bac99d2c
--- /dev/null
+++ b/.gitlab-ci/search-common-ancestor.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+set -e
+
+ancestor_horizon=28 # days (4 weeks)
+
+# We need to add a new remote for the upstream target branch, since this script
+# could be running in a personal fork of the repository which has out of date
+# branches.
+#
+# Limit the fetch to a certain date horizon to limit the amount of data we get.
+# If the branch was forked from origin/main before this horizon, it should
+# probably be rebased.
+if ! git ls-remote --exit-code upstream >/dev/null 2>&1 ; then
+ git remote add upstream https://gitlab.gnome.org/GNOME/${CI_PROJECT_NAME}.git
+fi
+git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" upstream
+
+# Work out the newest common ancestor between the detached HEAD that this CI job
+# has checked out, and the upstream target branch (which will typically be
+# `upstream/main` or `upstream/gnome-40`).
+# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` or `${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}`
+# are only defined if we’re running in a merge request pipeline,
+# fall back to `${CI_DEFAULT_BRANCH}` or `${CI_COMMIT_BRANCH}` respectively
+# otherwise.
+
+source_branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_BRANCH}}"
+git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" origin "${source_branch}"
+
+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
"origin/${source_branch}") | head -1)
+if [ -z "${newest_common_ancestor_sha}" ]; then
+ echo "Couldn’t find common ancestor with upstream main branch. This typically"
+ echo "happens if you branched from main a long time ago. Please update"
+ echo "your clone, rebase, and re-push your branch."
+ exit 1
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]