Skip to content

Commit a5660e9

Browse files
pan93412claude
andcommitted
ci: add CI workflows, golangci-lint config, and release pipeline
- Add .golangci.yml (v2 format, standard linters + modernize + gofumpt) - Add tests.yml: lint/format check and unit tests via Nix on PRs and main - Add release.yml: build on PRs, push to Docker Hub and Huawei SWR on tag push Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a8f4807 commit a5660e9

3 files changed

Lines changed: 130 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
release:
15+
name: Build and push
16+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
27+
28+
- name: Login to Docker Hub
29+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
30+
if: github.event_name != 'pull_request'
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_TOKEN }}
34+
35+
- name: Login to Huawei SWR
36+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
37+
if: github.event_name != 'pull_request'
38+
with:
39+
registry: swr.cn-east-3.myhuaweicloud.com
40+
username: ${{ secrets.HUAWEI_SWR_USERNAME }}
41+
password: ${{ secrets.HUAWEI_SWR_TOKEN }}
42+
43+
- name: Extract version
44+
id: version
45+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
46+
47+
- name: Build
48+
run: docker buildx bake
49+
env:
50+
VERSION: ${{ steps.version.outputs.VERSION }}
51+
52+
- name: Push to Docker Hub
53+
if: github.event_name != 'pull_request'
54+
run: docker buildx bake --push
55+
env:
56+
VERSION: ${{ steps.version.outputs.VERSION }}
57+
58+
- name: Push to Huawei SWR
59+
if: github.event_name != 'pull_request'
60+
run: docker buildx bake --push
61+
env:
62+
VERSION: ${{ steps.version.outputs.VERSION }}
63+
REGISTRY: swr.cn-east-3.myhuaweicloud.com

.github/workflows/tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
id-token: write
12+
contents: read
13+
14+
concurrency:
15+
group: tests-${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
lint:
20+
name: Lint and format
21+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
27+
- name: Install Nix
28+
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0
29+
30+
- name: Set up FlakeHub cache
31+
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3.20.0
32+
33+
- name: Verify formatting
34+
run: nix develop --command golangci-lint fmt --diff
35+
36+
- name: Run golangci-lint
37+
run: nix develop --command golangci-lint run ./...
38+
39+
unit:
40+
name: Unit tests
41+
runs-on: blacksmith-2vcpu-ubuntu-2404-arm
42+
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
46+
47+
- name: Install Nix
48+
uses: DeterminateSystems/determinate-nix-action@bafaa638b9d5ec0e7e3ac1a7fc80453ef1fd265f # v3.20.0
49+
50+
- name: Set up FlakeHub cache
51+
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3.20.0
52+
53+
- name: Run unit tests
54+
run: nix develop --command go test ./...

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
6+
linters:
7+
default: standard
8+
enable:
9+
- modernize
10+
11+
formatters:
12+
enable:
13+
- gofumpt

0 commit comments

Comments
 (0)