Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDRIVER-5932] Simplify version calculations #1943

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .evergreen/config_generator/components/funcs/fetch_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ class FetchSource(Function):
set -o errexit
set -o pipefail
if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then
# This is a GitHub PR or patch build, probably branched from master
if command -v python3 &>/dev/null; then
# Prefer python3 if it is available
echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
else
echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
fi
VERSION=$VERSION_CURRENT-${version_id}
VERSION=patch-${version_id}
else
VERSION=latest
fi
Expand Down
9 changes: 1 addition & 8 deletions .evergreen/generated_configs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,7 @@ functions:
set -o errexit
set -o pipefail
if [ -n "${github_pr_number}" -o "${is_patch}" = "true" ]; then
# This is a GitHub PR or patch build, probably branched from master
if command -v python3 &>/dev/null; then
# Prefer python3 if it is available
echo $(python3 ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
else
echo $(python ./build/calc_release_version.py --next-minor) > VERSION_CURRENT
fi
VERSION=$VERSION_CURRENT-${version_id}
VERSION=patch-${version_id}
else
VERSION=latest
fi
Expand Down
11 changes: 7 additions & 4 deletions .evergreen/scripts/abi-compliance-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ mkdir abi-compliance/changes-install
mkdir abi-compliance/latest-release-install
mkdir abi-compliance/dumps

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

declare newest current
newest="$(cat VERSION_RELEASED)"
current="$(cat VERSION_CURRENT)"
current="$(cat VERSION_CURRENT)-$today+git$head_commit"
newest=$(cat etc/prior_version.txt)

declare working_dir
working_dir="$(pwd)"
Expand Down
4 changes: 0 additions & 4 deletions .evergreen/scripts/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ CMAKE=$(find_cmake_latest)
# Check that a CLion user didn't accidentally convert NEWS from UTF-8 to ASCII
grep "á" NEWS > /dev/null || (echo "NEWS file appears to have lost its UTF-8 encoding?" || exit 1)

debug "Calculating release version..."
python build/calc_release_version.py >VERSION_CURRENT
python build/calc_release_version.py -p >VERSION_RELEASED

build_dir=$MONGOC_DIR/_build/for-docs
"$CMAKE" -S "$MONGOC_DIR" -B "$build_dir" \
-D ENABLE_MAN_PAGES=ON \
Expand Down
6 changes: 1 addition & 5 deletions .evergreen/scripts/build_snapshot_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ sudo mock -r ${config} --use-bootstrap-image --isolation=simple --install rpmdev
sudo mock -r ${config} --use-bootstrap-image --isolation=simple --dnf-cmd --setopt=powertools.module_hotfixes=true install utf8proc-devel

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

bare_upstream_version=$(rpmspec --srpm -q --qf '%{version}' "$spec_file")
# Upstream version in the .spec file cannot have hyphen (-); replace the current
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ CTestTestfile.cmake
_build/
dist_manifest.txt
test-results.json
VERSION_RELEASED
*.pyc

# Windows things
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include (ParseVersion)
ParseVersion ("${BUILD_VERSION}" MONGOC)
# Defines additional similar variables:
include (LoadVersion)
file (WRITE VERSION_CURRENT "${BUILD_VERSION}")
LoadVersion (VERSION_CURRENT MONGOC)

# Extended version attributes that CMake doesn't (yet) understand, which include
Expand Down
22 changes: 4 additions & 18 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ build:
LET source_dir=/opt/mongoc/source
LET build_dir=/opt/mongoc/build
COPY --dir \
src/ \
build/ \
COPYING \
CMakeLists.txt \
COPYING \
NEWS \
README.rst \
src/ \
THIRD_PARTY_NOTICES \
NEWS \
VERSION_CURRENT \
"$source_dir"
COPY +version-current/ $source_dir
ENV CCACHE_HOME=/root/.cache/ccache
RUN cmake -S "$source_dir" -B "$build_dir" -G "Ninja Multi-Config" \
-D ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \
Expand Down Expand Up @@ -115,20 +115,6 @@ test-cxx-driver:
ENV CCACHE_BASE=$source
RUN --mount=type=cache,target=$CCACHE_HOME cmake --build $build

# version-current :
# Create the VERSION_CURRENT file using Git. This file is exported as an artifact at /
version-current:
# Run on Alpine, which does this work the fastest
FROM alpine:3.18
# Install Python and Git, the only things required for this job:
RUN apk add git python3
# Copy only the .git/ directory and calc_release_version, which are enough to get the VERSION_CURRENT
COPY --dir .git/ build/calc_release_version.py /s/
# Calculate it:
RUN cd /s/ && \
python calc_release_version.py --next-minor > VERSION_CURRENT
SAVE ARTIFACT /s/VERSION_CURRENT

# PREP_CMAKE "warms up" the CMake installation cache for the current environment
PREP_CMAKE:
COMMAND
Expand Down
Loading