From d4d2cbd586f320be9427b4f8bcadc21e399ea060 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sun, 1 Jan 2023 13:42:36 +0100 Subject: [PATCH] feat(ci): prepare concourse pipelines --- .concourse/branch-tracker.yml | 42 +++++++++++++++++++++ .concourse/branch-validate.yml | 69 ++++++++++++++++++++++++++++++++++ .concourse/cleanup.yml | 30 +++++++++++++++ .concourse/tasks/lint.yml | 24 ++++++++++++ .concourse/tasks/test.yml | 25 ++++++++++++ .github/workflows/go.yml | 61 ------------------------------ .golangci.yml | 26 +++++++------ 7 files changed, 204 insertions(+), 73 deletions(-) create mode 100644 .concourse/branch-tracker.yml create mode 100644 .concourse/branch-validate.yml create mode 100644 .concourse/cleanup.yml create mode 100644 .concourse/tasks/lint.yml create mode 100644 .concourse/tasks/test.yml delete mode 100644 .github/workflows/go.yml diff --git a/.concourse/branch-tracker.yml b/.concourse/branch-tracker.yml new file mode 100644 index 0000000..73c2496 --- /dev/null +++ b/.concourse/branch-tracker.yml @@ -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 "(?Ppattern)" 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.*)' + + - 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))} \ No newline at end of file diff --git a/.concourse/branch-validate.yml b/.concourse/branch-validate.yml new file mode 100644 index 0000000..d474c78 --- /dev/null +++ b/.concourse/branch-validate.yml @@ -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 \ No newline at end of file diff --git a/.concourse/cleanup.yml b/.concourse/cleanup.yml new file mode 100644 index 0000000..11c120b --- /dev/null +++ b/.concourse/cleanup.yml @@ -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 diff --git a/.concourse/tasks/lint.yml b/.concourse/tasks/lint.yml new file mode 100644 index 0000000..964dba3 --- /dev/null +++ b/.concourse/tasks/lint.yml @@ -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 diff --git a/.concourse/tasks/test.yml b/.concourse/tasks/test.yml new file mode 100644 index 0000000..76723ef --- /dev/null +++ b/.concourse/tasks/test.yml @@ -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 ./... diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 612e487..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -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 }} diff --git a/.golangci.yml b/.golangci.yml index 4fcf4b7..9c8db24 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,7 +5,7 @@ linters-settings: lines: 100 statements: 50 gci: - local-prefixes: github.com/baez90/goveal + local-prefixes: code.icb4dc0.de/prskr/goveal goconst: min-len: 2 min-occurrences: 2 @@ -24,7 +24,7 @@ linters-settings: gocyclo: min-complexity: 15 goimports: - local-prefixes: github.com/baez90/goveal + local-prefixes: code.icb4dc0.de/prskr/goveal golint: min-confidence: 0 gomnd: @@ -58,47 +58,52 @@ linters: # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint disable-all: true enable: - - deadcode + - contextcheck - dogsled - dupl - errcheck + - errchkjson + - errname + - errorlint - exhaustive - exportloopref - funlen - gocognit - goconst - - gocritic + # - gocritic - gocyclo - godox - gofumpt - goimports + - gomoddirectives - gomnd - gosec - gosimple - govet - importas - ineffassign + # - ireturn - enable later - lll - misspell - nakedret - nestif + - nilnil - noctx - nolintlint - paralleltest - prealloc + - predeclared - promlinter - staticcheck - - structcheck - stylecheck - testpackage - thelper - - typecheck + # - typecheck - unconvert - unparam - - varcheck - whitespace - - #- unused + - unused + - wastedassign issues: # Excluding configuration per-path, per-linter, per-text and per-source @@ -118,6 +123,3 @@ run: skip-files: - ".*\\.pb\\.go$" - ".*.mock.\\.go$" - -service: - golangci-lint-version: 1.43.x # use the fixed version to not introduce new linters unexpectedly