mirror of
https://github.com/vxcontrol/cloud.git
synced 2026-07-20 23:46:09 -04:00
99 lines
2.4 KiB
YAML
99 lines
2.4 KiB
YAML
name: Go SDK CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "**"
|
|
tags:
|
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test:
|
|
name: Test and Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
cache: true
|
|
cache-dependency-path: go.sum
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Verify dependencies
|
|
run: go mod verify
|
|
|
|
- name: Format check
|
|
run: |
|
|
gofmt -s -l . | tee /tmp/gofmt.out
|
|
test ! -s /tmp/gofmt.out
|
|
|
|
- name: Go vet
|
|
run: go vet ./...
|
|
|
|
- name: Lint
|
|
uses: golangci/golangci-lint-action@v4
|
|
with:
|
|
version: latest
|
|
args: --timeout=5m
|
|
continue-on-error: true
|
|
|
|
- name: Unit tests
|
|
run: go test ./... -v -race -coverprofile=coverage.out
|
|
|
|
- name: Test examples
|
|
run: |
|
|
echo "Testing examples build..."
|
|
cd examples/check-update && go build .
|
|
cd ../download-installer && go build .
|
|
cd ../report-errors && go build .
|
|
echo "✓ All examples build successfully"
|
|
|
|
- name: Cross-platform build test
|
|
env:
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
echo "Testing cross-platform builds..."
|
|
# Test key platforms
|
|
GOOS=linux GOARCH=amd64 go build ./...
|
|
GOOS=linux GOARCH=arm64 go build ./...
|
|
GOOS=darwin GOARCH=amd64 go build ./...
|
|
GOOS=darwin GOARCH=arm64 go build ./...
|
|
GOOS=windows GOARCH=amd64 go build ./...
|
|
echo "✓ Cross-platform builds successful"
|
|
|
|
- name: Security scan
|
|
run: |
|
|
echo "Running security checks..."
|
|
go install golang.org/x/vuln/cmd/govulncheck@latest
|
|
govulncheck ./...
|
|
echo "✓ Security scan completed"
|
|
continue-on-error: true
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
file: ./coverage.out
|
|
fail_ci_if_error: false
|