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

build: INFENG-926: Fix version.sh version string output #10085

Merged
merged 16 commits into from
Oct 21, 2024

Conversation

davidfluck-hpe
Copy link
Contributor

@davidfluck-hpe davidfluck-hpe commented Oct 21, 2024

Ticket

INFENG-926

Description

This fixes a bug in version.sh that would cause an invalid local version string to be output under certain circumstances; specifically, if a tag were made on a commit that was not on the current branch (i.e. reachable with git-describe). This took a code path in version.sh that did not properly remove any existing tag +metadata with grep, leading to version strings like 0.751.0+dryrun+27a014b44. Note the extra plus sign (+). This causes downstream tools, like helm, to fail.

Now, we remove any existing version metadata from the final for all code paths.

This also changes all instances of \d character classes to [0-9]. This fixes a cross-platform issue where BSD grep's -E includes \d classes, while GNU grep's -E does not. This means the script worked fine on macOS, but broke subtly in CI (and I suppose on anyone's work machine that uses Linux). We avoid this entirely by falling back to standard character sets.

Test Plan

  1. Create a tag with a plus sign + in it on a commit on a branch other than this one, INFENG-926-fix-version-sh. E.g. v0.800.0+dryrun.
  2. Switch back to INFENG-926-fix-version-sh and run ./version.sh. The version string returned should have only one +metadata part, instead of two.
  3. Delete the tag you created.

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

This fixes a bug in version.sh that would cause an invalid local version
string to be output under certain circumstances; specifically, if a tag
were made on a commit that was not on the current branch (i.e. reachable
with git-describe). This took a code path in version.sh that did not
properly remove any existing tag +metadata with grep, leading to version
strings like 0.751.0+dryrun+27a014b44. Note the extra plus sign
(+). This causes downstream tools, like helm, to fail.

Now, we remove any existing version metadata from the final for all code
paths.
@cla-bot cla-bot bot added the cla-signed label Oct 21, 2024
@davidfluck-hpe davidfluck-hpe requested a review from a team October 21, 2024 15:34
Copy link

netlify bot commented Oct 21, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit 6eb386b
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/67169a4e327f920009734069

(https://circleci.com/docs/configuration-reference/#checkout), I believe
we need to add a git-fetch after checkout to grab additional refs
necessary for version.sh to work properly on CI.
Use explicit [0-9] character classes, because apparently BSD grep's -E
mode includes \d classes, while GNU grep's -E does not. This was causing
the script to run correctly on macOS, but not on Linux. Delightful.
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.39%. Comparing base (b155332) to head (6eb386b).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10085   +/-   ##
=======================================
  Coverage   54.39%   54.39%           
=======================================
  Files        1267     1267           
  Lines      159323   159323           
  Branches     3632     3630    -2     
=======================================
  Hits        86670    86670           
  Misses      72519    72519           
  Partials      134      134           
Flag Coverage Δ
backend 45.56% <ø> (ø)
harness 72.55% <ø> (ø)
web 53.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes

Remove git fetch --tags and debug version.sh invocation from
.circleci/config.yml.
@davidfluck-hpe davidfluck-hpe merged commit 4afc15f into main Oct 21, 2024
82 of 94 checks passed
@davidfluck-hpe davidfluck-hpe deleted the INFENG-926-fix-version-sh-bug branch October 21, 2024 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants