Skip to content

Commit 6e2a3d8

Browse files
[CDRIVER-5932] Simplify version calculations (#1943)
* Don't update VERSION_CURRENT during fetch-source fetch-source would pull sources from the repo, and then recalculate the current version and overwrite the VERSION_CURRENT file. We will rely on VERSION_CURRENT going forward. fetch-source also tried to create a qualified name for the commit as $CURRENT_VERSION, but this was bugged and only included the commit hash on patch builds. We don't rely on this, so we'll go with just using the commit hash for now. * Remove use of VERSION_RELEASED * Remove calc_release_version and more usages thereof * Store a record of the prior version in the repository
1 parent eb9093a commit 6e2a3d8

18 files changed

+75
-610
lines changed

.evergreen/config_generator/components/funcs/fetch_source.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ class FetchSource(Function):
1818
set -o errexit
1919
set -o pipefail
2020
if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then
21-
# This is a GitHub PR or patch build, probably branched from master
22-
if command -v python3 &>/dev/null; then
23-
# Prefer python3 if it is available
24-
echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
25-
else
26-
echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
27-
fi
28-
VERSION=$VERSION_CURRENT-${version_id}
21+
VERSION=patch-${version_id}
2922
else
3023
VERSION=latest
3124
fi

.evergreen/generated_configs/functions.yml

+1-8
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,7 @@ functions:
216216
set -o errexit
217217
set -o pipefail
218218
if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then
219-
# This is a GitHub PR or patch build, probably branched from master
220-
if command -v python3 &>/dev/null; then
221-
# Prefer python3 if it is available
222-
echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
223-
else
224-
echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
225-
fi
226-
VERSION=$VERSION_CURRENT-${version_id}
219+
VERSION=patch-${version_id}
227220
else
228221
VERSION=latest
229222
fi

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ mkdir abi-compliance/changes-install
88
mkdir abi-compliance/latest-release-install
99
mkdir abi-compliance/dumps
1010

11-
python ./build/calc_release_version.py --next-minor >VERSION_CURRENT
12-
python ./build/calc_release_version.py --next-minor -p >VERSION_RELEASED
11+
declare head_commit today
12+
# The 10 digits of the current commit
13+
head_commit=$(git rev-parse --revs-only --short=10 "HEAD^{commit}")
14+
# The YYYYMMDD date
15+
today=$(date +%Y%m%d)
1316

1417
declare newest current
15-
newest="$(cat VERSION_RELEASED)"
16-
current="$(cat VERSION_CURRENT)"
18+
current="$(cat VERSION_CURRENT)-$today+git$head_commit"
19+
newest=$(cat etc/prior_version.txt)
1720

1821
declare working_dir
1922
working_dir="$(pwd)"

.evergreen/scripts/build-docs.sh

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ CMAKE=$(find_cmake_latest)
99
# Check that a CLion user didn't accidentally convert NEWS from UTF-8 to ASCII
1010
grep "á" NEWS > /dev/null || (echo "NEWS file appears to have lost its UTF-8 encoding?" || exit 1)
1111

12-
debug "Calculating release version..."
13-
python build/calc_release_version.py >VERSION_CURRENT
14-
python build/calc_release_version.py -p >VERSION_RELEASED
15-
1612
build_dir=$MONGOC_DIR/_build/for-docs
1713
"$CMAKE" -S "$MONGOC_DIR" -B "$build_dir" \
1814
-D ENABLE_MAN_PAGES=ON \

.evergreen/scripts/build_snapshot_rpm.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ sudo mock -r ${config} --use-bootstrap-image --isolation=simple --install rpmdev
8484
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --dnf-cmd --setopt=powertools.module_hotfixes=true install utf8proc-devel
8585

8686
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyin "$(pwd)" "$(pwd)/${spec_file}" /tmp
87-
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --cwd "/tmp/${build_dir}" --chroot -- /bin/sh -c "(
88-
python3.11 build/calc_release_version.py | sed -E 's/([^-]+).*/\1/' > VERSION_CURRENT ;
89-
python3.11 build/calc_release_version.py -p > VERSION_RELEASED
90-
)"
91-
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyout "/tmp/${build_dir}/VERSION_CURRENT" "/tmp/${build_dir}/VERSION_RELEASED" .
87+
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyout "/tmp/${build_dir}/VERSION_CURRENT" .
9288

9389
bare_upstream_version=$(rpmspec --srpm -q --qf '%{version}' "$spec_file")
9490
# Upstream version in the .spec file cannot have hyphen (-); replace the current

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ CTestTestfile.cmake
2020
_build/
2121
dist_manifest.txt
2222
test-results.json
23-
VERSION_RELEASED
2423
*.pyc
2524

2625
# Windows things

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ include (ParseVersion)
1616
ParseVersion ("${BUILD_VERSION}" MONGOC)
1717
# Defines additional similar variables:
1818
include (LoadVersion)
19-
file (WRITE VERSION_CURRENT "${BUILD_VERSION}")
2019
LoadVersion (VERSION_CURRENT MONGOC)
2120

2221
# Extended version attributes that CMake doesn't (yet) understand, which include

Earthfile

+4-18
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ build:
2626
LET source_dir=/opt/mongoc/source
2727
LET build_dir=/opt/mongoc/build
2828
COPY --dir \
29-
src/ \
3029
build/ \
31-
COPYING \
3230
CMakeLists.txt \
31+
COPYING \
32+
NEWS \
3333
README.rst \
34+
src/ \
3435
THIRD_PARTY_NOTICES \
35-
NEWS \
36+
VERSION_CURRENT \
3637
"$source_dir"
37-
COPY +version-current/ $source_dir
3838
ENV CCACHE_HOME=/root/.cache/ccache
3939
RUN cmake -S "$source_dir" -B "$build_dir" -G "Ninja Multi-Config" \
4040
-D ENABLE_MAINTAINER_FLAGS=ON \
@@ -113,20 +113,6 @@ test-cxx-driver:
113113
ENV CCACHE_BASE=$source
114114
RUN --mount=type=cache,target=$CCACHE_HOME cmake --build $build
115115

116-
# version-current :
117-
# Create the VERSION_CURRENT file using Git. This file is exported as an artifact at /
118-
version-current:
119-
# Run on Alpine, which does this work the fastest
120-
FROM alpine:3.18
121-
# Install Python and Git, the only things required for this job:
122-
RUN apk add git python3
123-
# Copy only the .git/ directory and calc_release_version, which are enough to get the VERSION_CURRENT
124-
COPY --dir .git/ build/calc_release_version.py /s/
125-
# Calculate it:
126-
RUN cd /s/ && \
127-
python calc_release_version.py --next-minor > VERSION_CURRENT
128-
SAVE ARTIFACT /s/VERSION_CURRENT
129-
130116
# PREP_CMAKE "warms up" the CMake installation cache for the current environment
131117
PREP_CMAKE:
132118
COMMAND

0 commit comments

Comments
 (0)