Clone the repo in CI without GitHub-hosted actions
Why: The runner cannot reach github.com, so cloning actions/checkout timed out before any test ran. Evidence: mirrors.aliyun.com/golang/go1.27.1.linux-amd64.tar.gz returned HTTP 200. The workflow now fetches GITHUB_SHA with the job token and installs Go from that mirror. Impact: Submodule checkout still requires SUBMODULE_TOKEN. A missing secret fails the job with that message. Refs: feature/agent-stack-r0-r1 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+33
-10
@@ -10,14 +10,29 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GOPROXY: https://goproxy.cn,direct
|
GOPROXY: https://goproxy.cn,direct
|
||||||
steps:
|
steps:
|
||||||
- name: Configure submodule auth over HTTPS
|
- name: Checkout
|
||||||
run: git config --global url."https://weichen:${{ secrets.SUBMODULE_TOKEN }}@git-home.u1680832.nyat.app:30319/".insteadOf "ssh://git@git-ssh.u1680832.nyat.app:31411/"
|
env:
|
||||||
- uses: actions/checkout@v4
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
SUBMODULE_TOKEN: ${{ secrets.SUBMODULE_TOKEN }}
|
||||||
submodules: recursive
|
run: |
|
||||||
- uses: actions/setup-go@v5
|
set -euo pipefail
|
||||||
with:
|
git init -q
|
||||||
go-version: "1.27"
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||||
|
git -c http.extraheader="AUTHORIZATION: token ${TOKEN}" fetch --depth=1 origin "${GITHUB_SHA}"
|
||||||
|
git checkout -q --detach FETCH_HEAD
|
||||||
|
if [ -z "${SUBMODULE_TOKEN}" ]; then
|
||||||
|
echo "SUBMODULE_TOKEN is not configured" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git config --global url."https://weichen:${SUBMODULE_TOKEN}@git-home.u1680832.nyat.app:30319/".insteadOf "ssh://git@git-ssh.u1680832.nyat.app:31411/"
|
||||||
|
git -c fetch.recurseSubmodules=false submodule update --init --recursive
|
||||||
|
- name: Install Go 1.27.1
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
curl -fsSL -o "$RUNNER_TEMP/go.tgz" https://mirrors.aliyun.com/golang/go1.27.1.linux-amd64.tar.gz
|
||||||
|
tar -C /usr/local -xzf "$RUNNER_TEMP/go.tgz"
|
||||||
|
ln -sfn /usr/local/go/bin/go /usr/local/bin/go
|
||||||
|
ln -sfn /usr/local/go/bin/gofmt /usr/local/bin/gofmt
|
||||||
- name: Vet, test, and race
|
- name: Vet, test, and race
|
||||||
run: GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./... && GOWORK=off go test -count=1 -race ./...
|
run: GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./... && GOWORK=off go test -count=1 -race ./...
|
||||||
docker-checkout-hostgateway:
|
docker-checkout-hostgateway:
|
||||||
@@ -26,5 +41,13 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_SERVER_URL: http://gitea:3000
|
GITHUB_SERVER_URL: http://gitea:3000
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout without GitHub actions
|
||||||
- run: test -f go.mod && echo "docker-mode checkout via host-gateway OK"
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
git init -q
|
||||||
|
git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||||
|
git -c http.extraheader="AUTHORIZATION: token ${TOKEN}" fetch --depth=1 origin "${GITHUB_SHA}"
|
||||||
|
git checkout -q --detach FETCH_HEAD
|
||||||
|
test -f go.mod && echo "docker-mode checkout via host-gateway OK"
|
||||||
|
|||||||
Reference in New Issue
Block a user