Skip to content

Commit 1c223d8

Browse files
committed
feat: init
0 parents  commit 1c223d8

File tree

168 files changed

+19260
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+19260
-0
lines changed

.envrc

Whitespace-only changes.

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
target-branch: "next"
6+
schedule:
7+
interval: daily
8+
9+
- package-ecosystem: gomod
10+
directory: /
11+
target-branch: "next"
12+
schedule:
13+
interval: daily

.github/workflows/ci.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- beta
10+
- next
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
- uses: asdf-vm/actions/install@v3
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version: '>=1.22.6'
26+
- uses: golangci/golangci-lint-action@v6
27+
with:
28+
version: latest
29+
skip-cache: false
30+
test:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
- uses: asdf-vm/actions/install@v3
37+
- uses: actions/setup-go@v5
38+
with:
39+
go-version: '>=1.22.6'
40+
- run: make test
41+
test-acceptance:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- run: dd if=/dev/zero of=/tmp/zfsstorage bs=524288000 count=1 # 500mb storage
45+
- run: sudo apt-get update
46+
- run: sudo apt install zfsutils-linux
47+
- run: sudo zpool create zfs-pool2 /tmp/zfsstorage
48+
- run: sudo zfs create zfs-pool2/unencrypted
49+
- run: echo "ddddddddddddddddddddddddddddddd" > /tmp/zfs-key
50+
- run: sudo zfs create -o encryption=on -o keylocation=file:///tmp/zfs-key -o keyformat=raw -u -v zfs-pool2/encrypted
51+
- uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 0
54+
- uses: asdf-vm/actions/install@v3
55+
- uses: actions/setup-go@v5
56+
with:
57+
go-version: '>=1.22.6'
58+
- run: sudo make test-acceptance
59+
release:
60+
runs-on: ubuntu-latest
61+
needs: [ lint, test, test-acceptance ]
62+
if: github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/next'
63+
permissions:
64+
contents: write # to be able to publish a GitHub release
65+
issues: write # to be able to comment on released issues
66+
pull-requests: write # to be able to comment on released pull requests
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
- uses: asdf-vm/actions/install@v3
72+
- uses: actions/setup-go@v5
73+
with:
74+
go-version: '>=1.22.6'
75+
- uses: cycjimmy/semantic-release-action@v4
76+
id: semantic
77+
with:
78+
extra_plugins: |
79+
@semantic-release/changelog
80+
@semantic-release/git
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
- run: git reset --hard && git clean -fdx
84+
- uses: goreleaser/goreleaser-action@v6
85+
if: steps.semantic.outputs.new_release_published == 'true'
86+
with:
87+
distribution: goreleaser
88+
version: latest
89+
args: release
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
docs:
93+
runs-on: ubuntu-latest
94+
if: github.ref == 'refs/heads/next'
95+
needs: [ release ]
96+
env:
97+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
98+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
99+
steps:
100+
- uses: actions/checkout@v4
101+
- name: Install Vercel CLI
102+
run: npm install --global vercel@latest
103+
- name: Pull Vercel Environment Information
104+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
105+
- name: Build Project Artifacts
106+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
107+
- name: Deploy Project Artifacts to Vercel
108+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

.golangci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
linters-settings:
2+
whitespace:
3+
multi-if: true
4+
multi-func: true
5+
errcheck:
6+
check-type-assertions: true
7+
goconst:
8+
min-len: 2
9+
min-occurrences: 3
10+
gocritic:
11+
enabled-tags:
12+
- diagnostic
13+
- experimental
14+
- opinionated
15+
- performance
16+
- style
17+
govet:
18+
enable-all: true
19+
disable:
20+
- fieldalignment
21+
nolintlint:
22+
require-explanation: true
23+
require-specific: true
24+
varnamelen:
25+
min-name-length: 2
26+
max-distance: 12
27+
unparam:
28+
check-exported: true
29+
depguard:
30+
rules:
31+
cmd:
32+
list-mode: strict
33+
files:
34+
- "**/cmd/**/*.go"
35+
- "**/cmd/*.go"
36+
allow:
37+
- $all
38+
- $gostd
39+
- "github.com/spf13/cobra"
40+
- "github.com/backup-blob/zfs-backup-blob/internal/driver"
41+
- "github.com/backup-blob/zfs-backup-blob/internal/repository"
42+
- "github.com/backup-blob/zfs-backup-blob/internal/usecase"
43+
- "github.com/backup-blob/zfs-backup-blob/internal/domain"
44+
- "github.com/backup-blob/zfs-backup-blob/cmd/command"
45+
- "github.com/backup-blob/zfs-backup-blob/pkg/format"
46+
- "github.com/golobby/container/v3"
47+
repo:
48+
list-mode: strict
49+
files:
50+
- "**/internal/repository/**/*.go"
51+
- "**/internal/repository/*.go"
52+
allow:
53+
- $gostd
54+
- "github.com/backup-blob/zfs-backup-blob/internal/domain"
55+
- "github.com/backup-blob/zfs-backup-blob/internal/driver"
56+
usecase:
57+
list-mode: strict
58+
files:
59+
- "**/internal/usecase/**/*.go"
60+
- "**/internal/usecase/*.go"
61+
allow:
62+
- $gostd
63+
- "github.com/backup-blob/zfs-backup-blob/internal/domain"
64+
- "github.com/backup-blob/zfs-backup-blob/internal/repository"
65+
driver:
66+
list-mode: strict
67+
files:
68+
- "**/internal/driver/**/*.go"
69+
- "**/internal/driver/*.go"
70+
allow:
71+
- $gostd
72+
- "github.com/go-playground/validator/v10"
73+
- "github.com/backup-blob/zfs-backup-blob/internal/domain"
74+
- "github.com/backup-blob/zfs-backup-blob/pkg"
75+
- "github.com/aws/aws-sdk-go-v2"
76+
- "github.com/rs/zerolog"
77+
- "github.com/jedib0t/go-pretty/v6/table"
78+
deny:
79+
- pkg: "github.com/backup-blob/zfs-backup-blob/internal/repository"
80+
desc: not allowed
81+
- pkg: "github.com/backup-blob/zfs-backup-blob/internal/usecase"
82+
desc: not allowed
83+
pkg:
84+
list-mode: strict
85+
files:
86+
- "**/pkg/**/*.go"
87+
- "**/pkg/*.go"
88+
allow:
89+
- $all
90+
- $gostd
91+
- "github.com/fujiwara/shapeio"
92+
- "github.com/docker/go-units"
93+
deny:
94+
- pkg: "github.com/backup-blob/zfs-backup-blob/internal"
95+
desc: not allowed
96+
97+
linters:
98+
disable-all: true
99+
enable:
100+
- wsl
101+
- govet
102+
- whitespace
103+
- varnamelen
104+
- unparam
105+
- unconvert
106+
- testpackage
107+
- tenv
108+
- nolintlint
109+
- nestif
110+
- nilerr
111+
- maintidx
112+
- gosec
113+
- mnd
114+
- goconst
115+
- gocritic
116+
- godot
117+
- bodyclose
118+
- containedctx
119+
- depguard
120+
- dupl
121+
- durationcheck
122+
- errname
123+
- forcetypeassert
124+
- cyclop
125+
run:
126+
issues-exit-code: 1
127+
tests: false
128+
129+
issues:
130+
max-same-issues: 0
131+
exclude-files:
132+
- ".*_test.go$"
133+
- "pkg/fakemiddleware/fakemiddleware.go$"
134+
exclude-dirs:
135+
- "docs"
136+
exclude-rules:
137+
- linters:
138+
- mnd
139+
text: "Magic number: 2, in <condition> detected"
140+
141+
output:
142+
show-stats: true

.goreleaser.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The lines below are called `modelines`. See `:help modeline`
5+
# Feel free to remove those if you don't want/need to use them.
6+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+
version: 1
10+
11+
before:
12+
hooks:
13+
- go mod tidy
14+
15+
builds:
16+
- env:
17+
- CGO_ENABLED=0
18+
goos:
19+
- linux
20+
- darwin
21+
main: ./cmd
22+
23+
archives:
24+
- format: tar.gz
25+
# this name template makes the OS and Arch compatible with the results of `uname`.
26+
name_template: >-
27+
{{ .ProjectName }}_
28+
{{- title .Os }}_
29+
{{- if eq .Arch "amd64" }}x86_64
30+
{{- else if eq .Arch "386" }}i386
31+
{{- else }}{{ .Arch }}{{ end }}
32+
{{- if .Arm }}v{{ .Arm }}{{ end }}
33+
# use zip for windows archives
34+
format_overrides:
35+
- goos: windows
36+
format: zip
37+
38+
changelog:
39+
sort: asc
40+
filters:
41+
exclude:
42+
- "^docs:"
43+
- "^test:"

.releaserc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"branches": [
3+
{
4+
"name": "main"
5+
},
6+
{
7+
"name": "beta",
8+
"channel": "alpha",
9+
"prerelease": true
10+
},
11+
{
12+
"name": "next",
13+
"channel": "alpha",
14+
"prerelease": true
15+
}
16+
],
17+
"tagFormat": "v${version}",
18+
"plugins": [
19+
"@semantic-release/commit-analyzer",
20+
"@semantic-release/release-notes-generator",
21+
["@semantic-release/github", {"successComment": false, "failComment": false}]
22+
]
23+
}

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
golang 1.22.6

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
PHONY: install lint format
2+
3+
install:
4+
@asdf install
5+
@go install github.com/google/go-licenses@latest
6+
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
7+
@go install github.com/smartystreets/goconvey@latest
8+
@go install go.uber.org/mock/mockgen@latest
9+
@make -C docs install
10+
11+
lint:
12+
@test -z $(gofmt -l .)
13+
@golangci-lint run ./...
14+
@make -C docs lint
15+
16+
license-check:
17+
@go-licenses report ./... --ignore github.com/backup-blob/zfs-backup-blob,golang.org/x/sys/unix
18+
19+
format:
20+
@go fmt ./...
21+
22+
test:
23+
@go test ./... -cover -short -count=1
24+
25+
coverage:
26+
@go test ./... -cover -short -coverprofile=coverage.out
27+
@go tool cover -html=coverage.out
28+
29+
test-acceptance:
30+
@go test ./... -cover -run Integration -count=1
31+
32+
gen-mocks:
33+
@mockgen -source=internal/domain/zfs.go -destination=internal/domain/mocks/zfs.go -package mocks
34+
@mockgen -source=internal/domain/snapshot.go -destination=internal/domain/mocks/snapshot.go -package mocks
35+
@mockgen -source=internal/domain/storage.go -destination=internal/domain/mocks/storage.go -package mocks
36+
@mockgen -source=internal/domain/backup.go -destination=internal/domain/mocks/backup.go -package mocks
37+
@mockgen -source=internal/domain/volume.go -destination=internal/domain/mocks/volume.go -package mocks
38+
@mockgen -source=internal/domain/render.go -destination=internal/domain/mocks/render.go -package mocks
39+
@mockgen -source=internal/domain/backup_state.go -destination=internal/domain/mocks/backup_state.go -package mocks
40+
@mockgen -source=internal/domain/config/config.go -destination=internal/domain/config/mocks/config.go -package mocks_config

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Zfs-Backup-Blob
2+
3+
A Backup tool to back up zfs snapshots to a blob storage.

0 commit comments

Comments
 (0)