Skip to content

fix(ci): add temp container for git commit SHA in build#728

Merged
bupd merged 1 commit into
goharbor:mainfrom
Sypher845:fix/build-missing-git-commit
Mar 8, 2026
Merged

fix(ci): add temp container for git commit SHA in build#728
bupd merged 1 commit into
goharbor:mainfrom
Sypher845:fix/build-missing-git-commit

Conversation

@Sypher845

Copy link
Copy Markdown
Contributor

Fixes #726

  • The Build function uses the Alpine version of the Go container, which does not have git installed.
  • One option was to install git inside the build container, but that would run redundantly in the loop for all cross-platform builds.
  • Instead, a temporary container is used outside the loop to resolve the git commit SHA once and reuse it for all builds.
image

@codecov

codecov Bot commented Mar 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 7.44%. Comparing base (60ad0bd) to head (5510347).
⚠️ Report is 107 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #728      +/-   ##
=========================================
- Coverage   10.99%   7.44%   -3.55%     
=========================================
  Files         173     261      +88     
  Lines        8671   12945    +4274     
=========================================
+ Hits          953     964      +11     
- Misses       7612   11872    +4260     
- Partials      106     109       +3     

☔ 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.

@Sypher845

Copy link
Copy Markdown
Contributor Author

@bupd The lint is failing because of the new release of the golangci-lint

@bupd

bupd commented Mar 6, 2026

Copy link
Copy Markdown
Member

Fix the lint then.

@bupd

bupd commented Mar 6, 2026

Copy link
Copy Markdown
Member

Looks like there is two gosec issues. Please find the root cause and fix it in a separate PR.

Also we need to find why golangci-lint being latest fails the pipeline - we also need to find the cause for this thing

@Sypher845

Copy link
Copy Markdown
Contributor Author

golangci-lint uses securego/gosec as one of its bundled linters. When gosec releases a new version with new rules, golangci-lint bumps its gosec dependency, which causes new lint failures on previously clean code. Wouldn't it be better to pin the golangci-lint version?

@vg006

vg006 commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

@Sypher845
Pinning golangci-lint restricts updates for other linters and formatters used in the project too. Ideally, it is not a good way to address this problem and we may need to look the cause and fix issues.

@Sypher845

Copy link
Copy Markdown
Contributor Author

i agree we should fix the issues. I was suggesting instead of using the latest (where any PR breaks for a new rule), we pin the version and upgrade it periodically. During each upgrade, we will fix all new lint issues in a single PR. This way no unrelated PR gets blocked by a new lint rule it didn't introduce.

@bupd bupd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Sypher845 - i believe we should also add this to the builddev too. Please update Thanks.

@bupd

bupd commented Mar 7, 2026

Copy link
Copy Markdown
Member

i agree we should fix the issues. I was suggesting instead of using the latest (where any PR breaks for a new rule), we pin the version and upgrade it periodically. During each upgrade, we will fix all new lint issues in a single PR. This way no unrelated PR gets blocked by a new lint rule it didn't introduce.

@Sypher845 - we had like this earlier - and no one is willing to update the golangci-lint to the newest version thats why we now have it as latest - I think if you find any lint issues that is unrelated to the Change Request you are working on.

Please feel free to create a new issue / PR fixing that specific lint issue.

@bupd

bupd commented Mar 7, 2026

Copy link
Copy Markdown
Member

Appreciate the PR #730

@Sypher845

Copy link
Copy Markdown
Contributor Author

@Sypher845 - i believe we should also add this to the builddev too. Please update Thanks.

@bupd
buildDev builds for a single platform and uses the full golang: image, which already includes git. The git commit SHA is being captured correctly in it.
In build, since it targets all platforms, a temp container was needed because we had the Alpine golang container for each platform inside the loop. The temp container is placed before the loop to resolve the git commit SHA once and reuse it for all builds.

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 force-pushed the fix/build-missing-git-commit branch from 51335ed to 5510347 Compare March 7, 2026 19:33
@bupd bupd changed the title fix: add temp container for git commit SHA in build fix(ci): add temp container for git commit SHA in build Mar 8, 2026
@bupd bupd merged commit 8ca59d6 into goharbor:main Mar 8, 2026
7 of 8 checks passed
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.

Harbor CLI binary is missing git-commit SHA

3 participants