Skip to content

Commit

Permalink
Migrated to go 1.18 and CI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mmontes11 committed Jun 7, 2022
1 parent badaca4 commit be5bd1c
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 161 deletions.
13 changes: 0 additions & 13 deletions .env.cluster.sample

This file was deleted.

9 changes: 0 additions & 9 deletions .env.sample

This file was deleted.

40 changes: 18 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,50 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.16
go-version: 1.18

- name: Check out code
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3

- name: Lint
run: make lint
- name: GolangCI Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.46.2

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.16
go-version: 1.18

- name: Check out code
- name: Checkout code
uses: actions/checkout@v2

- name: Build
run: make build

- name: Bin
uses: actions/upload-artifact@v2
with:
name: echoperator
path: ./bin/echoperator

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.16
go-version: 1.18

- name: Check out code
- name: Checkout code
uses: actions/checkout@v2

- name: Test
run: make cover

- name: Cover
- name: Coverage
uses: actions/upload-artifact@v2
with:
name: cover
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/deploy.yml

This file was deleted.

59 changes: 51 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,67 @@ name: Release
on:
push:
tags:
- "v*"
- "*"

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch tags
run: git fetch --force --tags

- name: Setup QEMU
uses: docker/setup-qemu-action@v1

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx

- name: Check out code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Prepare
id: prep
run: |
VERSION=sha-${GITHUB_SHA::8}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}
- name: Publish multi-arch Docker image
uses: docker/build-push-action@v2
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/arm64,linux/amd64
tags: |
docker.io/mmontes11/echoperator:${{ steps.prep.outputs.VERSION }}
docker.io/mmontes11/echoperator:latest
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}
- name: Release
- name: GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ./scripts/release.sh
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
37 changes: 37 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
linters-settings:
dupl:
threshold: 100
gocyclo:
min-complexity: 15
lll:
line-length: 140
misspell:
locale: US

linters:
disable-all: true
enable:
- deadcode
- dupl
- errcheck
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nestif
- staticcheck
- typecheck
- unused
- varcheck
# not compatible with go 1.18 yet
# - bodyclose
# - noctx
# - structcheck

run:
timeout: 5m
go: "1.18"
13 changes: 13 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project_name: echoperator
builds:
- main: ./cmd/echoperator
binary: echoperator
goos:
- linux
goarch:
- arm64
- amd64
env:
- CGO_ENABLED=0
archives:
- name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM golang:1.16.6-alpine3.14 AS builder
FROM golang:1.18.3-alpine3.16 AS builder

RUN apk update && \
apk add --no-cache --update make bash git ca-certificates && \
update-ca-certificates
apk add --no-cache --update make bash git ca-certificates && \
update-ca-certificates

WORKDIR /go/src/echoperator

COPY . .

RUN make build

FROM alpine:3.14.0
FROM alpine:3.16.0

COPY --from=builder /go/src/echoperator/bin/echoperator /echoperator

Expand Down
Loading

0 comments on commit be5bd1c

Please sign in to comment.