Skip to content

Commit 8c2bf2e

Browse files
authored
ci: initial pipeline (#3)
Signed-off-by: Francesco Canovai <[email protected]>
1 parent 3f4759c commit 8c2bf2e

35 files changed

+739
-119
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
ci:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
# We need the full history for the commitlint task
14+
with:
15+
fetch-depth: 0
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
- name: Install Task
18+
uses: arduino/setup-task@v2
19+
- name: Install Dagger
20+
env:
21+
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
22+
DAGGER_VERSION: 0.13.3
23+
run: |
24+
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
25+
- name: Run CI task
26+
run: |
27+
task ci
28+
- name: Write manifest
29+
run: |
30+
task manifest
31+
- name: Publish images
32+
if: |
33+
github.event_name == 'workflow_dispatch' ||
34+
github.event.pull_request.head.repo.full_name == github.repository
35+
env:
36+
REGISTRY_USER: ${{ github.actor }}
37+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
task publish
40+
- name: Attach manifest to workflow run
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: manifest.yaml
44+
path: ./manifest.yaml
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# TODO: googleapis/release-please-action cannot sign commits yet.
13+
# We'll use the cli until there's a fix for
14+
# https://github.com/googleapis/release-please/issues/2280.
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Install Task
21+
uses: arduino/setup-task@v2
22+
- name: Install Dagger
23+
env:
24+
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
25+
DAGGER_VERSION: 0.13.3
26+
run: |
27+
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
28+
- name: Create image and manifest
29+
env:
30+
REGISTRY_USER: ${{ github.actor }}
31+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
task publish
34+
task manifest
35+
- name: Attach manifest to workflow run
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: manifest.yaml
39+
path: ./manifest.yaml
40+
# TODO: remove bump-minor-pre-major when in production. It prevents
41+
# release-please from bumping the major version on breaking changes.
42+
# TODO: remove release-as after first release. Used to set the first
43+
# release version, which would default to 1.0.0. Set the version
44+
# manually also for 1.0.0.
45+
# We use a GitHub token with write permissions to create the release,
46+
# otherwise we won't be able to trigger a new run when pushing on main.
47+
- name: Run release-please
48+
run: |
49+
npx release-please release-pr \
50+
--token="${{ secrets.REPO_PAT }}" \
51+
--repo-url="${{ github.repository }}" \
52+
--bump-minor-pre-major=true \
53+
--release-as=0.1.0 \
54+
--signoff "Peggie <[email protected]>";
55+
npx release-please github-release \
56+
--token="${{ secrets.REPO_PAT }}" \
57+
--repo-url="${{ github.repository }}"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release Publish Artifacts
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
release-publish-artifacts:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
- name: Install Task
13+
uses: arduino/setup-task@v2
14+
- name: Install Dagger
15+
env:
16+
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
17+
DAGGER_VERSION: 0.13.3
18+
run: |
19+
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
20+
- name: Create image and manifest
21+
env:
22+
REGISTRY_USER: ${{ github.actor }}
23+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
24+
run: |
25+
task publish
26+
task manifest
27+
- name: Attach manifest to release
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
task upload-manifest-to-release

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ go.work
2626
*.swo
2727
*~
2828

29-
# Temporary files
29+
# Dependency directories (remove the comment below to include it)
3030
vendor/
31+
32+
# Go workspace file
33+
go.work
34+
35+
# Taskfile cache
36+
.task

.golangci.yml

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
1-
run:
2-
timeout: 5m
3-
allow-parallel-runners: true
1+
linters-settings:
2+
lll:
3+
line-length: 120
4+
gci:
5+
sections:
6+
- standard
7+
- default
8+
- prefix(github.com/cloudnative-pg/plugin-barman-cloud)
9+
- blank
10+
- dot
11+
nlreturn:
12+
# Size of the block (including return statement that is still "OK")
13+
# so no return split required.
14+
# Default: 1
15+
block-size: 3
416

517
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
9-
# restore some of the defaults
10-
# (fill in the rest as needed)
1118
exclude-rules:
12-
- path: "api/*"
13-
linters:
14-
- lll
15-
- path: "internal/*"
19+
# Allow dot imports for ginkgo and gomega
20+
- source: ginkgo|gomega
1621
linters:
17-
- dupl
18-
- lll
22+
- revive
23+
text: "should not use dot imports"
24+
- linters:
25+
- stylecheck
26+
text: "should not use dot imports"
27+
exclude-dirs:
28+
- vendor
29+
1930
linters:
20-
disable-all: true
21-
enable:
22-
- dupl
23-
- errcheck
31+
enable-all: true
32+
disable:
33+
- depguard
34+
- err113
35+
- exhaustruct
36+
- execinquery
2437
- exportloopref
25-
- ginkgolinter
26-
- goconst
27-
- gocyclo
28-
- gofmt
29-
- goimports
30-
- gosimple
31-
- govet
32-
- ineffassign
33-
- lll
34-
- misspell
35-
- nakedret
36-
- prealloc
37-
- revive
38-
- staticcheck
39-
- typecheck
40-
- unconvert
41-
- unparam
42-
- unused
38+
- funlen
39+
- gochecknoglobals
40+
- gochecknoinits
41+
- godox
42+
- gomnd
43+
- paralleltest
44+
- testpackage
45+
- varnamelen
46+
- wsl
4347

44-
linters-settings:
45-
revive:
46-
rules:
47-
- name: comment-spacings
48+
run:
49+
timeout: 10m
50+
allow-parallel-runners: true

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.0.0"
3+
}

.spellcheck.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
matrix:
2+
- name: Markdown
3+
sources:
4+
# Ignore the CHANGELOG.md file, it is autogenerated
5+
- ./**/*.md|!./CHANGELOG.md
6+
dictionary:
7+
wordlists:
8+
- .wordlist.txt
9+
aspell:
10+
lang: en
11+
d: en_US
12+
pipeline:
13+
- pyspelling.filters.markdown:
14+
- pyspelling.filters.html:
15+
ignores:
16+
- ':matches(code, pre)'
17+
- 'code'
18+
- 'pre'

.wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cnpg
2+
CloudNativePG
3+
TODO

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN go mod download
1414
# Copy the go source
1515
COPY cmd/main.go cmd/main.go
1616
COPY api/ api/
17-
COPY internal/controller/ internal/controller/
17+
COPY internal/ internal/
1818

1919
# Build
2020
# the GOARCH has not a default value to allow the binary be built according to the host where the command

0 commit comments

Comments
 (0)