mirror of
https://github.com/ossf/scorecard.git
synced 2024-10-26 10:28:10 +03:00
Consistent -ldflags
across go build
(#1070)
Co-authored-by: Azeem Shaikh <azeems@google.com>
This commit is contained in:
parent
06c14a64ba
commit
3cbe7b26f7
25
Makefile
25
Makefile
@ -8,8 +8,8 @@ PROTOC := $(shell which protoc)
|
||||
IMAGE_NAME = scorecard
|
||||
OUTPUT = output
|
||||
IGNORED_CI_TEST="E2E TEST:blob|E2E TEST:executable"
|
||||
|
||||
VERSION_LDFLAGS=$(shell ./scripts/version-ldflags)
|
||||
LDFLAGS=$(shell echo "-w -extldflags \"-static\" $(VERSION_LDFLAGS)")
|
||||
|
||||
############################### make help #####################################
|
||||
.PHONY: help
|
||||
@ -115,53 +115,52 @@ docs/checks.md: docs/checks/internal/checks.yaml docs/checks/internal/*.go docs/
|
||||
|
||||
build-scorecard: ## Runs go build on repo
|
||||
# Run go build and generate scorecard executable
|
||||
CGO_ENABLED=0 go build -a -tags netgo -ldflags '-w -extldflags "-static" $(VERSION_LDFLAGS)'
|
||||
CGO_ENABLED=0 go build -a -tags netgo -ldflags '$(LDFLAGS)'
|
||||
|
||||
build-pubsub: ## Runs go build on the PubSub cron job
|
||||
# Run go build and the PubSub cron job
|
||||
cd cron/controller && CGO_ENABLED=0 go build -a -ldflags '-w -extldflags "static"' -o controller
|
||||
cd cron/worker && CGO_ENABLED=0 go build -a -ldflags '-w -extldflags "-static" $(VERSION_LDFLAGS)' -o worker
|
||||
cd cron/controller && CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o controller
|
||||
cd cron/worker && CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o worker
|
||||
|
||||
build-bq-transfer: ## Runs go build on the BQ transfer cron job
|
||||
build-bq-transfer: ./cron/bq/*.go
|
||||
# Run go build on the Copier cron job
|
||||
cd cron/bq && CGO_ENABLED=0 go build -a -ldflags '-w -extldflags "static"' -o data-transfer
|
||||
cd cron/bq && CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o data-transfer
|
||||
|
||||
build-webhook: ## Runs go build on the cron webhook
|
||||
# Run go build on the cron webhook
|
||||
cd cron/webhook && CGO_ENABLED=0 go build -a -ldflags '-w -extldflags "static"' -o webhook
|
||||
cd cron/webhook && CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o webhook
|
||||
|
||||
build-add-script: ## Runs go build on the add script
|
||||
build-add-script: cron/data/add/add
|
||||
cron/data/add/add: cron/data/add/*.go cron/data/*.go repos/*.go cron/data/projects.csv
|
||||
# Run go build on the add script
|
||||
cd cron/data/add && CGO_ENABLED=0 go build -a -ldflags '-w -extldflags "-static"' -o add
|
||||
cd cron/data/add && CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o add
|
||||
|
||||
build-validate-script: ## Runs go build on the validate script
|
||||
build-validate-script: cron/data/validate/validate
|
||||
cron/data/validate/validate: cron/data/validate/*.go cron/data/*.go cron/data/projects.csv
|
||||
# Run go build on the validate script
|
||||
cd cron/data/validate && CGO_ENABLED=0 go build -a -ldflags '-w -extldflags "-static"' -o validate
|
||||
cd cron/data/validate && CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o validate
|
||||
|
||||
build-update-script: ## Runs go build on the update script
|
||||
build-update-script: cron/data/update/projects-update
|
||||
cron/data/update/projects-update: cron/data/update/*.go cron/data/*.go
|
||||
# Run go build on the update script
|
||||
cd cron/data/update && CGO_ENABLED=0 go build -a -tags netgo -ldflags '-w -extldflags "-static"' -o projects-update
|
||||
cd cron/data/update && CGO_ENABLED=0 go build -a -tags netgo -ldflags '$(LDFLAGS)' -o projects-update
|
||||
|
||||
dockerbuild: ## Runs docker build
|
||||
# Build all Docker images in the Repo
|
||||
$(call ndef, GITHUB_AUTH_TOKEN)
|
||||
DOCKER_BUILDKIT=1 docker build . --file Dockerfile --tag $(IMAGE_NAME)
|
||||
DOCKER_BUILDKIT=1 docker build . --file cron/controller/Dockerfile \
|
||||
--build-arg=COMMIT_SHA=$(GIT_HASH) --tag $(IMAGE_NAME)-batch-controller
|
||||
DOCKER_BUILDKIT=1 docker build . --file cron/worker/Dockerfile --tag $(IMAGE_NAME)-batch-worker
|
||||
DOCKER_BUILDKIT=1 docker build . --file cron/controller/Dockerfile --tag $(IMAGE_NAME)-batch-controller
|
||||
DOCKER_BUILDKIT=1 docker build . --file cron/worker/Dockerfile --tag $(IMAGE_NAME)-batch-worker
|
||||
DOCKER_BUILDKIT=1 docker build . --file cron/bq/Dockerfile --tag $(IMAGE_NAME)-bq-transfer
|
||||
DOCKER_BUILDKIT=1 docker build . --file cron/webhook/Dockerfile --tag ${IMAGE_NAME}-webhook
|
||||
###############################################################################
|
||||
|
||||
################################# make test ###################################
|
||||
test-targets = unit-test e2e ci-e2e
|
||||
test-targets = unit-test e2e ci-e2e
|
||||
.PHONY: test $(test-targets)
|
||||
test: $(test-targets)
|
||||
|
||||
|
@ -25,8 +25,6 @@ ARG TARGETARCH
|
||||
RUN CGO_ENABLED=0 make build-pubsub
|
||||
|
||||
FROM gcr.io/distroless/base:nonroot@sha256:a74f307185001c69bc362a40dbab7b67d410a872678132b187774fa21718fa13
|
||||
ARG COMMIT_SHA
|
||||
ENV SCORECARD_COMMIT_SHA=${COMMIT_SHA}
|
||||
COPY ./cron/data/projects*csv cron/data/
|
||||
COPY --from=pubsub /src/cron/controller/controller cron/controller/controller
|
||||
ENTRYPOINT ["cron/controller/controller"]
|
||||
|
@ -27,10 +27,9 @@ import (
|
||||
"github.com/ossf/scorecard/v2/cron/config"
|
||||
"github.com/ossf/scorecard/v2/cron/data"
|
||||
"github.com/ossf/scorecard/v2/cron/pubsub"
|
||||
"github.com/ossf/scorecard/v2/pkg"
|
||||
)
|
||||
|
||||
const commitSHA = "SCORECARD_COMMIT_SHA"
|
||||
|
||||
func publishToRepoRequestTopic(ctx context.Context, iter data.Iterator, datetime time.Time) (int32, error) {
|
||||
var shardNum int32
|
||||
request := data.ScorecardBatchRequest{
|
||||
@ -125,7 +124,7 @@ func main() {
|
||||
}
|
||||
*metadata.NumShard = (shardNum + 1)
|
||||
*metadata.ShardLoc = bucket + "/" + data.GetBlobFilename("", t)
|
||||
*metadata.CommitSha = os.Getenv(commitSHA)
|
||||
*metadata.CommitSha = pkg.GetCommit()
|
||||
metadataJSON, err := protojson.Marshal(&metadata)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error during protojson.Marshal: %w", err))
|
||||
|
Loading…
Reference in New Issue
Block a user