Skip to content

Commit 42262da

Browse files
committed
add ci and unify build entrypoints
1 parent bf98edc commit 42262da

File tree

4 files changed

+66
-9
lines changed

4 files changed

+66
-9
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
tags-ignore:
8+
- "v*"
9+
pull_request:
10+
11+
jobs:
12+
verify:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- name: Run tests
24+
run: make test
25+
26+
- name: Run go vet
27+
run: make vet
28+
29+
- name: Run race tests
30+
run: make test-race
31+
32+
- name: Run coverage
33+
run: make cover
34+
35+
- name: Build CLI
36+
run: make build
37+
38+
- name: Upload coverage profile
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: coverage-profile
42+
path: coverage.out

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
go-version-file: go.mod
2222

2323
- name: Run tests
24-
run: go test ./...
24+
run: make test
2525

2626
- name: Build release assets
2727
run: |

Makefile

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1-
BIN := bin/cloudcanal
1+
GO ?= go
2+
BIN ?= bin/cloudcanal
3+
PKG ?= ./...
4+
TEST_PKG ?= ./test/...
5+
COVER_PROFILE ?= coverage.out
26

3-
.PHONY: build test clean
7+
.PHONY: build test vet test-race cover ci clean
48

59
build:
610
mkdir -p $(dir $(BIN))
7-
go build -o $(BIN) ./cmd/cloudcanal
11+
$(GO) build -o $(BIN) ./cmd/cloudcanal
812

913
test:
10-
go test ./...
14+
$(GO) test $(PKG)
15+
16+
vet:
17+
$(GO) vet $(PKG)
18+
19+
test-race:
20+
$(GO) test -race $(TEST_PKG)
21+
22+
cover:
23+
$(GO) test -coverpkg=$(PKG) -coverprofile=$(COVER_PROFILE) $(TEST_PKG)
24+
$(GO) tool cover -func=$(COVER_PROFILE)
25+
26+
ci: test vet test-race cover build
1127

1228
clean:
13-
rm -rf $(dir $(BIN))
29+
rm -rf $(dir $(BIN)) $(COVER_PROFILE)

scripts/all_build.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@ else
5353
fi
5454

5555
STEP_NO="2/3"
56-
run_step "Run tests" "test" go test ./...
56+
run_step "Run tests" "test" make test
5757

5858
STEP_NO="3/3"
59-
mkdir -p "$BIN_DIR"
60-
run_step "Build CLI" "build" go build -o "$BIN_PATH" ./cmd/cloudcanal
59+
run_step "Build CLI" "build" make build
6160

6261
log_success "Binary ready at $BIN_PATH"
6362
print_run_summary "Build completed"

0 commit comments

Comments
 (0)