xfy 000a6afc08
Some checks failed
CI / Lint (push) Failing after 3m44s
CI / Test (push) Failing after 3m42s
CI / Build (push) Has been skipped
ci: use Aliyun Go mirror and goproxy.cn for China network
go.dev/dl redirects to dl.google.com which is blocked in China.
Use mirrors.aliyun.com for Go toolchain download and goproxy.cn
for Go module proxy.
2026-06-12 16:23:00 +08:00

81 lines
1.9 KiB
YAML

name: CI
on:
push:
branches: [master]
tags: ["v*"]
pull_request:
branches: [master]
permissions:
contents: read
env:
GO_MIRROR: https://mirrors.aliyun.com/golang
GOPROXY: https://goproxy.cn,direct
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Go
run: |
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
curl -sL "${GO_MIRROR}/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf -
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Check formatting
run: |
go install mvdan.cc/gofumpt@latest
output=$(gofumpt -l .)
if [ -n "$output" ]; then
echo "Files need formatting:"
echo "$output"
exit 1
fi
- name: Run lint
run: |
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
golangci-lint run ./...
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Go
run: |
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
curl -sL "${GO_MIRROR}/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf -
echo "/usr/local/go/bin" >> $GITHUB_PATH
- name: Run unit tests
run: go test -race -count=1 ./internal/...
build:
name: Build
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
run: |
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
curl -sL "${GO_MIRROR}/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf -
echo "/usr/local/go/bin" >> $GITHUB_PATH
- name: Build
run: make build
- name: Verify binary
run: ./bin/lolly --help