ci: add an ABI check job

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7875>
This commit is contained in:
Matthew Waters 2024-11-12 16:23:07 +11:00
parent c3d4d500e0
commit 5b32fe7b24
7 changed files with 134 additions and 0 deletions

View file

@ -37,6 +37,7 @@ variables:
INDENT_AMD64_SUFFIX: 'amd64/gst-indent' INDENT_AMD64_SUFFIX: 'amd64/gst-indent'
COMMITLINT_AMD64_SUFFIX: 'amd64/commitlint' COMMITLINT_AMD64_SUFFIX: 'amd64/commitlint'
WINDOWS_AMD64_SUFFIX: 'amd64/windows' WINDOWS_AMD64_SUFFIX: 'amd64/windows'
ABI_CHECK_AMD64_SUFFIX: 'amd64/abi-check'
WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH" WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$GST_UPSTREAM_BRANCH"
@ -263,6 +264,28 @@ windows amd64 docker:
tags: tags:
- gst-mac-arm - gst-mac-arm
.abi-check image:
variables:
CCACHE_DIR: !reference [".fedora image", "variables", CCACHE_DIR]
FDO_DISTRIBUTION_VERSION: !reference [".fedora image", "variables", FDO_DISTRIBUTION_VERSION]
FDO_REPO_SUFFIX: !reference [".fedora image", "variables", FDO_REPO_SUFFIX]
FDO_BASE_IMAGE: '$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FEDORA_TAG-$GST_UPSTREAM_BRANCH'
FDO_DISTRIBUTION_TAG: "abi-check-$ABI_CHECK_TAG-$GST_UPSTREAM_BRANCH"
FDO_DISTRIBUTION_PACKAGES: 'libabigail'
FDO_DISTRIBUTION_EXEC: 'GIT_BRANCH=$CI_COMMIT_REF_NAME GIT_URL=$CI_REPOSITORY_URL bash ci/docker/abi-check/prepare.sh'
ABI_CHECK_CACHE: '/abi-check-cache'
abi-check docker:
# placeholder-job has very minimal CPU available and may overrun the job
# timeout if an image rebuild (which builds GStreamer) needs to be performed.
#tags: [ 'placeholder-job' ]
stage: 'preparation'
extends:
- '.abi-check image'
- '.fdo.container-build@fedora'
needs:
- 'fedora amd64 docker'
# ---- Preparation ----- # # ---- Preparation ----- #
# #
# gst-indent!! # gst-indent!!
@ -701,6 +724,26 @@ build macos:
-Dgst-plugins-good:cairo=enabled -Dgst-plugins-good:cairo=enabled
-Dgst-plugins-good:soup=enabled -Dgst-plugins-good:soup=enabled
abi-check:
stage: 'build'
extends:
- '.abi-check image'
- '.fdo.suffixed-image@fedora'
- '.build'
needs:
- "trigger"
- 'abi-check docker'
script:
- $CI_PROJECT_DIR/ci/scripts/abi-check.sh build/
variables:
ABI_CHECK_DIR: 'abi-dumps'
artifacts:
expire_in: "7 days"
when: "always"
paths:
- 'meson-logs/'
- '$ABI_CHECK_DIR'
# ---- Tests ----- # # ---- Tests ----- #
.test: .test:

View file

@ -13,4 +13,6 @@ variables:
LINT_TAG: '2024-02-20.0' LINT_TAG: '2024-02-20.0'
ABI_CHECK_TAG: '2024-11-18.0'
WINDOWS_TAG: '2024-11-12.0' WINDOWS_TAG: '2024-11-12.0'

View file

@ -0,0 +1,13 @@
#! /bin/bash
set -eux
meson_args="${MESON_ARGS:-}"
install_prefix=/tmp/install
MESON_ARGS="${meson_args} --prefix ${install_prefix} --optimization=g" ./ci/scripts/build.sh build/
ninja -C build/ install
find ${install_prefix}/lib64 -type f -iname *libgst*.so.* -print0 | xargs -0 -I '{}' bash ./ci/scripts/save-abi.sh {} ${ABI_CHECK_CACHE}
rm -rf $install_prefix

View file

@ -0,0 +1,5 @@
#! /bin/bash
set -eux
bash ./ci/docker/abi-check/install-abi-check-cache.sh

37
ci/scripts/abi-check.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
set -eux
builddir="$1"
meson_args="${MESON_ARGS:-}"
if [[ -z "$builddir" ]]; then
echo "Usage: build.sh <build_directory>"
exit 1
fi
echo ${ABI_CHECK_CACHE}
echo ${ABI_CHECK_DIR}
# nproc works on linux
# sysctl for macos
_jobs=$(nproc || sysctl -n hw.ncpu)
jobs="${FDO_CI_CONCURRENT:-$_jobs}"
install_prefix=/tmp/install
MESON_ARGS="${meson_args} --prefix ${install_prefix} --optimization=g" ./ci/scripts/build.sh build/
ninja -C $builddir install
find ${install_prefix}/lib64 -type f -iname *libgst*.so.* -print0 | xargs -0 -I '{}' bash ${CI_PROJECT_DIR}/ci/scripts/save-abi.sh {} ${ABI_CHECK_DIR}
fail_file=abi-compare-failure
if ! find ${ABI_CHECK_CACHE} -type f -print0 | xargs -0 -I '{}' bash ${CI_PROJECT_DIR}/ci/scripts/compare-abi.sh {} ${CI_PROJECT_DIR}/${ABI_CHECK_DIR}/ ${fail_file}
then
echo ABI comparison failed for the following modules!
cat ${fail_file}
rm -rf $install_prefix
exit 1;
fi
rm -rf $install_prefix

24
ci/scripts/compare-abi.sh Executable file
View file

@ -0,0 +1,24 @@
#! /bin/bash
set -eux
old_abi=${1}
output_dir=${2}
output_fail_file=${3}
upstream_branch=${GST_UPSTREAM_BRANCH:-}
module=$(basename ${old_abi})
opts="--drop-private-types"
if [ "x$upstream_branch" = "xmain" ]
then
# don't error out on added symbols
opts="${opts} --no-added-syms"
fi
mkdir -p ${output_dir}
if ! abidiff ${opts} ${old_abi} ${output_dir}/${module}
then
echo ${module} >> ${output_fail_file}
exit 1;
fi

10
ci/scripts/save-abi.sh Executable file
View file

@ -0,0 +1,10 @@
#! /bin/bash
set -eux
filename=${1}
output_dir=${2}
module=$(basename ${filename} | cut -f1,2 -d'.')
mkdir -p ${output_dir}
abidw -o ${output_dir}/${module}.abi --drop-private-types ${filename}