Skip to content

Commit eced305

Browse files
committed
fix: lint issues
Signed-off-by: Magnus Ullberg <magnus@ullberg.us>
1 parent 26cb76f commit eced305

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
66
# update PATH for local pip installs
77
ENV PATH="$PATH:~/.local/bin"
88

9+
# Install golangci-lint
10+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git xz-utils && rm -rf /var/lib/apt/lists/* \
11+
&& GOLANGCI_LINT_VERSION=2.6.2 \
12+
&& curl -sSLO "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" \
13+
&& tar -xzf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz -C /tmp \
14+
&& mv /tmp/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint /usr/local/bin/golangci-lint \
15+
&& rm -rf /tmp/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64* golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz
16+
917
CMD sleep infinity
1018

1119
ENTRYPOINT []

.devcontainer/post-install.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,15 @@ set -eux
33

44
# initialize pre-commit
55
git config --global --add safe.directory /workspaces
6+
7+
# Install golangci-lint if not present (useful when devcontainer not rebuilt)
8+
if ! command -v golangci-lint >/dev/null 2>&1; then
9+
echo "golangci-lint not found, installing v2 via github release tarball"
10+
apt-get update && apt-get install -y --no-install-recommends ca-certificates curl xz-utils || true
11+
GOLANGCI_LINT_VERSION=2.6.2
12+
curl -sSLO "https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz" || true
13+
tar -xzf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz -C /tmp || true
14+
mv /tmp/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint /usr/local/bin/golangci-lint || true
15+
rm -rf /tmp/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64* golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz || true
16+
echo "golangci-lint installed"
17+
fi

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ fmt: ## Format Go code
3636
vet: ## Vet Go code
3737
go vet ./...
3838

39+
.PHONY: lint
40+
lint: ## Run golangci-lint (requires golangci-lint installed)
41+
golangci-lint run
42+
3943
.PHONY: test
4044
test: tidy fmt vet ## Run tests with coverage
4145
go test ./... -race -coverprofile=coverage.out

pkg/util/cleanup_job_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ func TestWaitForJobCompletion_Success(t *testing.T) {
392392
},
393393
}
394394

395-
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(job).Build()
395+
cl := fake.NewClientBuilder().WithScheme(scheme).WithObjects(job).Build()
396396

397-
err := WaitForJobCompletion(context.Background(), client, job, 10*time.Second)
397+
err := WaitForJobCompletion(context.Background(), cl, job, 10*time.Second)
398398
if err != nil {
399399
t.Errorf("Expected no error, got %v", err)
400400
}
@@ -414,9 +414,9 @@ func TestWaitForJobCompletion_Timeout(t *testing.T) {
414414
},
415415
}
416416

417-
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(job).Build()
417+
cl := fake.NewClientBuilder().WithScheme(scheme).WithObjects(job).Build()
418418

419-
err := WaitForJobCompletion(context.Background(), client, job, 1*time.Second)
419+
err := WaitForJobCompletion(context.Background(), cl, job, 1*time.Second)
420420
if err == nil {
421421
t.Errorf("Expected timeout error, got nil")
422422
}
@@ -442,9 +442,9 @@ func TestWaitForJobCompletion_Failed(t *testing.T) {
442442
},
443443
}
444444

445-
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(job).Build()
445+
cl := fake.NewClientBuilder().WithScheme(scheme).WithObjects(job).Build()
446446

447-
err := WaitForJobCompletion(context.Background(), client, job, 10*time.Second)
447+
err := WaitForJobCompletion(context.Background(), cl, job, 10*time.Second)
448448
if err == nil {
449449
t.Errorf("Expected job failed error, got nil")
450450
}

0 commit comments

Comments
 (0)