Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- "**"
tags-ignore:
- "v*"
pull_request:

jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run tests
run: make test

- name: Run go vet
run: make vet

- name: Run race tests
run: make test-race

- name: Run coverage
run: make cover

- name: Build CLI
run: make build

- name: Upload coverage profile
uses: actions/upload-artifact@v4
with:
name: coverage-profile
path: coverage.out
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
go-version-file: go.mod

- name: Run tests
run: go test ./...
run: make test

- name: Build release assets
run: |
Expand Down
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
BIN := bin/cloudcanal
GO ?= go
BIN ?= bin/cloudcanal
PKG ?= ./...
TEST_PKG ?= ./test/...
COVER_PROFILE ?= coverage.out

.PHONY: build test clean
.PHONY: build test vet test-race cover ci clean

build:
mkdir -p $(dir $(BIN))
go build -o $(BIN) ./cmd/cloudcanal
$(GO) build -o $(BIN) ./cmd/cloudcanal

test:
go test ./...
$(GO) test $(PKG)

vet:
$(GO) vet $(PKG)

test-race:
$(GO) test -race $(TEST_PKG)

cover:
$(GO) test -coverpkg=$(PKG) -coverprofile=$(COVER_PROFILE) $(TEST_PKG)
$(GO) tool cover -func=$(COVER_PROFILE)

ci: test vet test-race cover build

clean:
rm -rf $(dir $(BIN))
rm -rf $(dir $(BIN)) $(COVER_PROFILE)
5 changes: 2 additions & 3 deletions scripts/all_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ else
fi

STEP_NO="2/3"
run_step "Run tests" "test" go test ./...
run_step "Run tests" "test" make test

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

log_success "Binary ready at $BIN_PATH"
print_run_summary "Build completed"
Loading