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

Fix CI step failure to tag Docker image with latest release version #4304

Merged
merged 2 commits into from
Jun 6, 2018

Conversation

impactmass
Copy link
Contributor

@impactmass impactmass commented Jun 6, 2018

Resolves #4305
Impact: critical
Type: bugfix

Issue

CI process fails to push the :latest tag to docker since v1.10.0. Currently reactioncommerce/reaction:latest points to v1.9.0 image.

This is caused by the sort command called on the git tags. The current sort ranks 1.9.0 higher than 1.10.0. So we never get the correct highest tag.

Solution

Adding the --version-sort flag to the sort command creates the correct tag version hierarchy.
From the man page:

-V, --version-sort
Sort version numbers.  The input lines are treated as file names in form PREFIX VERSION SUFFIX, where SUFFIX matches the regu-
lar expression "(.([A-Za-z~][A-Za-z0-9~]*)?)*".  The files are compared by their prefixes and versions (leading zeros are
ignored in version numbers, see example below).  If an input string does not match the pattern, then it is compared using the
byte compare function.  All string comparisons are performed in C locale, the locale environment setting is ignored.

Example:

$ ls sort* | sort -V
sort-1.022.tgz
sort-1.23.tgz
sort-1.23.1.tgz
sort-1.024.tgz
sort-1.024.003.
sort-1.024.003.tgz
sort-1.024.07.tgz
sort-1.024.009.tgz

How To Test

Because the code section affected is in an if condition that checks that the merge happened on a master branch, testing this PR is not so direct.

I tested that this worked by using another branch with that if statement removed. I also had to hard-code a commit SHA that is tied to the latest release in order to confirm that the command getting the CURRENT_RELEASE var works correctly. That way I could see this in the CI logs:


mkdir -p docker-cache
.circleci/bin/docker-tags "$CIRCLE_SHA1" "$CIRCLE_BRANCH" | sed 's/\//-/g' \
  > docker-cache/docker-tags.txt
cat docker-cache/docker-tags.txt


confirm-docker-tags
v1.12.1
HIGHEST_TAG: 1.12.1
latest

Breaking changes

None

For the failing CI job (Dockerfile lint), see #4306

@impactmass impactmass changed the title WIP - Fix CI step failure to tag latest with correct version WIP - Fix CI step failure to tag Docker image with latest release version Jun 6, 2018
@impactmass impactmass changed the title WIP - Fix CI step failure to tag Docker image with latest release version Fix CI step failure to tag Docker image with latest release version Jun 6, 2018
@impactmass impactmass requested review from spencern and ticean June 6, 2018 18:39
Copy link
Member

@ticean ticean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you!

@spencern spencern merged commit 71ed86b into release-1.13.0 Jun 6, 2018
@spencern spencern deleted the fix-impactmass-fix-docker-tags branch June 6, 2018 19:17
@spencern spencern mentioned this pull request Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants