name: CI on: push: branches: [master] tags: ["v*"] pull_request: branches: [master] permissions: contents: read jobs: test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Go and run checks run: | export PATH="/usr/local/go/bin:$(go env GOPATH 2>/dev/null || echo /root/go)/bin:$PATH" GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') if ! command -v go &>/dev/null; then curl -sL "https://mirrors.aliyun.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - fi export GOPROXY=https://goproxy.cn,direct echo "=== Go Version ===" go version echo "=== Check Formatting ===" go install mvdan.cc/gofumpt@latest output=$(gofumpt -l .) if [ -n "$output" ]; then echo "Files need formatting:" echo "$output" exit 1 fi echo "Formatting OK" echo "=== Go Vet ===" go vet ./... echo "Vet OK" echo "=== Unit Tests ===" go test -race -count=1 ./internal/... build: name: Build needs: [test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Go and build run: | export PATH="/usr/local/go/bin:$PATH" GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') if ! command -v go &>/dev/null; then curl -sL "https://mirrors.aliyun.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - fi export GOPROXY=https://goproxy.cn,direct make build ./bin/lolly --help