Skip to content

Commit d79a0bd

Browse files
authored
CDRIVER-5930 re-enable ABI compliance checks for r2.0 (#1977)
1 parent 0e34290 commit d79a0bd

File tree

5 files changed

+219
-43
lines changed

5 files changed

+219
-43
lines changed

.evergreen/config_generator/components/abi_compliance_check.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,49 @@
22
from shrub.v3.evg_command import s3_put
33
from shrub.v3.evg_task import EvgTask
44

5+
from config_generator.components.funcs.set_cache_dir import SetCacheDir
6+
57
from config_generator.etc.function import Function
68
from config_generator.etc.utils import bash_exec
79

810

911
class CheckABICompliance(Function):
1012
name = 'abi-compliance-check'
11-
commands = [
13+
commands = SetCacheDir.commands + [
1214
bash_exec(
1315
command_type=EvgCommandType.SETUP,
1416
working_dir='mongoc',
17+
include_expansions_in_env=['MONGO_C_DRIVER_CACHE_DIR'],
1518
script='.evergreen/scripts/abi-compliance-check-setup.sh'
1619
),
1720
bash_exec(
1821
command_type=EvgCommandType.TEST,
1922
add_expansions_to_env=True,
2023
working_dir='mongoc',
24+
include_expansions_in_env=['MONGO_C_DRIVER_CACHE_DIR'],
2125
script='.evergreen/scripts/abi-compliance-check.sh'
2226
),
2327
s3_put(
28+
command_type=EvgCommandType.SYSTEM,
2429
aws_key='${aws_key}',
2530
aws_secret='${aws_secret}',
2631
bucket='mciuploads',
2732
content_type='text/html',
2833
display_name='ABI Compliance Check: ',
2934
local_files_include_filter='abi-compliance/compat_reports/**/compat_report.html',
3035
permissions='public-read',
31-
remote_file='${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_reports/',
36+
remote_file='mongo-c-driver/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/',
37+
),
38+
s3_put(
39+
command_type=EvgCommandType.SYSTEM,
40+
aws_key='${aws_key}',
41+
aws_secret='${aws_secret}',
42+
bucket='mciuploads',
43+
content_type='text/plain',
44+
display_name='ABI Compliance Check: ',
45+
local_files_include_filter='abi-compliance/logs/**/log.txt',
46+
permissions='public-read',
47+
remote_file='mongo-c-driver/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/',
3248
),
3349
]
3450

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from config_generator.etc.function import Function
2+
from config_generator.etc.utils import bash_exec
3+
4+
from shrub.v3.evg_command import EvgCommandType, expansions_update
5+
6+
7+
class SetCacheDir(Function):
8+
name = 'set-cache-dir'
9+
commands = [
10+
bash_exec(
11+
command_type=EvgCommandType.SETUP,
12+
script='''\
13+
if [[ -n "$XDG_CACHE_DIR" ]]; then
14+
cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification.
15+
elif [[ -n "$LOCALAPPDATA" ]]; then
16+
cache_dir="$LOCALAPPDATA" # Windows.
17+
elif [[ -n "$USERPROFILE" ]]; then
18+
cache_dir="$USERPROFILE/.cache" # Windows (fallback).
19+
elif [[ -d "$HOME/Library/Caches" ]]; then
20+
cache_dir="$HOME/Library/Caches" # MacOS.
21+
elif [[ -n "$HOME" ]]; then
22+
cache_dir="$HOME/.cache" # Linux-like.
23+
elif [[ -d ~/.cache ]]; then
24+
cache_dir="~/.cache" # Linux-like (fallback).
25+
else
26+
cache_dir="$(pwd)/.cache" # EVG task directory (fallback).
27+
fi
28+
29+
mkdir -p "$cache_dir/mongo-c-driver" || exit
30+
cache_dir="$(cd "$cache_dir/mongo-c-driver" && pwd)" || exit
31+
32+
printf "MONGO_C_DRIVER_CACHE_DIR: %s\\n" "$cache_dir" >|expansions.set-cache-dir.yml
33+
''',
34+
),
35+
expansions_update(
36+
command_type=EvgCommandType.SETUP,
37+
file='expansions.set-cache-dir.yml'
38+
),
39+
]
40+
41+
42+
def functions():
43+
return SetCacheDir.defn()

.evergreen/generated_configs/functions.yml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
11
functions:
22
abi-compliance-check:
3+
- command: subprocess.exec
4+
type: setup
5+
params:
6+
binary: bash
7+
args:
8+
- -c
9+
- |
10+
if [[ -n "$XDG_CACHE_DIR" ]]; then
11+
cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification.
12+
elif [[ -n "$LOCALAPPDATA" ]]; then
13+
cache_dir="$LOCALAPPDATA" # Windows.
14+
elif [[ -n "$USERPROFILE" ]]; then
15+
cache_dir="$USERPROFILE/.cache" # Windows (fallback).
16+
elif [[ -d "$HOME/Library/Caches" ]]; then
17+
cache_dir="$HOME/Library/Caches" # MacOS.
18+
elif [[ -n "$HOME" ]]; then
19+
cache_dir="$HOME/.cache" # Linux-like.
20+
elif [[ -d ~/.cache ]]; then
21+
cache_dir="~/.cache" # Linux-like (fallback).
22+
else
23+
cache_dir="$(pwd)/.cache" # EVG task directory (fallback).
24+
fi
25+
26+
mkdir -p "$cache_dir/mongo-c-driver" || exit
27+
cache_dir="$(cd "$cache_dir/mongo-c-driver" && pwd)" || exit
28+
29+
printf "MONGO_C_DRIVER_CACHE_DIR: %s\n" "$cache_dir" >|expansions.set-cache-dir.yml
30+
- command: expansions.update
31+
type: setup
32+
params:
33+
file: expansions.set-cache-dir.yml
334
- command: subprocess.exec
435
type: setup
536
params:
637
binary: bash
738
working_dir: mongoc
39+
include_expansions_in_env:
40+
- MONGO_C_DRIVER_CACHE_DIR
841
args:
942
- -c
1043
- .evergreen/scripts/abi-compliance-check-setup.sh
@@ -14,10 +47,13 @@ functions:
1447
binary: bash
1548
working_dir: mongoc
1649
add_expansions_to_env: true
50+
include_expansions_in_env:
51+
- MONGO_C_DRIVER_CACHE_DIR
1752
args:
1853
- -c
1954
- .evergreen/scripts/abi-compliance-check.sh
2055
- command: s3.put
56+
type: system
2157
params:
2258
display_name: "ABI Compliance Check: "
2359
aws_key: ${aws_key}
@@ -26,7 +62,18 @@ functions:
2662
content_type: text/html
2763
local_files_include_filter: abi-compliance/compat_reports/**/compat_report.html
2864
permissions: public-read
29-
remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/abi-compliance/compat_reports/
65+
remote_file: mongo-c-driver/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/
66+
- command: s3.put
67+
type: system
68+
params:
69+
display_name: "ABI Compliance Check: "
70+
aws_key: ${aws_key}
71+
aws_secret: ${aws_secret}
72+
bucket: mciuploads
73+
content_type: text/plain
74+
local_files_include_filter: abi-compliance/logs/**/log.txt
75+
permissions: public-read
76+
remote_file: mongo-c-driver/${branch_name}/${revision}/${version_id}/${build_id}/${task_id}/${execution}/abi-compliance-check/
3077
backtrace:
3178
- command: subprocess.exec
3279
params:
@@ -525,6 +572,38 @@ functions:
525572
args:
526573
- -c
527574
- .evergreen/scripts/compile-scan-build.sh
575+
set-cache-dir:
576+
- command: subprocess.exec
577+
type: setup
578+
params:
579+
binary: bash
580+
args:
581+
- -c
582+
- |
583+
if [[ -n "$XDG_CACHE_DIR" ]]; then
584+
cache_dir="$XDG_CACHE_DIR" # XDG Base Directory specification.
585+
elif [[ -n "$LOCALAPPDATA" ]]; then
586+
cache_dir="$LOCALAPPDATA" # Windows.
587+
elif [[ -n "$USERPROFILE" ]]; then
588+
cache_dir="$USERPROFILE/.cache" # Windows (fallback).
589+
elif [[ -d "$HOME/Library/Caches" ]]; then
590+
cache_dir="$HOME/Library/Caches" # MacOS.
591+
elif [[ -n "$HOME" ]]; then
592+
cache_dir="$HOME/.cache" # Linux-like.
593+
elif [[ -d ~/.cache ]]; then
594+
cache_dir="~/.cache" # Linux-like (fallback).
595+
else
596+
cache_dir="$(pwd)/.cache" # EVG task directory (fallback).
597+
fi
598+
599+
mkdir -p "$cache_dir/mongo-c-driver" || exit
600+
cache_dir="$(cd "$cache_dir/mongo-c-driver" && pwd)" || exit
601+
602+
printf "MONGO_C_DRIVER_CACHE_DIR: %s\n" "$cache_dir" >|expansions.set-cache-dir.yml
603+
- command: expansions.update
604+
type: setup
605+
params:
606+
file: expansions.set-cache-dir.yml
528607
start-load-balancer:
529608
- command: subprocess.exec
530609
type: setup

.evergreen/scripts/abi-compliance-check-setup.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,30 @@ fi
1818
declare parallel_level
1919
parallel_level="$(("$(nproc)" + 1))"
2020

21+
export PATH
22+
PATH="${MONGO_C_DRIVER_CACHE_DIR:?}/bin:${PATH:-}" # abi-compliance-checker
23+
2124
# Obtain abi-compliance-checker.
2225
echo "Fetching abi-compliance-checker..."
23-
[[ -d checker ]] || {
24-
git clone -b "2.3" --depth 1 https://github.com/lvc/abi-compliance-checker.git checker
25-
pushd checker
26-
make -j "${parallel_level:?}" --no-print-directory install prefix="${working_dir:?}/install"
27-
popd # checker
26+
[[ -d "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3" ]] || {
27+
git clone -b "2.3" --depth 1 https://github.com/lvc/abi-compliance-checker.git "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3"
28+
pushd "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3"
29+
make -j "${parallel_level:?}" --no-print-directory install prefix="${MONGO_C_DRIVER_CACHE_DIR:?}"
30+
popd # "${MONGO_C_DRIVER_CACHE_DIR:?}/checker-2.3"
2831
} >/dev/null
2932
echo "Fetching abi-compliance-checker... done."
3033

3134
# Obtain ctags.
3235
echo "Fetching ctags..."
33-
[[ -d ctags ]] || {
34-
git clone -b "v6.0.0" --depth 1 https://github.com/universal-ctags/ctags.git ctags
35-
pushd ctags
36+
[[ -d "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0" ]] || {
37+
git clone -b "v6.0.0" --depth 1 https://github.com/universal-ctags/ctags.git "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0"
38+
pushd "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0"
3639
./autogen.sh
37-
./configure --prefix="${working_dir}/install"
40+
./configure --prefix="${MONGO_C_DRIVER_CACHE_DIR:?}"
3841
make -j "${parallel_level:?}"
3942
make install
40-
popd # ctags
43+
popd # "${MONGO_C_DRIVER_CACHE_DIR:?}/ctags-6.0.0"
4144
} >/dev/null
4245
echo "Fetching ctags... done."
4346

44-
command -V abi-compliance-checker
47+
command -V abi-compliance-checker
Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,110 @@
11
#!/usr/bin/env bash
22

33
set -o errexit
4+
set -o pipefail
45

56
# create all needed directories
67
mkdir abi-compliance
7-
mkdir abi-compliance/changes-install
8-
mkdir abi-compliance/latest-release-install
8+
mkdir abi-compliance/current-install
9+
mkdir abi-compliance/base-install
910
mkdir abi-compliance/dumps
1011

1112
declare head_commit today
12-
# The 10 digits of the current commit
13+
# The 10 digits of the base commit
1314
head_commit=$(git rev-parse --revs-only --short=10 "HEAD^{commit}")
1415
# The YYYYMMDD date
1516
today=$(date +%Y%m%d)
1617

17-
declare newest current
18-
current="$(cat VERSION_CURRENT)-$today+git$head_commit"
19-
newest=$(cat etc/prior_version.txt)
18+
declare current base
19+
current="$(cat VERSION_CURRENT)-${today:?}+git${head_commit:?}" # e.g. 2.3.4-dev
20+
base=$(cat etc/prior_version.txt) # e.g. 1.2.3
21+
22+
current_verdir="$(echo "${current:?}" | perl -lne 'm|^(\d+\.\d+\.\d+).*$|; print $1')" # Strip any suffixes.
23+
base_verdir="${base:?}"
24+
25+
# Double-check we are testing against the same API major version.
26+
if [[ "${base_verdir:?}" != 2.* ]]; then
27+
echo "API major version mismatch: base version is ${base:?} but current version is ${current:?}" >&2
28+
exit 1
29+
fi
2030

2131
declare working_dir
2232
working_dir="$(pwd)"
2333

2434
export PATH
25-
PATH="${working_dir:?}/install/bin:${PATH:-}"
35+
PATH="${MONGO_C_DRIVER_CACHE_DIR:?}/bin:${PATH:-}" # abi-compliance-checker
36+
37+
cmake_configure_flags=(
38+
"-DENABLE_STATIC=OFF"
39+
"-DENABLE_TESTS=OFF"
40+
"-DENABLE_EXAMPLES=OFF"
41+
)
2642

2743
# build the current changes
2844
env \
2945
CFLAGS="-g -Og" \
30-
EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/changes-install" \
46+
EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/current-install ${cmake_configure_flags[*]:?}" \
3147
.evergreen/scripts/compile.sh
3248

33-
# checkout the newest release
34-
git checkout "tags/${newest}" -f
49+
# checkout the base release
50+
git checkout "tags/${base:?}" -f
3551

36-
declare compile_script=".evergreen/scripts/compile.sh"
37-
if [[ ! -f "${compile_script}" ]]; then
38-
# Compatibility: remove once latest release contains relocated script.
39-
compile_script=".evergreen/compile.sh"
40-
fi
52+
declare compile_script
53+
compile_script=".evergreen/scripts/compile.sh"
4154

42-
# build the newest release
55+
# build the base release
4356
env \
4457
CFLAGS="-g -Og" \
45-
EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/latest-release-install" \
58+
EXTRA_CONFIGURE_FLAGS="-DCMAKE_INSTALL_PREFIX=./abi-compliance/base-install ${cmake_configure_flags[*]:?}" \
4659
bash "${compile_script}"
4760

4861
# check for abi compliance. Generates HTML Reports.
4962
cd abi-compliance
5063

5164
cat >|old.xml <<DOC
52-
<version>${newest}</version>
65+
<version>
66+
${base:?}
67+
</version>
68+
69+
<libs>
70+
$(pwd)/base-install/lib
71+
</libs>
72+
73+
<add_include_paths>
74+
$(pwd)/base-install/include/bson-${base_verdir:?}/
75+
$(pwd)/base-install/include/mongoc-${base_verdir:?}/
76+
</add_include_paths>
77+
5378
<headers>
54-
$(pwd)/latest-release-install/include/libmongoc-1.0/mongoc/mongoc.h
55-
$(pwd)/latest-release-install/include/libbson-1.0/bson/bson.h
79+
$(pwd)/base-install/include/bson-${base_verdir:?}/bson/bson.h
80+
$(pwd)/base-install/include/mongoc-${base_verdir:?}/mongoc/mongoc.h
5681
</headers>
57-
<libs>$(pwd)/latest-release-install/lib</libs>
5882
DOC
5983

6084
cat >|new.xml <<DOC
61-
<version>${current}</version>
85+
<version>
86+
${current:?}
87+
</version>
88+
89+
<libs>
90+
$(pwd)/current-install/lib
91+
</libs>
92+
93+
<add_include_paths>
94+
$(pwd)/current-install/include/bson-${current_verdir:?}/
95+
$(pwd)/current-install/include/mongoc-${current_verdir:?}/
96+
</add_include_paths>
97+
6298
<headers>
63-
$(pwd)/changes-install/include/libmongoc-1.0/mongoc/mongoc.h
64-
$(pwd)/changes-install/include/libbson-1.0/bson/bson.h
99+
$(pwd)/current-install/include/bson-${current_verdir:?}/bson/bson.h
100+
$(pwd)/current-install/include/mongoc-${current_verdir:?}/mongoc/mongoc.h
65101
</headers>
66-
<libs>$(pwd)/changes-install/lib</libs>
67102
DOC
68103

69104
# Allow task to upload the HTML report despite failed status.
70105
if ! abi-compliance-checker -lib mongo-c-driver -old old.xml -new new.xml; then
71-
: # CDRIVER-5930: re-enable task failure once 2.0.0 is released.
72-
# declare status
73-
# status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abi-compliance-checker emitted one or more errors"}'
74-
# curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true
106+
find . -name log.txt -exec cat {} + >&2 || true
107+
declare status
108+
status='{"status":"failed", "type":"test", "should_continue":true, "desc":"abi-compliance-checker emitted one or more errors"}'
109+
curl -sS -d "${status:?}" -H "Content-Type: application/json" -X POST localhost:2285/task_status || true
75110
fi

0 commit comments

Comments
 (0)