Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kijimaD committed Oct 18, 2023
0 parents commit b53acfe
Show file tree
Hide file tree
Showing 11 changed files with 1,063 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: ⚗️Check

on:
push:

env:
GH_TOKEN: ${{ secrets.WRITE_PACKAGE }}

jobs:
# 共通処理
setup:
runs-on: ubuntu-latest
steps:
- name: set up
uses: actions/setup-go@v4
with:
go-version: ^1.20
id: go
- name: check out
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@main
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
build:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: build
run: make build

run:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: run
run: make run

test:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: test
run: make test

lint:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --verbose
version: v1.54

image:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Get git tag(short)
id: git-tag
run: |
GIT_TAG=$(git rev-parse --short HEAD)
echo "::set-output name=git-tag::$GIT_TAG"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.WRITE_PACKAGE }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build image for release
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
target: release
push: true
tags: ghcr.io/kijimad/go_skel:${{ steps.git-tag.outputs.git-tag }},ghcr.io/kijimad/go_skel:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Move cache
if: github.ref == 'refs/heads/main'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

bin/
105 changes: 105 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
# - deadcode
- decorder
# - depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
# - exhaustivestruct
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
# - golint
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
# - ifshort
- importas
- ineffassign
- interfacebloat
# - interfacer
- ireturn
- lll
- loggercheck
- maintidx
- makezero
# - maligned
- misspell
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nonamedreturns
# - nosnakecase
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- reassign
- revive
# - rowserrcheck
# - scopelint
- sqlclosecheck
- staticcheck
# - structcheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
# - testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
# - varcheck
# - varnamelen
# - wastedassign
- whitespace
- wrapcheck
# - wsl
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
###########
# builder #
###########

FROM golang:1.20-buster AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
upx-ucl

WORKDIR /build
COPY . .

RUN GO111MODULE=on CGO_ENABLED=0 go build -o ./bin/go_skel \
-ldflags='-w -s -extldflags "-static"' \
. \
&& upx-ucl --best --ultra-brute ./bin/go_skel

###########
# release #
###########

FROM gcr.io/distroless/static-debian11:latest AS release

COPY --from=builder /build/bin/go_skel /bin/
WORKDIR /workdir
ENTRYPOINT ["/bin/go_skel"]
Loading

0 comments on commit b53acfe

Please sign in to comment.