Skip to content

Commit 5f016bd

Browse files
Merge pull request #115 from bitrise-io/flags
feat: ACI-3637 Add timestamps flag for bazel and wait for BES upload
2 parents e3cf352 + 204098d commit 5f016bd

File tree

16 files changed

+89
-38
lines changed

16 files changed

+89
-38
lines changed

.golangci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ linters:
1212
- paralleltest
1313
- testpackage
1414
- mnd
15-
- gomnd
1615
- err113
1716
- perfsprint
1817
- varnamelen
1918
- gci
2019
- nolintlint
2120
- cyclop
22-
- execinquery # deprecated (since v1.58.0) due to: The repository of the linter has been archived by the owner.

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Tool versions
2-
GOLANGCI_LINT_VERSION = v1.60.0
2+
GOLANGCI_LINT_VERSION = v1.64.8
33

44
.PHONY: lint
55
lint: ## Runs golangci-lint
66
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --timeout 5m
77

8+
.PHONY: lint-fix
9+
lint-fix: ## Runs golangci-lint
10+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --timeout 5m --fix
11+
12+
813
.PHONY: govulncheck
914
govulncheck: ## Runs govulncheck
1015
go run golang.org/x/vuln/cmd/govulncheck@latest -test ./...

bitrise.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ workflows:
3131
- content: |-
3232
#!/usr/bin/env bash
3333
34-
asdf global golang 1.22
34+
asdf install golang 1.23.8
35+
asdf global golang 1.23.8
3536
- script:
3637
title: Install Goreleaser
3738
inputs:
@@ -469,7 +470,7 @@ step_bundles:
469470
#!/bin/bash
470471
set -ex
471472
472-
asdf install golang 1.21.5
473+
asdf install golang 1.23.8
473474
- script:
474475
title: Generate dependency matrix
475476
inputs:

cmd/enableForBazel.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ If the "# [start/end] generated-by-bitrise-build-cache" block is already present
4949
}
5050

5151
var rbeEnabled bool //nolint:gochecknoglobals
52+
var timestamps bool //nolint:gochecknoglobals
5253

5354
func init() {
5455
enableForBazelCmd.Flags().BoolVar(&rbeEnabled, "with-rbe", false, "Enable Remote Build Execution (RBE)")
56+
enableForBazelCmd.Flags().BoolVar(&timestamps, "timestamps", false, "Enable timestamps in build output")
5557
enableForCmd.AddCommand(enableForBazelCmd)
5658
}
5759

@@ -101,7 +103,12 @@ func enableForBazelCmdFn(logger log.Logger, homeDirPath string, envProvider func
101103
logger.Debugf("isBazelrcExists: %t", isBazelrcExists)
102104

103105
logger.Infof("(i) Generate ~/.bazelrc")
104-
bazelrcBlockContent, err := bazelconfig.GenerateBazelrc(cacheEndpointURL, rbeEndpointURL, authConfig.WorkspaceID, authConfig.AuthToken, cacheConfig)
106+
bazelrcBlockContent, err := bazelconfig.GenerateBazelrc(cacheEndpointURL,
107+
authConfig.WorkspaceID, authConfig.AuthToken, cacheConfig,
108+
bazelconfig.Preferences{
109+
RBEEndpointURL: rbeEndpointURL,
110+
IsTimestampsEnabled: timestamps,
111+
})
105112
if err != nil {
106113
return fmt.Errorf("generate bazelrc: %w", err)
107114
}

cmd/saveXcodeDerivedDataFiles_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package cmd
22

33
import (
4-
"context"
54
"testing"
65
"time"
76

87
"github.com/stretchr/testify/mock"
98
"github.com/stretchr/testify/require"
109

10+
"context"
11+
1112
"github.com/bitrise-io/bitrise-build-cache-cli/internal/config/common"
1213
"github.com/bitrise-io/bitrise-build-cache-cli/internal/xcode"
1314
xcodeMocks "github.com/bitrise-io/bitrise-build-cache-cli/internal/xcode/mocks"

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/bitrise-io/bitrise-build-cache-cli
22

3-
go 1.22.3
3+
go 1.23.8
44

55
require (
66
cloud.google.com/go/longrunning v0.6.0
@@ -36,8 +36,6 @@ require (
3636
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
3737
github.com/spf13/pflag v1.0.5 // indirect
3838
github.com/stretchr/objx v0.5.2 // indirect
39-
go.uber.org/multierr v1.10.0 // indirect
40-
go.uber.org/zap v1.27.0 // indirect
4139
golang.org/x/net v0.28.0 // indirect
4240
golang.org/x/sys v0.24.0 // indirect
4341
golang.org/x/text v0.17.0 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
110110
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
111111
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
112112
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
113-
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
114-
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
115-
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
116-
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
117113
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
118114
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
119115
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

internal/build_cache/kv/download_multi.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (c *Client) DownloadFileGroupFromBuildCache(ctx context.Context, dd filegro
3333
}
3434
}
3535

36+
//nolint: gosec
3637
c.logger.TInfof("(i) Downloading %d files, largest is %s",
3738
len(dd.Files), humanize.Bytes(uint64(largestFileSize)))
3839

@@ -90,13 +91,13 @@ func (c *Client) DownloadFileGroupFromBuildCache(ctx context.Context, dd filegro
9091
missingPlusFailed := filesMissing.Load() + filesFailedToDownload.Load()
9192
switch {
9293
case errors.Is(err, ErrCacheNotFound):
93-
if missingPlusFailed < int32(maxLoggedDownloadErrors) {
94+
if int(missingPlusFailed) < maxLoggedDownloadErrors {
9495
c.logger.Infof("Cache entry not found for file %s (%s)", file.Path, file.Hash)
9596
}
9697

9798
filesMissing.Add(1)
9899
case err != nil:
99-
if missingPlusFailed < int32(maxLoggedDownloadErrors) {
100+
if int(missingPlusFailed) < maxLoggedDownloadErrors {
100101
c.logger.Errorf("Failed to download file %s with error: %v", file.Path, err)
101102
}
102103

@@ -110,6 +111,7 @@ func (c *Client) DownloadFileGroupFromBuildCache(ctx context.Context, dd filegro
110111

111112
wg.Wait()
112113

114+
//nolint: gosec
113115
c.logger.TInfof("(i) Downloaded: %d files (%s). Missing: %d files. Failed: %d files", filesDownloaded.Load(), humanize.Bytes(uint64(downloadSize.Load())), filesMissing.Load(), filesFailedToDownload.Load())
114116

115117
stats := DownloadFilesStats{
@@ -126,7 +128,9 @@ func (c *Client) DownloadFileGroupFromBuildCache(ctx context.Context, dd filegro
126128
c.logger.Debugf(" Files missing: %d", stats.FilesMissing)
127129
c.logger.Debugf(" Files failed to download: %d", stats.FilesFailedToDownload)
128130
c.logger.Debugf(" Files skipped (existing): %d", skippedFiles.Load())
131+
//nolint: gosec
129132
c.logger.Debugf(" Download size: %s", humanize.Bytes(uint64(stats.DownloadSize)))
133+
//nolint: gosec
130134
c.logger.Debugf(" Largest file size: %s", humanize.Bytes(uint64(stats.LargestFileSize)))
131135

132136
if maxLoggedDownloadErrors < stats.FilesFailedToDownload+stats.FilesMissing {

internal/build_cache/kv/upload.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func (c *Client) UploadFileToBuildCache(ctx context.Context, filePath, key strin
2626

2727
err = c.uploadToBuildCache(ctx, func(ctx context.Context) error {
2828
fileSize, err := c.uploadFile(ctx, filePath, key, checksum)
29+
//nolint: gosec
2930
c.logger.Infof("(i) Uploaded: %s", humanize.Bytes(uint64(fileSize)))
3031

3132
return err

internal/build_cache/kv/upload_multi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (c *Client) UploadFileGroupToBuildCache(ctx context.Context, dd filegroup.I
9393

9494
wg.Wait()
9595

96+
//nolint: gosec
9697
c.logger.TInfof("(i) Uploaded %s in %d keys", humanize.Bytes(uint64(stats.UploadSize)), stats.FilesUploaded)
9798

9899
if stats.FilesFailedToUpload > 0 {

0 commit comments

Comments
 (0)