diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6da6892..d77e316 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: branches: [main] pull_request: +env: + GO_VERSION: "1.23.12" + GOPROXY: "https://goproxy.cn,direct" + jobs: go: name: Go (api) @@ -25,11 +29,22 @@ jobs: env: OPENGOODS_DATABASE_URL: postgres://opengoods:opengoods@postgres:5432/opengoods?sslmode=disable steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: "1.23" - cache-dependency-path: api/go.sum + - name: Checkout + working-directory: ${{ github.workspace }} + run: | + git config --global --add safe.directory '*' + git init -q . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git -c protocol.version=2 fetch -q --no-tags --depth 1 origin "${GITHUB_REF}" + git checkout -q --force FETCH_HEAD + - name: Setup Go + working-directory: ${{ github.workspace }} + run: | + curl -fsSL -o /tmp/go.tgz "https://mirrors.aliyun.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" + rm -rf /usr/local/go + tar -C /usr/local -xzf /tmp/go.tgz + echo "/usr/local/go/bin" >> "$GITHUB_PATH" + echo "$HOME/go/bin" >> "$GITHUB_PATH" - name: Apply migrations working-directory: . run: | @@ -50,7 +65,14 @@ jobs: run: working-directory: ingestion steps: - - uses: actions/checkout@v4 + - name: Checkout + working-directory: ${{ github.workspace }} + run: | + git config --global --add safe.directory '*' + git init -q . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git -c protocol.version=2 fetch -q --no-tags --depth 1 origin "${GITHUB_REF}" + git checkout -q --force FETCH_HEAD - name: Install run: pip install -e ".[dev]" - name: Ruff lint @@ -76,10 +98,21 @@ jobs: env: DBURL: postgres://opengoods:opengoods@postgres:5432/opengoods?sslmode=disable steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: "1.23" + - name: Checkout + working-directory: ${{ github.workspace }} + run: | + git config --global --add safe.directory '*' + git init -q . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git -c protocol.version=2 fetch -q --no-tags --depth 1 origin "${GITHUB_REF}" + git checkout -q --force FETCH_HEAD + - name: Setup Go + run: | + curl -fsSL -o /tmp/go.tgz "https://mirrors.aliyun.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" + rm -rf /usr/local/go + tar -C /usr/local -xzf /tmp/go.tgz + echo "/usr/local/go/bin" >> "$GITHUB_PATH" + echo "$HOME/go/bin" >> "$GITHUB_PATH" - name: Install golang-migrate run: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.18.1 - name: Migrate up