feat(ci): prepare concourse pipelines
All checks were successful
concourse-ci/golangci-lint golangci-lint run
concourse-ci/gotestsum gotestsum

This commit is contained in:
Peter 2023-01-01 13:42:36 +01:00
parent 51b6ffbff3
commit d4d2cbd586
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
7 changed files with 204 additions and 73 deletions

View file

@ -0,0 +1,42 @@
---
resource_types:
- name: git-branches
type: registry-image
source:
repository: aoldershaw/git-branches-resource
resources:
- name: feature-branches
type: git-branches
source:
uri: https://code.icb4dc0.de/prskr/goveal.git
# The "(?P<name>pattern)" syntax defines a named capture group.
# aoldershaw/git-branches-resource emits the value of each named capture
# group under the `groups` key.
#
# e.g. feature/some-feature ==> {"groups": {"feature": "some-feature"}}
branch_regex: '(\d+-|\w+\/)(?P<feature>.*)'
- name: goveal.git
type: git
icon: github
source:
uri: https://code.icb4dc0.de/prskr/goveal.git
fetch_tags: true
jobs:
- name: set-feature-pipelines
plan:
- in_parallel:
- get: feature-branches
trigger: true
- get: goveal.git
- load_var: branches
file: feature-branches/branches.json
- across:
- var: branch
values: ((.:branches))
set_pipeline: goveal-dev
file: goveal.git/.concourse/branch-validate.yml
instance_vars: {feature: ((.:branch.groups.feature))}
vars: {branch: ((.:branch.name))}

View file

@ -0,0 +1,69 @@
---
resources:
- name: goveal.git
type: git
icon: github
source:
uri: https://code.icb4dc0.de/prskr/goveal.git
branch: ((branch))
- name: templates.git
type: git
icon: github
source:
uri: https://code.icb4dc0.de/prskr/pipeline-templates.git
jobs:
- name: lint
plan:
- get: goveal.git
trigger: true
- get: templates.git
- task: lint
file: goveal.git/.concourse/tasks/lint.yml
input_mapping: {repo: goveal.git}
on_success:
task: report-success
file: templates.git/tasks/gitea-status.yml
input_mapping: {repo: goveal.git}
vars:
project_path: prskr/goveal
context: concourse-ci/lint/golangci-lint
description: Lint Go files
state: success
on_failure:
task: report-failure
file: templates.git/tasks/gitea-status.yml
input_mapping: {repo: goveal.git}
vars:
project_path: prskr/goveal
context: concourse-ci/lint/golangci-lint
description: Lint Go files
state: failure
- name: test
plan:
- get: goveal.git
trigger: true
- get: templates.git
- task: test
file: goveal.git/.concourse/tasks/test.yml
privileged: true
input_mapping: {repo: goveal.git}
on_success:
task: report-success
file: templates.git/tasks/gitea-status.yml
input_mapping: {repo: goveal.git}
vars:
project_path: prskr/goveal
context: concourse-ci/test/gotestsum
description: Run unit tests
state: success
on_failure:
task: report-failure
file: templates.git/tasks/gitea-status.yml
input_mapping: {repo: goveal.git}
vars:
project_path: prskr/goveal
context: concourse-ci/test/gotestsum
description: Run unit tests
state: failure

30
.concourse/cleanup.yml Normal file
View file

@ -0,0 +1,30 @@
---
resources:
- name: daily
type: time
source:
interval: 24h
- name: goveal.git
type: git
icon: github
source:
uri: https://code.icb4dc0.de/prskr/goveal.git
- name: templates.git
type: git
icon: github
source:
uri: https://code.icb4dc0.de/prskr/pipeline-templates.git
jobs:
- name: renovate
plan:
- get: goveal.git
trigger: true
- get: templates.git
- get: daily
trigger: true
- task: renovate
file: templates.git/tasks/renovate.yml
input_mapping: { repo: goveal.git }
vars:
project_path: prskr/goveal

24
.concourse/tasks/lint.yml Normal file
View file

@ -0,0 +1,24 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: docker.io/golangci/golangci-lint
tag: latest
inputs:
- name: repo
path: .
params:
GO111MODULE: "on"
CGO_ENABLED: "0"
GITEA_TOKEN: ((gitea-credentials.token))
run:
path: bash
args:
- -ce
- |
golangci-lint run -v

25
.concourse/tasks/test.yml Normal file
View file

@ -0,0 +1,25 @@
---
platform: linux
image_resource:
type: registry-image
source:
repository: docker.io/golang:1.19-buster
tag: latest
inputs:
- name: repo
path: .
params:
GO111MODULE: "on"
CGO_ENABLED: "1"
GITEA_TOKEN: ((gitea-credentials.token))
run:
path: bash
args:
- -ce
- |
go install gotest.tools/gotestsum@latest
gotestsum -f pkgname-and-test-fails -- -race -shuffle=on ./...

View file

@ -1,61 +0,0 @@
name: Go
on:
push:
tags:
- v*
branches:
- main
pull_request:
permissions:
contents: write
issues: write
packages: write
pull-requests: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v3
with:
go-version: '^1.18'
id: go
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
lfs: true
fetch-depth: 0
- name: Install Task
uses: arduino/setup-task@v1
- name: Download assets
run: task download-assets
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: Build & test
run: task test
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -5,7 +5,7 @@ linters-settings:
lines: 100 lines: 100
statements: 50 statements: 50
gci: gci:
local-prefixes: github.com/baez90/goveal local-prefixes: code.icb4dc0.de/prskr/goveal
goconst: goconst:
min-len: 2 min-len: 2
min-occurrences: 2 min-occurrences: 2
@ -24,7 +24,7 @@ linters-settings:
gocyclo: gocyclo:
min-complexity: 15 min-complexity: 15
goimports: goimports:
local-prefixes: github.com/baez90/goveal local-prefixes: code.icb4dc0.de/prskr/goveal
golint: golint:
min-confidence: 0 min-confidence: 0
gomnd: gomnd:
@ -58,47 +58,52 @@ linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true disable-all: true
enable: enable:
- deadcode - contextcheck
- dogsled - dogsled
- dupl - dupl
- errcheck - errcheck
- errchkjson
- errname
- errorlint
- exhaustive - exhaustive
- exportloopref - exportloopref
- funlen - funlen
- gocognit - gocognit
- goconst - goconst
- gocritic # - gocritic
- gocyclo - gocyclo
- godox - godox
- gofumpt - gofumpt
- goimports - goimports
- gomoddirectives
- gomnd - gomnd
- gosec - gosec
- gosimple - gosimple
- govet - govet
- importas - importas
- ineffassign - ineffassign
# - ireturn - enable later
- lll - lll
- misspell - misspell
- nakedret - nakedret
- nestif - nestif
- nilnil
- noctx - noctx
- nolintlint - nolintlint
- paralleltest - paralleltest
- prealloc - prealloc
- predeclared
- promlinter - promlinter
- staticcheck - staticcheck
- structcheck
- stylecheck - stylecheck
- testpackage - testpackage
- thelper - thelper
- typecheck # - typecheck
- unconvert - unconvert
- unparam - unparam
- varcheck
- whitespace - whitespace
- unused
#- unused - wastedassign
issues: issues:
# Excluding configuration per-path, per-linter, per-text and per-source # Excluding configuration per-path, per-linter, per-text and per-source
@ -118,6 +123,3 @@ run:
skip-files: skip-files:
- ".*\\.pb\\.go$" - ".*\\.pb\\.go$"
- ".*.mock.\\.go$" - ".*.mock.\\.go$"
service:
golangci-lint-version: 1.43.x # use the fixed version to not introduce new linters unexpectedly