From 39ff086236184147a0b58ff4b825c02ad4abcf00 Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 12 Jun 2026 17:00:09 +0800 Subject: [PATCH] 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. --- .gitea/workflows/ci.yml | 64 +++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index f7c25f4..725869a 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -10,25 +10,26 @@ on: permissions: contents: read -env: - GO_MIRROR: https://mirrors.aliyun.com/golang - GOPROXY: https://goproxy.cn,direct - jobs: - lint: - name: Lint + test: + name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Go + - 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}') - curl -sL "${GO_MIRROR}/go${GO_VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzf - - echo "/usr/local/go/bin" >> $GITHUB_PATH + 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 - - name: Check formatting - run: | + echo "=== Go Version ===" + go version + + echo "=== Check Formatting ===" go install mvdan.cc/gofumpt@latest output=$(gofumpt -l .) if [ -n "$output" ]; then @@ -36,45 +37,32 @@ jobs: echo "$output" exit 1 fi + echo "Formatting OK" - - name: Run vet - run: | - which go - go version + echo "=== Go Vet ===" go vet ./... + echo "Vet OK" - 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/... + echo "=== Unit Tests ===" + go test -race -count=1 ./internal/... build: name: Build - needs: [lint, test] + needs: [test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install Go + - name: Install Go and build run: | + export PATH="/usr/local/go/bin:$PATH" 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 + 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 - - name: Build - run: make build - - - name: Verify binary - run: ./bin/lolly --help + make build + ./bin/lolly --help