Skip to content

Commit 077f158

Browse files
committed
ci: add prow lint/test scripts w/ CPU limits
Unit tests and golangci-lint are taking a long time to run in Prow environments, sometimes timing out and causing CI flakes. Likely, this is a result of the CI detecting the number of CPUs on the host, yet being limited to fewer CPUs (2 currently) in the Prow job config. Regardless of whether Prow jobs are updated to allow more CPU/memory usage, it is still important to be able to limit concurrency to what is configured in the job to avoid the issue if Prow machines become significantly bigger in the future. Prow jobs will need to be updated to make use of these new scripts. Signed-off-by: Blaine Gardner <[email protected]>
1 parent fed4e52 commit 077f158

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ test-e2e: chainsaw # Run e2e tests against the K8s cluster specified in ~/.kube/
8989
.PHONY: lint
9090
lint: golangci-lint.client golangci-lint.controller golangci-lint.sidecar ## Run all linters (suggest `make -k`)
9191
golangci-lint.%: golangci-lint
92-
cd $* && $(GOLANGCI_LINT) run --config $(CURDIR)/.golangci.yaml --new
92+
cd $* && $(GOLANGCI_LINT) run $(GOLANGCI_LINT_RUN_OPTS) --config $(CURDIR)/.golangci.yaml --new
9393

9494
.PHONY: lint-fix
9595
lint-fix: golangci-lint-fix.client golangci-lint-fix.controller golangci-lint-fix.sidecar ## Run all linters and perform fixes where possible (suggest `make -k`)
9696
golangci-lint-fix.%: golangci-lint
97-
cd $* && $(GOLANGCI_LINT) run --config $(CURDIR)/.golangci.yaml --new --fix
97+
cd $* && $(GOLANGCI_LINT) run $(GOLANGCI_LINT_RUN_OPTS) --config $(CURDIR)/.golangci.yaml --new --fix
9898

9999
##@ Build
100100

hack/prow-lint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -o errexit
3+
set -o nounset
4+
set -o xtrace
5+
6+
GOLANGCI_LINT_RUN_OPTS=""
7+
GOLANGCI_LINT_RUN_OPTS="$GOLANGCI_LINT_RUN_OPTS --verbose" # debug linter timing and mem usage
8+
GOLANGCI_LINT_RUN_OPTS="$GOLANGCI_LINT_RUN_OPTS --concurrency=2" # prow job lags if too many threads
9+
export GOLANGCI_LINT_RUN_OPTS
10+
11+
make lint

hack/prow-test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -o errexit
3+
set -o nounset
4+
set -o xtrace
5+
6+
export GOMAXPROCS=2 # prow job lags if too many threads
7+
8+
make test

0 commit comments

Comments
 (0)