Skip to content

Commit 5cefb59

Browse files
authored
Cleanup and maintenance (#102)
* cleanup - remove un-needed files - rework makefile (mainly cleanup and usage of go modules and coverage) - compile plugins with coverage flags so test-coverage will work - bump go version - bump golangci-lint version and add linter config - fix lint issues in code Signed-off-by: adrianc <[email protected]> * update worflow action versions Signed-off-by: adrianc <[email protected]> * Add support for arm64 image build in workflows In addition fix image push trigger branch Signed-off-by: adrianc <[email protected]> * update packages Signed-off-by: adrianc <[email protected]> * update Dockerfile base image current base image was failing on arm64 builds. we now use debian for build and distroless for the app. Signed-off-by: adrianc <[email protected]> --------- Signed-off-by: adrianc <[email protected]>
1 parent 37fc6f4 commit 5cefb59

36 files changed

+549
-635
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore build and test binaries.
3+
bin/
4+
build/

.github/workflows/build-images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
1010

1111
- name: Check out code into the Go module directory
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313

1414
- name: Set up Docker Buildx
15-
uses: docker/setup-buildx-action@v2
15+
uses: docker/setup-buildx-action@v3
1616

1717
- name: Build container image
18-
uses: docker/build-push-action@v3
18+
uses: docker/build-push-action@v6
1919
with:
2020
push: false
2121
tags: ghcr.io/${{ steps.repo_name.outputs.repository }}:latest-amd64

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ jobs:
44
build:
55
strategy:
66
matrix:
7-
go-version: [1.19.x]
7+
go-version: [1.22.x]
88
goarch: [amd64]
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check out code into the Go module directory
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313

1414
- name: Install Go
15-
uses: actions/setup-go@v3
15+
uses: actions/setup-go@v5
1616
with:
1717
go-version: ${{ matrix.go-version }}
1818

.github/workflows/push-main.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/push-master.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: push-master
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
image-build-push:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set repository as lower-case output variable
11+
id: repo_name
12+
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
13+
14+
- name: Check out code into the Go module directory
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Docker meta
26+
id: docker_meta
27+
uses: docker/metadata-action@v5
28+
with:
29+
images: ghcr.io/${{ steps.repo_name.outputs.repository }}
30+
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.repository_owner }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Push to GitHub Container Registry
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: .
42+
push: true
43+
platforms: linux/amd64,linux/arm64
44+
tags: |
45+
ghcr.io/${{ steps.repo_name.outputs.repository }}:latest
46+
labels: ${{ steps.docker_meta.outputs.labels }}
47+
file: ./Dockerfile

.github/workflows/push-release.yml

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,84 +4,49 @@ on:
44
tags:
55
- v*
66
jobs:
7-
build-push-amd64:
8-
name: Image push/amd64
7+
image-build-push:
98
runs-on: ubuntu-latest
109
steps:
1110
- name: Set repository as lower-case output variable
1211
id: repo_name
1312
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
1413

1514
- name: Check out code into the Go module directory
16-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
1721

1822
- name: Set up Docker Buildx
19-
uses: docker/setup-buildx-action@v2
23+
uses: docker/setup-buildx-action@v3
2024

2125
- name: Login to GitHub Container Registry
22-
uses: docker/login-action@v2
26+
uses: docker/login-action@v3
2327
with:
2428
registry: ghcr.io
2529
username: ${{ github.repository_owner }}
2630
password: ${{ secrets.GITHUB_TOKEN }}
2731

2832
- name: Docker meta
2933
id: docker_meta
30-
uses: docker/metadata-action@v4
34+
uses: docker/metadata-action@v5
3135
with:
3236
images: ghcr.io/${{ steps.repo_name.outputs.repository }}
37+
tags: |
38+
type=ref,event=tag
3339
flavor: |
3440
latest=false
3541
36-
- name: Push container image
37-
uses: docker/build-push-action@v3
42+
- name: Build and Push container image
43+
uses: docker/build-push-action@v5
3844
with:
3945
context: .
4046
push: true
47+
platforms: linux/amd64,linux/arm64
4148
tags: |
42-
ghcr.io/${{ steps.repo_name.outputs.repository }}:stable-amd64
43-
${{ steps.docker_meta.outputs.tags }}-amd64
49+
ghcr.io/${{ steps.repo_name.outputs.repository }}:stable
50+
${{ steps.docker_meta.outputs.tags }}
4451
labels: ${{ steps.docker_meta.outputs.labels }}
4552
file: ./Dockerfile
46-
47-
create-push-manifest:
48-
needs: [build-push-amd64]
49-
runs-on: ubuntu-latest
50-
steps:
51-
- name: Set repository as lower-case output variable
52-
id: repo_name
53-
run: echo ::set-output name=repository::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
54-
55-
- name: Set up Docker Buildx
56-
uses: docker/setup-buildx-action@v2
57-
58-
- name: Docker meta
59-
id: docker_meta
60-
uses: docker/metadata-action@v4
61-
with:
62-
images: ghcr.io/${{ steps.repo_name.outputs.repository }}
63-
flavor: |
64-
latest=false
65-
66-
- name: Login to GitHub Container Registry
67-
uses: docker/login-action@v2
68-
with:
69-
registry: ghcr.io
70-
username: ${{ github.repository_owner }}
71-
password: ${{ secrets.GITHUB_TOKEN }}
72-
73-
- name: Create manifest for multi-arch images
74-
env:
75-
REPOSITORY: ghcr.io/${{ steps.repo_name.outputs.repository }}
76-
run: |
77-
# Get artifacts from previous steps
78-
docker pull ${{ steps.docker_meta.outputs.tags }}-amd64
79-
docker pull ${{ env.REPOSITORY }}:stable-amd64
80-
# Create and update manifests
81-
docker manifest create ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64
82-
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64 --arch amd64
83-
docker manifest create ${{ env.REPOSITORY }}:stable ${{ env.REPOSITORY }}:stable-amd64
84-
docker manifest annotate ${{ env.REPOSITORY }}:stable ${{ env.REPOSITORY }}:stable-amd64 --arch amd64
85-
# push manifests
86-
docker manifest push ${{ steps.docker_meta.outputs.tags }}
87-
docker manifest push ${{ env.REPOSITORY }}:stable

.github/workflows/test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ jobs:
44
test:
55
strategy:
66
matrix:
7-
go-version: [1.19.x]
7+
go-version: [1.22.x]
88
os: [ubuntu-latest]
99
runs-on: ${{ matrix.os }}
1010
steps:
1111
- name: Install Go
12-
uses: actions/setup-go@v3
12+
uses: actions/setup-go@v5
1313
with:
1414
go-version: ${{ matrix.go-version }}
1515

1616
- name: Checkout code
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818

1919
- name: lint
2020
run: make lint
@@ -28,18 +28,18 @@ jobs:
2828
needs: test
2929
steps:
3030
- name: Install Go
31-
uses: actions/setup-go@v3
31+
uses: actions/setup-go@v5
3232
with:
33-
go-version: 1.19.x
33+
go-version: 1.22.x
3434

3535
- name: Checkout code
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737

3838
- name: Go test with coverage
3939
run: make test-coverage
4040

4141
- name: Coveralls
42-
uses: coverallsapp/github-action@1.1.3
42+
uses: coverallsapp/github-action@v2
4343
with:
4444
github-token: ${{ secrets.GITHUB_TOKEN }}
45-
path-to-lcov: build/coverage/lcov.info
45+
file: cover.out

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
go.work.sum
23+
24+
# build dirs
25+
build/
26+
bin/
27+
28+
# IDE
29+
.vscode

0 commit comments

Comments
 (0)