Skip to content

🐛 set GIT_COMMIT in Makefile to populate version info #2007

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rashmigottipati
Copy link
Member

Description

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@rashmigottipati rashmigottipati requested a review from a team as a code owner June 3, 2025 20:25
Copy link

netlify bot commented Jun 3, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 852f0be
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/683f5a23baaba300091f8c32
😎 Deploy Preview https://deploy-preview-2007--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci openshift-ci bot requested review from camilamacedo86 and oceanc80 June 3, 2025 20:25
@rashmigottipati rashmigottipati changed the title 🐛 use SOURCE_GIT_COMMIT if available for the GIT_COMMIT 🐛 set GIT_COMMIT in Makefile to populate version info Jun 3, 2025
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.16%. Comparing base (8f81c23) to head (852f0be).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2007      +/-   ##
==========================================
- Coverage   69.17%   69.16%   -0.02%     
==========================================
  Files          79       79              
  Lines        7037     7037              
==========================================
- Hits         4868     4867       -1     
- Misses       1887     1888       +1     
  Partials      282      282              
Flag Coverage Δ
e2e 43.00% <ø> (ø)
unit 60.05% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joelanford
Copy link
Member

This still feels off to me from a supply chain security perspective.

Under what circumstances does it make sense for a CI system to build commit a but say that it is commit b?

Copy link
Contributor

@ankitathomas ankitathomas left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 4, 2025
Copy link

openshift-ci bot commented Jun 4, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ankitathomas
Once this PR has been reviewed and has the lgtm label, please assign tmshort for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@joelanford
Copy link
Member

/hold

Can we discuss this a bit more? Besides my concern about supply chain security, this still feels like a downstream-only concern.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 4, 2025
@rashmigottipati
Copy link
Member Author

@joelanford Thanks for raising this. You're right—if the build is for commit A, we absolutely shouldn't be marking it as commit B and this is certainly a concern from a supply chain security standpoint.

This is a downstream only concern. Previously I've created #1811 but that didn't resolve the bug (downstream) as confirmed by QE in the report (which says that with the latest change it's returning empty commit info).

The purpose of this change is to ensure that GIT_COMMIT gets correctly set in environments where the actual git metadata isn't available at build time—specifically in some downstream OpenShift build pipelines. It looks like in those cases, the build system injects the commit SHA via the SOURCE_GIT_COMMIT env var, probably due to not having access to .git directly (this is my assumption - I am not very familiar with the build process downstream). Without it, the resulting binaries end up with an empty gitCommit field.

Upstream, we expect git rev-parse HEAD to suffice, and that’s what is used as a fallback here.

If the concern is around upstream builds incorrectly using SOURCE_GIT_COMMIT, maybe we could explicitly scope the override to CI? Or, we could leave GIT_COMMIT empty unless it's explicitly set by the caller. Or we could make this change downstream and leave upstream as it is.

Happy to adjust based on what we agree is the cleanest path forward.

@joelanford
Copy link
Member

I'm guessing that #1811 is the upstream plumbing that was needed such that we could add some downstream plumbing to set GIT_COMMIT to whatever downstream CI has set in its environment for SOURCE_GIT_COMMIT. I think I'd expect our downstream Dockerfiles to do something like (not sure this syntax is correct off the top of my head):

ENV GIT_COMMIT=$SOURCE_GIT_COMMIT

prior to calling make go-build-local. For example, just before here: https://github.com/openshift/operator-framework-operator-controller/blob/6bb442f94f89eba1c2c05b72f711087397706b54/openshift/operator-controller.Dockerfile#L4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants