-
Notifications
You must be signed in to change notification settings - Fork 2
[DISCO-2383] feat: Use SHA commit hash as version #551
Conversation
command: | | ||
docker build \ | ||
-t app:build \ | ||
--build-arg VERSION="$(echo ${CIRCLE_SHA1} | cut -c -7)" . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I opted to use the short version of SHA1 here as it's identifying enough and can save a lot of space.
@@ -19,7 +23,7 @@ RUN \ | |||
cargo --version && \ | |||
rustc --version && \ | |||
mkdir -m 755 bin && \ | |||
cargo build --release && \ | |||
CONTILE_VERSION=${VERSION} cargo build --release && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, $CONTILE_VERSION
is only used at compile time, so it's only referenced when we build Contile.
"version".to_owned(), | ||
Value::String(env!("CARGO_PKG_VERSION").to_owned()), | ||
); | ||
checklist.insert("version".to_owned(), Value::String(create_app_version("/"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that apart from CARGO_PKG_VERSION
, CARGO_PKG_NAME
is also included in this field which I assume should be fine to do here.
In the CircleCI config |
Per Circle's doc, it will be an empty string if the build was not tagged (which we will be doing onwards), so we're good here. FWIW, Merino uses the same for $ curl https://merino.services.mozilla.com/__version__ | jq .
{
"source": "https://github.com/mozilla-services/merino-py",
"version": "",
"commit": "4dd482f7faf1a6667c4770da85850bd463b64232",
"build": "https://circleci.com/gh/mozilla-services/merino-py/8433"
} |
References
JIRA: DISCO-2383
GitHub: N/A
Description
This patch replaces all the version strings from Cargo.toml in Contile with
$CIRCLECI_SHA1
including Sentry, logging, Dockerflow, and outbound traffic. Note that it uses the short SHA1 (the leading 7 characters) rather than the original 40 characters string.PR Review Checklist
Put an
x
in the boxes that apply[DISCO-####]
, and has the same title