Skip to content

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Apr 30, 2025

in reality, we just don't want .gz because its just the binary gzipped

@caarlos0 caarlos0 added the bug Something isn't working label Apr 30, 2025
@caarlos0 caarlos0 self-assigned this Apr 30, 2025
@caarlos0 caarlos0 requested a review from Copilot April 30, 2025 16:53
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 30, 2025
Copy link

cloudflare-workers-and-pages bot commented Apr 30, 2025

Deploying goreleaser with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3b34db5
Status: ✅  Deploy successful!
Preview URL: https://1f7a2a17.goreleaser.pages.dev
Branch Preview URL: https://brew-tgz.goreleaser.pages.dev

View logs

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends Homebrew support to additional archive formats and updates tests accordingly.

  • Updates artifact names and formats in tests to support txz, tgz, tzst, tar.zst
  • Centralizes allowed archive formats in brew.go and updates corresponding error messages

Reviewed Changes

Copilot reviewed 2 out of 12 changed files in this pull request and generated 1 comment.

File Description
internal/pipe/brew/brew_test.go Updates test artifacts with new archive formats and refines file creation logic
internal/pipe/brew/brew.go Introduces a centralized formats list and updates error messages and filtering logic
Files not reviewed (10)
  • internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/default.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/git_remote.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/open_pr.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/valid_repository_templates.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/with_header.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/with_many_headers.rb.golden: Language not supported
Comments suppressed due to low confidence (1)

internal/pipe/brew/brew_test.go:423

  • [nitpick] Avoid shadowing the err variable if it is already defined; using assignment (err = runAll(ctx, client)) would maintain consistency in error handling.
err := runAll(ctx, client)

require.NoError(t, err)
require.NoError(t, f.Close())
for _, a := range ctx.Artifacts.List() {
if !strings.HasPrefix(a.Path, folder) {
Copy link
Preview

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using filepath.Rel to verify that the artifact path is within the test folder instead of strings.HasPrefix, to avoid potential false positives.

Suggested change
if !strings.HasPrefix(a.Path, folder) {
relPath, err := filepath.Rel(folder, a.Path)
require.NoError(t, err)
if strings.HasPrefix(relPath, "..") || filepath.IsAbs(relPath) {

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.93%. Comparing base (b0919e8) to head (3b34db5).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5746   +/-   ##
=======================================
  Coverage   82.93%   82.93%           
=======================================
  Files         161      161           
  Lines       15924    15928    +4     
=======================================
+ Hits        13206    13210    +4     
  Misses       2144     2144           
  Partials      574      574           

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

@lfaoro
Copy link

lfaoro commented May 1, 2025

glad to help you spot this bug! thank you for the fix

@lfaoro
Copy link

lfaoro commented May 1, 2025

tested and the fix worked

go install -v github.com/goreleaser/goreleaser/v2@brew-tgz

  • homebrew tap formula
    • token type                                     type=github
    • calculating checksum for build/ssm_0.3.2_linux_armv6.tgz
    • guessing install                               install=[bin.install "ssm"]
    • calculating checksum for build/ssm_0.3.2_linux_x86_64.tgz
    • guessing install                               install=[bin.install "ssm"]
    • calculating checksum for build/ssm_0.3.2_linux_arm64.tgz
    • guessing install                               install=[bin.install "ssm"]
    • calculating checksum for build/ssm_0.3.2_darwin_all.tgz
    • guessing install                               install=[bin.install "ssm"]
    • writing                                        formula=build/homebrew/ssm.rb
    • added new artifact                             name=ssm.rb type=Brew Tap path=build/homebrew/ssm.rb

before fix

  • homebrew tap formula
   • token type                                     type=github
 ⨯ release failed after 2s                  error=no linux/macos archives found matching goos=[darwin linux] goarch=[amd64 arm64 arm] goamd64=v1 goarm=6 ids=[]

same manifest: https://github.com/lfaoro/ssm/blob/main/.config/goreleaser.yaml

@lfaoro
Copy link

lfaoro commented May 5, 2025

@caarlos0 NIX has the same tgz issue

@caarlos0 caarlos0 changed the title fix(brew): support txz, tgz, tzst, tar.zst fix(brew,nix): support txz, tgz, tzst, tar.zst May 6, 2025
@caarlos0 caarlos0 requested a review from Copilot May 6, 2025 13:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the archive format filtering logic to support additional archive types (txz, tgz, tzst, tar.zst) by excluding archives with a raw ".gz" format and adjusts related tests accordingly.

  • Change archive filtering in both nix.go and brew.go from accepting only specific formats to excluding ".gz" formats.
  • Update brew test cases and expected artifact counts to reflect the new supported formats.
  • Introduce the Not filter in artifact.go to simplify negation of format filters.

Reviewed Changes

Copilot reviewed 5 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/pipe/nix/nix.go Alters the filter to exclude archives with a "gz" format rather than only including zip and tar.gz archives.
internal/pipe/brew/brew.go Updates archive filtering logic similarly to nix.go using the new Not filter.
internal/pipe/brew/brew_test.go Adjusts test artifact names and implements a loop to create files for each artifact based on their path.
internal/artifact/artifact_test.go Updates expected counts for filtered artifacts to account for the newly supported archive formats.
internal/artifact/artifact.go Adds a new Not filter function for negating filters.
Files not reviewed (10)
  • internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/default.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/git_remote.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/open_pr.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/valid_repository_templates.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/with_header.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/with_many_headers.rb.golden: Language not supported
Comments suppressed due to low confidence (1)

internal/artifact/artifact_test.go:139

  • [nitpick] The updated expected count for artifacts filtered by 'darwin' has increased. Please verify that this change is intentional and document the reasoning in the test or accompanying commit message to avoid future confusion.
require.Len(t, artifacts.Filter(ByGoos("darwin")).items, 3)

@@ -219,7 +219,7 @@ func preparePkg(
artifact.ByGoarch("all"),
),
artifact.And(
Copy link
Preview

Copilot AI May 6, 2025

Choose a reason for hiding this comment

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

Ensure that using artifact.Not(artifact.ByFormats("gz")) correctly excludes only pure gzipped artifacts while allowing the supported archive formats such as txz, tgz, tzst, and tar.zst. Adding a brief comment to explain this filtering logic would improve code readability.

Suggested change
artifact.And(
artifact.And(
// Exclude pure .gz files while allowing supported archive formats like .tgz, .txz, .tzst, and .tar.zst.

Copilot uses AI. Check for mistakes.

require.NoError(t, err)
require.NoError(t, f.Close())
for _, a := range ctx.Artifacts.List() {
if !strings.HasPrefix(a.Path, folder) {
Copy link
Preview

Copilot AI May 6, 2025

Choose a reason for hiding this comment

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

[nitpick] When iterating over artifacts to create files, the check using strings.HasPrefix(a.Path, folder) should be reviewed to ensure it reliably identifies files in the intended directory; consider using a more robust path comparison if available.

Suggested change
if !strings.HasPrefix(a.Path, folder) {
relPath, err := filepath.Rel(folder, a.Path)
require.NoError(t, err)
if strings.HasPrefix(relPath, "..") {

Copilot uses AI. Check for mistakes.

@caarlos0 caarlos0 requested a review from Copilot May 6, 2025 14:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates archive filter logic and test expectations to support additional archive formats (txz, tgz, tzst, tar.zst) while excluding raw gz, as well as adding a new Not filter helper.

  • Replaces explicit format filtering (e.g., "tar.gz") with a more flexible exclusion of "gz" formats in both nix and brew pipelines.
  • Updates tests to account for the additional archive artifacts and file creation.
  • Introduces a Not() helper function to simplify filter expressions.

Reviewed Changes

Copilot reviewed 5 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/pipe/nix/nix.go Replaces ByFormats("zip", "tar.gz") with Not(ByFormats("gz")) to exclude gz.
internal/pipe/brew/brew_test.go Updates test artifacts names and creates files for each artifact in a loop.
internal/pipe/brew/brew.go Updates archive filter to use Not(ByFormats("gz")) consistently.
internal/artifact/artifact_test.go Adjusts expected artifact counts in tests to reflect filtering changes.
internal/artifact/artifact.go Adds a new Not() helper function for filter negation.
Files not reviewed (10)
  • internal/pipe/brew/testdata/TestFullPipe/custom_block.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/custom_download_strategy.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/custom_require.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/default.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/default_gitlab.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/git_remote.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/open_pr.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/valid_repository_templates.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/with_header.rb.golden: Language not supported
  • internal/pipe/brew/testdata/TestFullPipe/with_many_headers.rb.golden: Language not supported
Comments suppressed due to low confidence (5)

internal/pipe/brew/brew_test.go:394

  • Replacing the single file creation with a loop to create files for all artifact paths improves test robustness. Consider adding assertions to verify file existence and properties to further strengthen test coverage.
for _, a := range ctx.Artifacts.List() {

internal/artifact/artifact_test.go:139

  • The expected artifact count for 'darwin' artifacts has been updated from 2 to 3; ensure this new expectation accurately reflects the filtering changes introduced in this PR.
require.Len(t, artifacts.Filter(ByGoos("darwin")).items, 3)

internal/pipe/nix/nix.go:222

  • The change to use Not(ByFormats("gz")) excludes artifacts whose format exactly equals 'gz' and aligns with the new requirement. Please verify that valid formats (e.g., 'tgz', 'txz', 'tar.zst') are not inadvertently filtered out.
artifact.Not(artifact.ByFormats("gz")),

internal/pipe/brew/brew.go:218

  • Updating the archive filter to use Not(ByFormats("gz")) ensures consistency across pipelines. Please double-check that this exact match approach does not exclude any intended formats.
artifact.Not(artifact.ByFormats("gz")),

internal/artifact/artifact.go:603

  • The addition of a Not() helper function simplifies filter negation and improves clarity. It would be beneficial to verify its behavior through existing tests to confirm it handles all expected edge cases.
func Not(filter Filter) Filter {

@caarlos0 caarlos0 merged commit ab3e620 into main May 6, 2025
17 of 18 checks passed
@caarlos0 caarlos0 deleted the brew-tgz branch May 6, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants