From 9c1ddbd6d7c488e0041d9c122baea612d87d544a Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Wed, 6 Apr 2022 10:32:48 +0200 Subject: [PATCH] Add golangci-lint action and restructure docker action --- .github/workflows/golangci-lint.yml | 20 ++++++++++++++ .../{build-docker-images.yml => master.yml} | 26 +++++++++++++++---- .golangci.yml | 4 +-- Dockerfile | 4 --- 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml rename .github/workflows/{build-docker-images.yml => master.yml} (56%) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..e44eb33 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/master.yml similarity index 56% rename from .github/workflows/build-docker-images.yml rename to .github/workflows/master.yml index b57c819..e53516e 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/master.yml @@ -1,15 +1,33 @@ -name: Build Docker images +name: Master workflow on: push: branches: [ master ] 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 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 with: @@ -22,8 +40,6 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Test - run: DOCKER_BUILDKIT=1 docker build -t temptest . --target test - name: Build base image run: DOCKER_BUILDKIT=1 docker build -t ghcr.io/jlelse/goblog:latest . --target base - name: Build tools image diff --git a/.golangci.yml b/.golangci.yml index fd5b089..7ea9d59 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,10 +32,10 @@ linters: - gosec linters-settings: gosimple: - go: "1.17" + go: "1.18" checks: ["all"] gostatichcheck: - go: "1.17" + go: "1.18" checks: ["all"] dupl: threshold: 125 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 381fbe5..fc6a1db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,10 +16,6 @@ FROM buildbase as build RUN go build -ldflags '-w -s' -o GoBlog -FROM build as test - -RUN go test -timeout 15s -cover ./... - FROM alpine:3.15 as base WORKDIR /app