ci: consolidate all steps into single step per job
GITHUB_PATH does not reliably update PATH for subsequent steps in Gitea Actions. Put Go install + all checks in one step with explicit PATH export. Simplify to 2 jobs: test + build.
This commit is contained in:
parent
c2fe40330b
commit
39ff086236
@ -10,25 +10,26 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
env:
|
|
||||||
GO_MIRROR: https://mirrors.aliyun.com/golang
|
|
||||||
GOPROXY: https://goproxy.cn,direct
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
test:
|
||||||
name: Lint
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go and run checks
|
||||||
run: |
|
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}')
|
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 -
|
if ! command -v go &>/dev/null; then
|
||||||
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
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
|
||||||
|
|
||||||
- name: Check formatting
|
echo "=== Go Version ==="
|
||||||
run: |
|
go version
|
||||||
|
|
||||||
|
echo "=== Check Formatting ==="
|
||||||
go install mvdan.cc/gofumpt@latest
|
go install mvdan.cc/gofumpt@latest
|
||||||
output=$(gofumpt -l .)
|
output=$(gofumpt -l .)
|
||||||
if [ -n "$output" ]; then
|
if [ -n "$output" ]; then
|
||||||
@ -36,45 +37,32 @@ jobs:
|
|||||||
echo "$output"
|
echo "$output"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "Formatting OK"
|
||||||
|
|
||||||
- name: Run vet
|
echo "=== Go Vet ==="
|
||||||
run: |
|
|
||||||
which go
|
|
||||||
go version
|
|
||||||
go vet ./...
|
go vet ./...
|
||||||
|
echo "Vet OK"
|
||||||
|
|
||||||
test:
|
echo "=== Unit Tests ==="
|
||||||
name: Test
|
go test -race -count=1 ./internal/...
|
||||||
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:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
needs: [lint, test]
|
needs: [test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go and build
|
||||||
run: |
|
run: |
|
||||||
|
export PATH="/usr/local/go/bin:$PATH"
|
||||||
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
|
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 -
|
if ! command -v go &>/dev/null; then
|
||||||
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
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
|
||||||
|
|
||||||
- name: Build
|
make build
|
||||||
run: make build
|
./bin/lolly --help
|
||||||
|
|
||||||
- name: Verify binary
|
|
||||||
run: ./bin/lolly --help
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user