Skip to content

Commit 2ba853a

Browse files
authored
Initial commit
0 parents  commit 2ba853a

35 files changed

Lines changed: 2664 additions & 0 deletions

.air.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
root = "."
2+
testdata_dir = "testdata"
3+
tmp_dir = "tmp"
4+
5+
[build]
6+
args_bin = []
7+
bin = "./tmp/main"
8+
cmd = "go build -o ./tmp/main ."
9+
delay = 1000
10+
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
11+
exclude_file = []
12+
exclude_regex = ["_test.go"]
13+
exclude_unchanged = false
14+
follow_symlink = false
15+
full_bin = ""
16+
include_dir = []
17+
include_ext = ["go", "tpl", "tmpl", "html"]
18+
include_file = []
19+
kill_delay = "1s"
20+
log = "build-errors.log"
21+
poll = false
22+
poll_interval = 0
23+
post_cmd = []
24+
pre_cmd = []
25+
rerun = false
26+
rerun_delay = 500
27+
send_interrupt = true
28+
stop_on_error = true
29+
30+
[color]
31+
app = ""
32+
build = "yellow"
33+
main = "magenta"
34+
runner = "green"
35+
watcher = "cyan"
36+
37+
[log]
38+
main_only = false
39+
silent = false
40+
time = false
41+
42+
[misc]
43+
clean_on_exit = true
44+
45+
[proxy]
46+
app_port = 0
47+
enabled = false
48+
proxy_port = 0
49+
50+
[screen]
51+
clear_on_rebuild = false
52+
keep_scroll = true

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Close inactive issues and PRs
2+
on:
3+
schedule:
4+
- cron: "30 1 * * *"
5+
6+
jobs:
7+
close-issues:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
issues: write
11+
pull-requests: write
12+
steps:
13+
- uses: actions/stale@v10
14+
with:
15+
days-before-stale: 7
16+
days-before-close: 7
17+
exempt-all-assignees: true
18+
19+
stale-issue-message: "This issue is stale because it has been open for 7 days with no activity."
20+
close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
21+
stale-issue-label: "stale"
22+
23+
stale-pr-message: "This PR is stale because it has been open for 7 days with no activity."
24+
close-pr-message: "This PR was closed because it has been inactive for 7 days since being marked as stale."
25+
stale-pr-label: "stale"

.github/workflows/go.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: Go
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches: [master]
10+
paths:
11+
- "**.go"
12+
- "go.mod"
13+
- "go.sum"
14+
- ".golangci.yml"
15+
pull_request:
16+
branches: [master]
17+
paths:
18+
- "**.go"
19+
- "go.mod"
20+
- "go.sum"
21+
- ".golangci.yml"
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
golangci:
29+
name: Lint
30+
runs-on: ubuntu-latest
31+
steps:
32+
# step 1: checkout repository code
33+
- name: Checkout code into workspace directory
34+
uses: actions/checkout@v4
35+
36+
# step 2: set up go
37+
- name: Set up Go
38+
uses: actions/setup-go@v6
39+
with:
40+
go-version: stable
41+
42+
# step 3: run golangci-lint
43+
- name: Run golangci-lint
44+
uses: golangci/golangci-lint-action@v8
45+
with:
46+
version: latest
47+
args: --timeout=5m
48+
49+
test:
50+
name: Test
51+
runs-on: ubuntu-latest
52+
steps:
53+
# step 1: checkout repository code
54+
- name: Checkout code into workspace directory
55+
uses: actions/checkout@v4
56+
57+
# step 2: set up go
58+
- name: Set up Go
59+
uses: actions/setup-go@v6
60+
with:
61+
go-version: stable
62+
63+
# step 3: install dependencies
64+
- name: Install all Go dependencies
65+
run: go mod download
66+
67+
# step 4: run test
68+
- name: Run coverage
69+
run: go test -race -shuffle=on -count=1 -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./...
70+
71+
# step 5: upload coverage
72+
- name: Upload coverage to Codecov
73+
uses: codecov/codecov-action@v5
74+
with:
75+
token: ${{ secrets.CODECOV_TOKEN }}
76+
77+
benchmark:
78+
name: Benchmark
79+
runs-on: ubuntu-latest
80+
permissions:
81+
contents: read
82+
pull-requests: write
83+
steps:
84+
# step 1: checkout repository code
85+
- name: Checkout code into workspace directory
86+
uses: actions/checkout@v4
87+
88+
# step 2: set up go
89+
- name: Set up Go
90+
uses: actions/setup-go@v6
91+
with:
92+
go-version: stable
93+
94+
# step 3: install dependencies
95+
- name: Install all Go dependencies
96+
run: go mod download
97+
98+
# step 4: restore previous benchmark history (if exists)
99+
- name: Restore benchmark history
100+
id: benchmark-cache
101+
uses: actions/cache/restore@v4
102+
with:
103+
path: ./cache
104+
key: ${{ runner.os }}-benchmark-${{ github.ref_name }}
105+
restore-keys: |
106+
${{ runner.os }}-benchmark-
107+
108+
# step 5: run benchmark
109+
- name: Run benchmarks
110+
run: go test -run=^$ -bench=. -benchmem ./... | tee benchmark.txt
111+
112+
# step 6: upload benchmark
113+
- name: Upload benchmark results
114+
uses: benchmark-action/github-action-benchmark@v1
115+
with:
116+
# What benchmark tool the benchmark.txt came from
117+
tool: "go"
118+
# Where the output from the benchmark tool is stored
119+
output-file-path: benchmark.txt
120+
# Where the previous data file is stored
121+
external-data-json-path: ./cache/benchmark-data.json
122+
# Workflow will fail when an alert happens
123+
fail-on-alert: true
124+
125+
# step 7: persist updated benchmark history
126+
- name: Save benchmark history
127+
if: always()
128+
uses: actions/cache/save@v4
129+
with:
130+
path: ./cache
131+
key: ${{ runner.os }}-benchmark-${{ github.ref_name }}-${{ github.run_id }}
132+
133+
e2e-test:
134+
name: E2E Test
135+
runs-on: ubuntu-latest
136+
if: false
137+
needs: test
138+
steps:
139+
# step 1: checkout repository code
140+
- name: Checkout code into workspace directory
141+
uses: actions/checkout@v4
142+
143+
# step 2: set up go
144+
- name: Set up Go
145+
uses: actions/setup-go@v6
146+
with:
147+
go-version: stable
148+
149+
# step 3: install main project dependencies
150+
- name: Install main Go dependencies
151+
run: go mod download
152+
153+
# step 4: install e2e test dependencies
154+
- name: Install E2E test dependencies
155+
run: cd tests/e2e && go mod download
156+
157+
# step 5: run e2e tests with verbose output
158+
- name: Run E2E tests
159+
run: cd tests/e2e && go test -v ./...

.github/workflows/pr-labels.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Remove Labels on New Push
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize] # Trigger on PR opened or new commits pushed
6+
7+
jobs:
8+
remove_labels:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write # Grant permission to modify labels
12+
steps:
13+
# step 1: checkout repository code
14+
- name: Checkout code into workspace directory
15+
uses: actions/checkout@v4
16+
17+
# step 2: remove specific labels
18+
- name: Remove specific labels
19+
run: |
20+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "ready" || true
21+
gh pr edit ${{ github.event.pull_request.number }} --remove-label "deployed" || true
22+
env:
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
concurrency:
8+
group: pr-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
env:
15+
DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
16+
DOCKER_REGISTRY_HOST: ${{ vars.DOCKER_REGISTRY_HOST || 'ghcr.io' }}
17+
permissions:
18+
contents: read
19+
pull-requests: write
20+
packages: write
21+
steps:
22+
- name: Prepare
23+
run: |
24+
repository=${{ github.repository }}
25+
echo "PROJECT_NAME=${repository#*/}" >> $GITHUB_ENV
26+
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Login to Container registry
33+
if: github.actor != 'dependabot[bot]'
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.DOCKER_REGISTRY_HOST }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- uses: actions/setup-go@v6
44+
with:
45+
go-version: stable
46+
47+
- name: Run GoReleaser
48+
uses: goreleaser/goreleaser-action@v6
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
52+
with:
53+
distribution: goreleaser
54+
version: "~> v2"
55+
args: release --snapshot
56+
57+
- name: Upload to S3
58+
if: github.actor != 'dependabot[bot]'
59+
uses: capcom6/upload-s3-action@c4fae9e0868ea2a99ef8e9318e93821e84086955 # v2.0.0
60+
env:
61+
AWS_REGION: ${{ secrets.AWS_REGION }}
62+
with:
63+
aws_key_id: ${{ secrets.AWS_KEY_ID }}
64+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
65+
aws_bucket: ${{ secrets.AWS_BUCKET }}
66+
endpoint: ${{ secrets.AWS_ENDPOINT }}
67+
source_files: |
68+
dist/${{ env.PROJECT_NAME }}_*.zip
69+
dist/${{ env.PROJECT_NAME }}_*.tar.gz
70+
destination_dir: ${{ github.repository }}/${{ github.event.pull_request.head.sha }}
71+
72+
- name: Push images
73+
if: github.actor != 'dependabot[bot]'
74+
env:
75+
DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
76+
PROJECT_NAME: ${{ env.PROJECT_NAME }}
77+
run: |
78+
docker tag ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:latest-arm64 ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}-arm64
79+
docker tag ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:latest-amd64 ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}-amd64
80+
docker push ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}-arm64
81+
docker push ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}-amd64
82+
docker manifest create ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }} \
83+
${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}-amd64 \
84+
${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}-arm64
85+
docker manifest push ${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}
86+
87+
- name: Find Comment
88+
if: github.actor != 'dependabot[bot]'
89+
uses: peter-evans/find-comment@v3
90+
id: fc
91+
with:
92+
issue-number: ${{ github.event.pull_request.number }}
93+
comment-author: "github-actions[bot]"
94+
body-includes: Pull request artifacts
95+
96+
- name: Create or update comment
97+
if: github.actor != 'dependabot[bot]'
98+
uses: peter-evans/create-or-update-comment@v4
99+
env:
100+
DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
101+
PROJECT_NAME: ${{ env.PROJECT_NAME }}
102+
with:
103+
comment-id: ${{ steps.fc.outputs.comment-id }}
104+
issue-number: ${{ github.event.pull_request.number }}
105+
body: |
106+
## 🤖 Pull request artifacts
107+
108+
| Platform | File |
109+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110+
| 🐳 Docker | [GitHub Container Registry](https://${{ env.DOCKER_REGISTRY }}/${{ env.PROJECT_NAME }}:pr-${{ github.event.pull_request.number }}) |
111+
| 🍎 Darwin arm64 | [${{ env.PROJECT_NAME }}_Darwin_arm64.tar.gz](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Darwin_arm64.tar.gz) |
112+
| 🍎 Darwin x86_64 | [${{ env.PROJECT_NAME }}_Darwin_x86_64.tar.gz](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Darwin_x86_64.tar.gz) |
113+
| 🐧 Linux arm64 | [${{ env.PROJECT_NAME }}_Linux_arm64.tar.gz](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Linux_arm64.tar.gz) |
114+
| 🐧 Linux i386 | [${{ env.PROJECT_NAME }}_Linux_i386.tar.gz](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Linux_i386.tar.gz) |
115+
| 🐧 Linux x86_64 | [${{ env.PROJECT_NAME }}_Linux_x86_64.tar.gz](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Linux_x86_64.tar.gz) |
116+
| 🪟 Windows arm64 | [${{ env.PROJECT_NAME }}_Windows_arm64.zip](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Windows_arm64.zip) |
117+
| 🪟 Windows i386 | [${{ env.PROJECT_NAME }}_Windows_i386.zip](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Windows_i386.zip) |
118+
| 🪟 Windows x86_64 | [${{ env.PROJECT_NAME }}_Windows_x86_64.zip](https://${{ secrets.AWS_BUCKET }}/${{ github.repository }}/${{ github.event.pull_request.head.sha }}/${{ env.PROJECT_NAME }}_Windows_x86_64.zip) |
119+
120+
edit-mode: replace

0 commit comments

Comments
 (0)