Skip to content

Commit 6fed7df

Browse files
authored
ci: use go1.20 (#145)
* ci: use go1.20 * chore: update golint * ci: fix rebase workflow * ci: update permission * ci: remove permissions * ci: split e2e job * ci: export name * ci: needs build * ci: get code
1 parent 9c4bfeb commit 6fed7df

File tree

11 files changed

+64
-56
lines changed

11 files changed

+64
-56
lines changed

.github/workflows/pr-build.yaml

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,21 @@ on:
99

1010
jobs:
1111
build:
12-
strategy:
13-
matrix:
14-
mongodb: ["4.4", "5.0"]
1512
runs-on: ubuntu-latest
1613
steps:
1714
- name: Checkout
1815
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
1916
- name: Setup Go
2017
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
2118
with:
22-
go-version: 1.19.x
19+
go-version: 1.20.x
2320
- name: Restore Go cache
2421
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
2522
with:
2623
path: ~/go/pkg/mod
2724
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2825
restore-keys: |
2926
${{ runner.os }}-go-
30-
- name: Setup Kubernetes
31-
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
32-
with:
33-
version: v0.11.1
34-
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
35-
- name: Setup kustomize
36-
shell: bash
37-
run: |
38-
curl --silent --location --remote-name "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv4.5.7/kustomize_v4.5.7_linux_amd64.tar.gz"
39-
tar xvzf kustomize_v4.5.7_linux_amd64.tar.gz
40-
sudo mv kustomize /usr/local/bin/kustomize
41-
rm -rfv *.tar.gz
42-
kustomize version
43-
- name: Install Helm
44-
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
4527
- name: fmt
4628
run: make fmt
4729
- name: vet
@@ -50,6 +32,8 @@ jobs:
5032
run: make lint
5133
- name: Run tests
5234
run: make test
35+
- name: Build binary
36+
run: make build
5337
- name: Send go coverage report
5438
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
5539
with:
@@ -63,13 +47,53 @@ jobs:
6347
fi
6448
- name: Build container image
6549
run: |
66-
make docker-build IMG=test/mongodb-query-exporter:latest BUILD_PLATFORMS=linux/amd64 \
67-
BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \
68-
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max"
50+
make docker-build
51+
- name: Create image tarball
52+
run: |
53+
docker save raffis/mongodb-query-exporter:latest --output exporter-container.tar
54+
- name: Upload image
55+
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb #v3.1.1
56+
with:
57+
name: exporter-container
58+
path: exporter-container.tar
59+
60+
e2e-tests:
61+
needs: [build]
62+
strategy:
63+
matrix:
64+
mongodb: ["4.4", "5.0"]
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
69+
- name: Download exporter container
70+
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 #v3.0.1
71+
with:
72+
name: exporter-container
73+
path: /tmp
74+
- name: Load image
75+
run: |
76+
docker load --input /tmp/exporter-container.tar
77+
docker image ls -a
78+
- name: Setup Kubernetes
79+
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
80+
with:
81+
version: v0.11.1
82+
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
83+
- name: Setup kustomize
84+
shell: bash
85+
run: |
86+
curl --silent --location --remote-name "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv4.5.7/kustomize_v4.5.7_linux_amd64.tar.gz"
87+
tar xvzf kustomize_v4.5.7_linux_amd64.tar.gz
88+
sudo mv kustomize /usr/local/bin/kustomize
89+
rm -rfv *.tar.gz
90+
kustomize version
91+
- name: Install Helm
92+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
6993
- name: Load test image
70-
run: kind load docker-image test/mongodb-query-exporter:latest
94+
run: kind load docker-image raffis/mongodb-query-exporter:latest
7195
- name: Deploy exporter
72-
run: make deploy-test IMG=test/mongodb-query-exporter:latest
96+
run: make deploy-test
7397
- name: Setup MongoDB
7498
env:
7599
MONGODB_VER: ${{ '13.5.0' }}

.github/workflows/pr-chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint and Test Charts
1+
name: pr-chart
22

33
on: pull_request
44

.github/workflows/rebase.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
- name: Automatic Rebase
1919
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
2020
env:
21-
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
21+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/release-chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Chart
1+
name: release-chart
22

33
on:
44
push:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fetch-depth: 0
2121
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
2222
with:
23-
go-version: '1.19'
23+
go-version: '1.20'
2424
- name: Docker Login
2525
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0
2626
with:

.github/workflows/scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Scan
1+
name: scan
22

33
on:
44
push:

.goreleaser.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ sboms:
3636
dockers:
3737
- image_templates:
3838
- ghcr.io/raffis/{{ .ProjectName }}:{{ .Version }}-amd64
39-
dockerfile: Dockerfile.release
39+
dockerfile: Dockerfile
4040
use: buildx
4141
ids:
4242
- cli
@@ -53,7 +53,7 @@ dockers:
5353
- image_templates:
5454
- "ghcr.io/raffis/{{ .ProjectName }}:{{ .Version }}-arm64v8"
5555
goarch: arm64
56-
dockerfile: Dockerfile.release
56+
dockerfile: Dockerfile
5757
use: buildx
5858
ids:
5959
- cli

Dockerfile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
FROM golang:1.20 as builder
2-
3-
ADD . /go/src/github.com/raffis/mongodb-query-exporter
4-
WORKDIR /go/src/github.com/raffis/mongodb-query-exporter
5-
6-
7-
RUN make deps build
8-
9-
FROM gcr.io/distroless/base
10-
COPY --from=builder /go/src/github.com/raffis/mongodb-query-exporter/mongodb-query-exporter /bin/mongodb-query-exporter
11-
USER 1000:1000
12-
1+
FROM gcr.io/distroless/static:nonroot
2+
WORKDIR /
3+
COPY mongodb-query-exporter mongodb-query-exporter
134
EXPOSE 9412
14-
ENTRYPOINT [ "/bin/mongodb-query-exporter" ]
5+
6+
ENTRYPOINT ["/mongodb-query-exporter"]

Dockerfile.release

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

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ integrationtest:
4848
GOLANGCI_LINT = $(GOBIN)/golangci-lint
4949
.PHONY: golangci-lint
5050
golangci-lint: ## Download golint locally if necessary
51-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0)
51+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2)
5252

5353
.PHONY: lint
5454
lint: golangci-lint ## Run golangci-lint against code
@@ -68,14 +68,14 @@ vet:
6868

6969
build:
7070
@echo ">> building binaries"
71-
go build -o mongodb-query-exporter cmd/main.go
71+
CGO_ENABLED=0 go build -o mongodb-query-exporter cmd/main.go
7272

7373
.PHONY: run
7474
run: fmt vet
7575
go run ./cmd/main.go
7676

7777
.PHONY: docker-build
78-
docker-build: test ## Build docker image with the manager.
78+
docker-build: build ## Build docker image with the manager.
7979
docker build -t ${IMG} .
8080

8181
.PHONY: docker-push

0 commit comments

Comments
 (0)