Skip to content

Commit

Permalink
RUST-1932 Integrate release process with papertrail (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
abr-egn authored May 1, 2024
1 parent 7b66c3b commit 9040625
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 22 deletions.
11 changes: 9 additions & 2 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1511,12 +1511,19 @@ functions:
.evergreen/run-plain-tests.sh
"prepare resources":
- command: subprocess.exec
params:
working_dir: src
include_expansions_in_env:
- DRIVERS_TOOLS
binary: bash
args:
- .evergreen/fetch-drivers-tools.sh

- command: shell.exec
params:
script: |
${PREPARE_SHELL}
rm -rf $DRIVERS_TOOLS
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
"install rust":
Expand Down
11 changes: 11 additions & 0 deletions .evergreen/fetch-drivers-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -o errexit

if [[ -z "$DRIVERS_TOOLS" ]]; then
echo >&2 "\$DRIVERS_TOOLS must be set"
exit 1
fi

rm -rf $DRIVERS_TOOLS
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
18 changes: 18 additions & 0 deletions .evergreen/release-build-papertrail-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -o errexit
set +x

. ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/rust
rm secrets-export.sh

PAPERTRAIL_PRODUCT="rust-driver"
if [[ "${DRY_RUN}" == "yes" ]]; then
PAPERTRAIL_PRODUCT="rust-driver-testing"
fi

cat <<EOT >papertrail-expansion.yml
PAPERTRAIL_KEY_ID: "${PAPERTRAIL_KEY_ID}"
PAPERTRAIL_SECRET_KEY: "${PAPERTRAIL_SECRET_KEY}"
PAPERTRAIL_PRODUCT: "${PAPERTRAIL_PRODUCT}"
EOT
10 changes: 7 additions & 3 deletions .evergreen/release-danger-do-not-run-manually.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ set +x

set -o errexit

if [[ -z "$TOKEN" ]]; then
echo >&2 "\$TOKEN must be set to the crates.io authentication token"
if [[ -z "$CRATES_IO_TOKEN" ]]; then
echo >&2 "\$CRATES_IO_TOKEN must be set to the crates.io authentication token"
exit 1
fi

Expand All @@ -25,4 +25,8 @@ if [[ "${DRY_RUN}" == "yes" ]]; then
EXTRA="--dry-run"
fi

cargo publish --token $TOKEN ${EXTRA}
if [[ "${PACKAGE_ONLY}" == "yes" ]]; then
cargo package --no-verify --allow-dirty
else
cargo publish --token $CRATES_IO_TOKEN ${EXTRA}
fi
105 changes: 88 additions & 17 deletions .evergreen/releases.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
## Testing changes to this file
#
# You'll need to know the git tag of the most recent release; call that ${TAG}.
#
# The simplest way is to develop changes as a branch from the most recent release;
# in that case, a release dry-run can be executed via:
#
# evergreen patch --path .evergreen/releases.yml \
# -t publish-release -v all \
# -p mongo-rust-driver-current \
# -u --browse \
# --param triggered_by_git_tag=${TAG} \
# --param DRY_RUN=yes
#
# If the changes need to be developed against the main branch, more steps are needed:
#
# 1. Add dummy version numbers to the Cargo.toml lines for action_macro, bson, and libmongocrypt
# 2. Comment out the "fetch tag" func call from the "publish-release" task in this file
# 3. Execute:
#
# evergreen patch --path .evergreen/releases.yml \
# -t publish-release -v all \
# -p mongo-rust-driver \
# -u --browse \
# --param triggered_by_git_tag=${TAG} \
# --param DRY_RUN=yes \
# --param PACKAGE_ONLY=yes
#
# Make sure to remove the changes from 1 and 2 before merging!


exec_timeout_secs: 3600

functions:
Expand All @@ -12,9 +43,12 @@ functions:
working_dir: "src"
script: |
export PROJECT_DIRECTORY="$(pwd)"
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
cat <<EOT > expansion.yml
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
GIT_TAG: "${triggered_by_git_tag}"
PREPARE_SHELL: |
set -o errexit
set -o xtrace
Expand All @@ -40,45 +74,82 @@ functions:
rm expansion.yml
"install dependencies":
command: shell.exec
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
.evergreen/install-dependencies.sh rust
- command: shell.exec
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
.evergreen/install-dependencies.sh rust
- command: subprocess.exec
params:
working_dir: src
include_expansions_in_env:
- DRIVERS_TOOLS
binary: bash
args:
- .evergreen/fetch-drivers-tools.sh

"build papertrail vars":
- command: subprocess.exec
params:
working_dir: src
include_expansions_in_env:
- DRIVERS_TOOLS
- DRY_RUN
- GIT_TAG
binary: bash
args:
- .evergreen/release-build-papertrail-vars.sh

- command: expansions.update
params:
file: src/papertrail-expansion.yml

- command: shell.exec
params:
working_dir: "src"
script: rm papertrail-expansion.yml

"fetch tag":
command: subprocess.exec
params:
working_dir: "src"
add_expansions_to_env: true
include_expansions_in_env:
- GIT_TAG
binary: bash
args:
- .evergreen/release-fetch-tag.sh

"publish release":
- command: shell.exec
- command: subprocess.exec
type: test
params:
working_dir: "src"
script: |
set +x
add_expansions_to_env: true
binary: bash
args:
- .evergreen/release-danger-do-not-run-manually.sh

TAG=${GIT_TAG} \
TOKEN=${CRATES_IO_TOKEN} \
DRY_RUN=${DRY_RUN} \
PROJECT_DIRECTORY="$(pwd)" \
bash .evergreen/release-danger-do-not-run-manually.sh
"publish papertrail":
- command: papertrail.trace
params:
key_id: ${PAPERTRAIL_KEY_ID}
secret_key: ${PAPERTRAIL_SECRET_KEY}
product: ${PAPERTRAIL_PRODUCT}
version: ${GIT_TAG}
filenames:
- src/target/package/mongodb-*.crate

tasks:
- name: "publish-release"
commands:
- func: "fetch source"
- func: "install dependencies"
- func: "fetch tag"
vars:
GIT_TAG: ${triggered_by_git_tag}
- func: "build papertrail vars"
- func: "publish release"
- func: "publish papertrail"

axes:
- id: "os"
Expand Down

0 comments on commit 9040625

Please sign in to comment.