Skip to content

Commit 23edbc3

Browse files
authored
chore: CI improvements (#88)
* Updated test pipeline * Updated build pipeline to run on v2 branch * Added buf, linter update & fixed proto gen
1 parent 7c33583 commit 23edbc3

38 files changed

+2474
-2342
lines changed

.github/workflows/build-image.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- '*.md'
1212
branches:
1313
- main
14+
- v2
1415
push:
1516
paths-ignore:
1617
- '.run/**'
@@ -20,6 +21,7 @@ on:
2021
- '*.md'
2122
branches:
2223
- main
24+
- v2
2325

2426
jobs:
2527
build:

.github/workflows/lint.yaml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- v2
78
paths-ignore:
89
- '.run/**'
910
- 'docs/**'
@@ -13,6 +14,7 @@ on:
1314
pull_request:
1415
branches:
1516
- main
17+
- v2
1618
types: [ opened, synchronize ]
1719
paths-ignore:
1820
- '.run/**'
@@ -22,18 +24,33 @@ on:
2224

2325
jobs:
2426
lint:
25-
name: "Run linter"
27+
name: Lint Go code
2628
runs-on: ubuntu-latest
29+
2730
steps:
28-
- name: Checkout
31+
- name: Checkout code
2932
uses: actions/checkout@v4
3033

31-
- name: Setup Go
32-
uses: actions/setup-go@v5
34+
- uses: actions/setup-go@v5
3335
with:
34-
go-version: 1.21.1
36+
go-version: 1.23.0
3537

3638
- name: golangci-lint
3739
uses: golangci/golangci-lint-action@v6
3840
with:
39-
version: latest
41+
version: v1.62.0
42+
args: --timeout=3m
43+
44+
buf:
45+
name: Run buf
46+
runs-on: ubuntu-latest
47+
permissions:
48+
contents: read
49+
pull-requests: write
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
53+
54+
- uses: bufbuild/buf-action@v1
55+
with:
56+
github_token: ${{ github.token }}

.github/workflows/test.yaml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- v2
78
paths-ignore:
89
- '.run/**'
910
- 'docs/**'
@@ -14,6 +15,7 @@ on:
1415
pull_request:
1516
branches:
1617
- main
18+
- v2
1719
types: [ opened, synchronize ]
1820
paths-ignore:
1921
- '.run/**'
@@ -23,21 +25,38 @@ on:
2325
- '*.md'
2426

2527
jobs:
26-
test:
28+
# Run unit tests
29+
unit:
2730
name: "Run unit tests"
2831
runs-on: ubuntu-latest
29-
3032
steps:
31-
- name: Checkout code
33+
- name: Checkout
3234
uses: actions/checkout@v4
3335

34-
- name: Set up Go
36+
- name: Setup Go
3537
uses: actions/setup-go@v5
3638
with:
37-
go-version: "^1.21.1"
39+
go-version: 1.23.0
40+
41+
# todo skip mocks coverage
42+
- name: Install dependencies and run tests
43+
run: |
44+
go mod download
45+
go test -v ./... -coverpkg=./... -short -coverprofile=unit_coverage.out
46+
47+
integration:
48+
name: "Run integration tests"
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
3853

39-
- name: Install dependencies
40-
run: go mod download
54+
- name: Setup Go
55+
uses: actions/setup-go@v5
56+
with:
57+
go-version: 1.23.0
4158

42-
- name: Test
43-
run: go test --short -v ./...
59+
- name: Install dependencies and run tests
60+
run: |
61+
go mod download
62+
go test -v -run 'Integration$' ./... -coverpkg=./... -coverprofile=integration_coverage.out

buf.gen.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: v2
2+
managed:
3+
disable:
4+
# Don't modify any file option or field option for googleapis
5+
- module: buf.build/googleapis/googleapis
6+
enabled: true
7+
override:
8+
- file_option: go_package_prefix
9+
value: github.com/ChargePi/ChargePi-go/gen/proto
10+
11+
inputs:
12+
- directory: ./proto
13+
plugins:
14+
#- remote: buf.build/protocolbuffers/go:v1.31.0
15+
- local: protoc-gen-go
16+
out: gen/proto
17+
opt:
18+
- paths=source_relative
19+
#- remote: buf.build/grpc/go:v1.5.1
20+
- local: protoc-gen-go-grpc
21+
out: gen/proto
22+
opt:
23+
- paths=source_relative
24+

buf.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: v2
2+
modules:
3+
- path: proto
4+
lint:
5+
use:
6+
- STANDARD
7+
- FILE_LOWER_SNAKE_CASE
8+
- PACKAGE_NO_IMPORT_CYCLE
9+
- PACKAGE_SAME_GO_PACKAGE
10+
- FIELD_LOWER_SNAKE_CASE
11+
- ENUM_VALUE_UPPER_SNAKE_CASE
12+
- PACKAGE_LOWER_SNAKE_CASE
13+
except:
14+
- FIELD_NOT_REQUIRED
15+
enum_zero_value_suffix: _UNSPECIFIED
16+
rpc_allow_same_request_response: false
17+
rpc_allow_google_protobuf_empty_requests: true
18+
rpc_allow_google_protobuf_empty_responses: true
19+
service_suffix: Service

0 commit comments

Comments
 (0)