Skip to content
Open
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
64 changes: 54 additions & 10 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,63 @@ on:
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.17'

- name: Run Linters
run: make lint

build:
test:
name: Test (Unit + Integration)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.17'

# --- Setup Integration Test Dependencies ---
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: 'v3.11.1'

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Set up Kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.28.0'

- name: Build
run: go build -v ./...
- name: Install Kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

- name: Test
run: go test -v ./...
# --- Run Tests ---
- name: Run All Tests
run: make test

build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.17'

- name: Build
run: go build -v ./...
60 changes: 52 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
.PHONEY: build
build:
GOOS=windows GOARCH=amd64 go build -o bin/kubeslice-cli-windows-amd64.exe main.go
GOOS=linux GOARCH=amd64 go build -o bin/kubeslice-cli-linux-amd64 main.go
GOOS=linux GOARCH=arm go build -o bin/kubeslice-cli-linux-arm main.go
GOOS=linux GOARCH=arm64 go build -o bin/kubeslice-cli-linux-arm64 main.go
GOOS=darwin GOARCH=amd64 go build -o bin/kubeslice-cli-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 go build -o bin/kubeslice-cli-darwin-arm64 main.go
GO_VERSION := 1.17

.PHONY: all build clean test test-unit test-integration lint tidy

all: build

# test-unit: Runs all unit tests.
# Uses -short to skip long-running tests.
test-unit:
@echo "Running unit tests..."
@go test -v -race -short -cover ./...

# test-integration: Runs only integration tests.
# Requires the 'integration' build tag.
test-integration:
@echo "Running integration tests..."
@go test -v -race -cover -tags=integration -run Integration ./...

# test: Runs All tests
test:
@echo "Running all tests..."
@make test-unit
@make test-integration

build: tidy
@echo "Building binaries for all platforms..."
@GOOS=windows GOARCH=amd64 go build -o bin/kubeslice-cli-windows-amd64.exe main.go
@GOOS=linux GOARCH=amd64 go build -o bin/kubeslice-cli-linux-amd64 main.go
@GOOS=linux GOARCH=arm go build -o bin/kubeslice-cli-linux-arm main.go
@GOOS=linux GOARCH=arm64 go build -o bin/kubeslice-cli-linux-arm64 main.go
@GOOS=darwin GOARCH=amd64 go build -o bin/kubeslice-cli-darwin-amd64 main.go
@GOOS=darwin GOARCH=arm64 go build -o bin/kubeslice-cli-darwin-arm64 main.go
@echo "Build complete."

lint:
@echo "Running linter..."
@if [ "$$(gofmt -l . | wc -l)" -gt 0 ]; then \
echo "Go files are not formatted. Please run 'gofmt -w .'"; \
gofmt -l .; \
exit 1; \
fi
@go vet ./...
@echo "Linting passed!"

tidy:
@echo "Running go mod tidy..."
@go mod tidy

clean:
@echo "Cleaning up..."
@rm -f bin/kubeslice-cli-*
@rm -rf bin
2 changes: 1 addition & 1 deletion util/file-generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ func DumpFile(template, filename string) {
if err2 != nil {
Fatalf("%s Failed to write %s", Cross, filename)
}
}
}