Skip to content

Commit

Permalink
ci: use go1.20 (#145)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
raffis authored Apr 14, 2023
1 parent 9c4bfeb commit 6fed7df
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 56 deletions.
72 changes: 48 additions & 24 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,21 @@ on:

jobs:
build:
strategy:
matrix:
mongodb: ["4.4", "5.0"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: 1.19.x
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
with:
version: v0.11.1
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
- name: Setup kustomize
shell: bash
run: |
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"
tar xvzf kustomize_v4.5.7_linux_amd64.tar.gz
sudo mv kustomize /usr/local/bin/kustomize
rm -rfv *.tar.gz
kustomize version
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
- name: fmt
run: make fmt
- name: vet
Expand All @@ -50,6 +32,8 @@ jobs:
run: make lint
- name: Run tests
run: make test
- name: Build binary
run: make build
- name: Send go coverage report
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
with:
Expand All @@ -63,13 +47,53 @@ jobs:
fi
- name: Build container image
run: |
make docker-build IMG=test/mongodb-query-exporter:latest BUILD_PLATFORMS=linux/amd64 \
BUILD_ARGS="--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max"
make docker-build
- name: Create image tarball
run: |
docker save raffis/mongodb-query-exporter:latest --output exporter-container.tar
- name: Upload image
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb #v3.1.1
with:
name: exporter-container
path: exporter-container.tar

e2e-tests:
needs: [build]
strategy:
matrix:
mongodb: ["4.4", "5.0"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
- name: Download exporter container
uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 #v3.0.1
with:
name: exporter-container
path: /tmp
- name: Load image
run: |
docker load --input /tmp/exporter-container.tar
docker image ls -a
- name: Setup Kubernetes
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
with:
version: v0.11.1
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
- name: Setup kustomize
shell: bash
run: |
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"
tar xvzf kustomize_v4.5.7_linux_amd64.tar.gz
sudo mv kustomize /usr/local/bin/kustomize
rm -rfv *.tar.gz
kustomize version
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
- name: Load test image
run: kind load docker-image test/mongodb-query-exporter:latest
run: kind load docker-image raffis/mongodb-query-exporter:latest
- name: Deploy exporter
run: make deploy-test IMG=test/mongodb-query-exporter:latest
run: make deploy-test
- name: Setup MongoDB
env:
MONGODB_VER: ${{ '13.5.0' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint and Test Charts
name: pr-chart

on: pull_request

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: Automatic Rebase
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
2 changes: 1 addition & 1 deletion .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Chart
name: release-chart

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: '1.19'
go-version: '1.20'
- name: Docker Login
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Scan
name: scan

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sboms:
dockers:
- image_templates:
- ghcr.io/raffis/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile.release
dockerfile: Dockerfile
use: buildx
ids:
- cli
Expand All @@ -53,7 +53,7 @@ dockers:
- image_templates:
- "ghcr.io/raffis/{{ .ProjectName }}:{{ .Version }}-arm64v8"
goarch: arm64
dockerfile: Dockerfile.release
dockerfile: Dockerfile
use: buildx
ids:
- cli
Expand Down
18 changes: 5 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
FROM golang:1.20 as builder

ADD . /go/src/github.com/raffis/mongodb-query-exporter
WORKDIR /go/src/github.com/raffis/mongodb-query-exporter


RUN make deps build

FROM gcr.io/distroless/base
COPY --from=builder /go/src/github.com/raffis/mongodb-query-exporter/mongodb-query-exporter /bin/mongodb-query-exporter
USER 1000:1000

FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY mongodb-query-exporter mongodb-query-exporter
EXPOSE 9412
ENTRYPOINT [ "/bin/mongodb-query-exporter" ]

ENTRYPOINT ["/mongodb-query-exporter"]
8 changes: 0 additions & 8 deletions Dockerfile.release

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ integrationtest:
GOLANGCI_LINT = $(GOBIN)/golangci-lint
.PHONY: golangci-lint
golangci-lint: ## Download golint locally if necessary
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2)

.PHONY: lint
lint: golangci-lint ## Run golangci-lint against code
Expand All @@ -68,14 +68,14 @@ vet:

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

.PHONY: run
run: fmt vet
go run ./cmd/main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker-build: build ## Build docker image with the manager.
docker build -t ${IMG} .

.PHONY: docker-push
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/raffis/mongodb-query-exporter/v2

go 1.19
go 1.20

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
Expand Down

0 comments on commit 6fed7df

Please sign in to comment.