mirror of https://github.com/jlelse/GoBlog
Add golangci-lint action and restructure docker action
This commit is contained in:
parent
0af387930d
commit
9c1ddbd6d7
|
@ -0,0 +1,20 @@
|
||||||
|
name: Lint Code with golangci-lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
golangci-lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.18'
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v2
|
||||||
|
with:
|
||||||
|
version: latest
|
|
@ -1,15 +1,33 @@
|
||||||
name: Build Docker images
|
name: Master workflow
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install SQLite
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install libsqlite3-dev build-essential
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: '1.18'
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Test
|
||||||
|
run: go test -timeout 15s -tags linux,libsqlite3,sqlite_fts5 -cover ./...
|
||||||
|
docker:
|
||||||
|
name: Build Docker images
|
||||||
|
needs: [ test ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
with:
|
||||||
|
@ -22,8 +40,6 @@ jobs:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Test
|
|
||||||
run: DOCKER_BUILDKIT=1 docker build -t temptest . --target test
|
|
||||||
- name: Build base image
|
- name: Build base image
|
||||||
run: DOCKER_BUILDKIT=1 docker build -t ghcr.io/jlelse/goblog:latest . --target base
|
run: DOCKER_BUILDKIT=1 docker build -t ghcr.io/jlelse/goblog:latest . --target base
|
||||||
- name: Build tools image
|
- name: Build tools image
|
|
@ -32,10 +32,10 @@ linters:
|
||||||
- gosec
|
- gosec
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gosimple:
|
gosimple:
|
||||||
go: "1.17"
|
go: "1.18"
|
||||||
checks: ["all"]
|
checks: ["all"]
|
||||||
gostatichcheck:
|
gostatichcheck:
|
||||||
go: "1.17"
|
go: "1.18"
|
||||||
checks: ["all"]
|
checks: ["all"]
|
||||||
dupl:
|
dupl:
|
||||||
threshold: 125
|
threshold: 125
|
|
@ -16,10 +16,6 @@ FROM buildbase as build
|
||||||
|
|
||||||
RUN go build -ldflags '-w -s' -o GoBlog
|
RUN go build -ldflags '-w -s' -o GoBlog
|
||||||
|
|
||||||
FROM build as test
|
|
||||||
|
|
||||||
RUN go test -timeout 15s -cover ./...
|
|
||||||
|
|
||||||
FROM alpine:3.15 as base
|
FROM alpine:3.15 as base
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
Loading…
Reference in New Issue