Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

[DISCO-2383] feat: Use SHA commit hash as version #551

Merged
merged 4 commits into from
May 10, 2023
Merged

Conversation

ncloudioj
Copy link
Collaborator

@ncloudioj ncloudioj commented May 9, 2023

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

  • This PR conforms to the Contribution Guidelines
  • This PR conforms to the Opsec policies
  • Functional and performance test coverage has been expanded and maintained
  • Documentation has been updated
  • The PR title starts with the JIRA issue reference, format [DISCO-####], and has the same title

@ncloudioj ncloudioj requested a review from a team as a code owner May 9, 2023 18:47
command: |
docker build \
-t app:build \
--build-arg VERSION="$(echo ${CIRCLE_SHA1} | cut -c -7)" .
Copy link
Collaborator Author

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 && \
Copy link
Collaborator Author

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("/")));
Copy link
Collaborator Author

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.

src/main.rs Show resolved Hide resolved
@Trinaa
Copy link
Collaborator

Trinaa commented May 9, 2023

In the CircleCI config write-version command we assign 'CIRCLE_TAG' to the 'version' field, should that be empty now?

@Trinaa Trinaa requested a review from a team May 9, 2023 20:19
@taddes taddes changed the title [DISCO-2383] feat: Use SHA commit hash as versoin [DISCO-2383] feat: Use SHA commit hash as version May 9, 2023
@ncloudioj
Copy link
Collaborator Author

In the CircleCI config write-version command we assign 'CIRCLE_TAG' to the 'version' field, should that be empty now?

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 write-version and it returns.

$ 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"
}

@ncloudioj ncloudioj merged commit eae82ee into main May 10, 2023
@ncloudioj ncloudioj deleted the disco-2383 branch May 10, 2023 14:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants