Skip to content

Commit

Permalink
Major updates
Browse files Browse the repository at this point in the history
* Build using Go 1.23
* Update all dependencies including Kubernetes to 1.29.12
* Replace go-kit logging with slog from promslog
* Update all Github Actions to latest versions
  • Loading branch information
treydock committed Jan 9, 2025
1 parent d838f4d commit e29fb1c
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 381 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
install
*.md
*.tar.gz
dist
12 changes: 6 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
- name: Set version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Helm
uses: azure/setup-helm@v3
uses: azure/setup-helm@v4.20
with:
version: v3.8.0
version: v3.12.2
- uses: creekorful/[email protected]
- name: Make Release
env:
Expand All @@ -32,10 +32,10 @@ jobs:
rm -rf release
make release
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --rm-dist --debug
args: release --clean --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Helm charts
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ jobs:
fi
echo "REF=${ref}" >> $GITHUB_ENV
echo "VERSION=${version}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Login to quay.io
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ACCESS_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: ./
context: .
file: ./Dockerfile
push: true
tags: ohiosupercomputer/job-pod-reaper:${{ env.VERSION }},quay.io/ohiosupercomputercenter/job-pod-reaper:${{ env.VERSION }}
Expand Down
42 changes: 22 additions & 20 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,55 @@ jobs:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 3
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.51.2
version: v1.63.4
args: --timeout=5m
skip-cache: true
- name: Run tests
run: make all
- name: Run coverage
run: make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Build
run: make build
- name: Run GoReleaser build
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: build --rm-dist --snapshot
args: build --snapshot --clean
- name: Docker Build
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: quay.io/ohiosupercomputercenter/job-pod-reaper:latest
outputs: type=docker,dest=/tmp/job-pod-reaper.tar
- name: Upload Docker image
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: image
path: /tmp/job-pod-reaper.tar
Expand All @@ -68,29 +69,30 @@ jobs:
name: Test Helm Chart
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
uses: azure/setup-helm@v4.2.0
with:
version: v3.8.0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: 3.11
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
uses: helm/chart-testing-action@v2.6.1
- name: Download image
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: image
path: /tmp
- name: Run chart-testing (lint)
run: ct lint --target-branch=main --check-version-increment=false
- name: Create kind cluster
uses: helm/kind-action@v1.4.0
uses: helm/kind-action@v1.12.0
with:
version: v0.18.0
version: v0.26.0
node_image: kindest/node:v1.29.12@sha256:62c0672ba99a4afd7396512848d6fc382906b8f33349ae68fb1dbfe549f70dec
cluster_name: kind
- name: Load image
run: |
Expand Down
4 changes: 0 additions & 4 deletions .golangci.errcheck-exclude

This file was deleted.

3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
linters-settings:
errcheck:
exclude: .golangci.errcheck-exclude
exclude-functions:
- '(net/http.ResponseWriter).Write'
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.19-alpine AS builder
FROM golang:1.23-alpine3.21 AS builder
RUN apk update && apk add git make
WORKDIR /go/src/app
COPY . ./
COPY . .
ARG VERSION="main"
RUN make build VERSION=${VERSION}

FROM alpine:3.12
FROM alpine:3.21
RUN apk --no-cache add ca-certificates
WORKDIR /
COPY --from=builder /go/src/app/job-pod-reaper .
Expand Down
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
export GOPATH ?= $(firstword $(subst :, ,$(shell go env GOPATH)))
GOOS := linux
GOARCH := amd64
GOHOSTOS ?= $(shell go env GOHOSTOS)
GOHOSTARCH ?= $(shell go env GOHOSTARCH)
GOLANGCI_LINT := $(GOPATH)/bin/golangci-lint
GOLANGCI_LINT_VERSION := v1.51.2
GOLANGCI_LINT_VERSION := v1.63.4
VERSION ?= $(shell git describe --tags --abbrev=0 || git rev-parse --short HEAD)
GITSHA := $(shell git rev-parse HEAD)
GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BUILDUSER := $(shell whoami)@$(shell hostname)
BUILDDATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")

ifeq ($(GOHOSTARCH),amd64)
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows))
# Only supported on amd64
test-flags := -race
endif
endif

.PHONY: unused lint style test release

all: unused lint style test

build:
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="\
GO111MODULE=on GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) CGO_ENABLED=0 go build -ldflags="\
-X github.com/prometheus/common/version.Version=$(VERSION) \
-X github.com/prometheus/common/version.Revision=$(GITSHA) \
-X github.com/prometheus/common/version.Branch=$(GITBRANCH) \
Expand All @@ -23,20 +30,20 @@ build:
-o job-pod-reaper main.go

test:
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) go test -race ./...
GO111MODULE=on GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go test $(test-flags) ./...

coverage:
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) go test -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic ./...
GO111MODULE=on GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go test $(test-flags) -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic ./...

unused:
@echo ">> running check for unused/missing packages in go.mod"
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) go mod tidy
GO111MODULE=on GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go mod tidy
@git diff --exit-code -- go.sum go.mod

lint: $(GOLANGCI_LINT)
@echo ">> running golangci-lint"
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOLANGCI_LINT) run ./...
GO111MODULE=on GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
GO111MODULE=on GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) $(GOLANGCI_LINT) run ./...

style:
@echo ">> checking code style"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Metrics about the count of reaped resources, duration of last reaping, and error

## Kubernetes support

Currently this code is built and tested against Kubernetes 1.25.x and 1.26.x.
Currently this code is built and tested against Kubernetes 1.29.x.

The Kubernetes APIs used by this project do not tend to change between Kubernetes releases so it is likely this code will work on all 1.x releases of Kubernetes.

## Install

Expand Down
60 changes: 29 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,62 +1,60 @@
module github.com/OSC/job-pod-reaper

go 1.20
go 1.23

require (
github.com/go-kit/log v0.2.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.39.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/prometheus/client_golang v1.20.4
github.com/prometheus/common v0.61.0
k8s.io/api v0.29.12
k8s.io/apimachinery v0.29.12
k8s.io/client-go v0.29.12
)

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.90.0 // indirect
k8s.io/kube-openapi v0.0.0-20230131200451-5e46c6e584a1 // indirect
k8s.io/utils v0.0.0-20230115233650-391b47cb4029 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit e29fb1c

Please sign in to comment.