Skip to content

fix(errand): 需求并发校验时间戳改为详情接口现取 (#96) #302

fix(errand): 需求并发校验时间戳改为详情接口现取 (#96)

fix(errand): 需求并发校验时间戳改为详情接口现取 (#96) #302

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
checks: write
pull-requests: write
env:
GO_VERSION: "1.26"
jobs:
changes:
name: Detect changed modules
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.filter.outputs.modules }}
steps:
- uses: actions/checkout@v6
- name: Determine changed modules
id: filter
run: |
# On push to main, compare against the previous commit.
# On pull_request, compare against the base branch.
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE=${{ github.event.pull_request.base.sha }}
else
BASE=${{ github.event.before }}
fi
ALL_MODULES='["internal/pkg","internal/service/userservice","internal/service/catalogservice","internal/service/paymentservice","internal/service/spotservice","internal/service/errandservice"]'
# Fall back to running everything when BASE is unknown or unreachable
# (first push, force-push that rewrote history, shallow clone missing the object).
if [ "$BASE" = "0000000000000000000000000000000000000000" ] || [ -z "$BASE" ]; then
echo "modules=$ALL_MODULES" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! git cat-file -e "$BASE^{commit}" 2>/dev/null; then
echo "modules=$ALL_MODULES" >> "$GITHUB_OUTPUT"
exit 0
fi
CHANGED=$(git diff --name-only "$BASE" HEAD)
PKG_CHANGED=false
MODULES='[]'
# Check if shared lib changed — if so, all modules must run.
if echo "$CHANGED" | grep -qE '^internal/pkg/|^\.golangci\.yml|^go\.work|^proto/|^buf\.gen\.yaml|^buf\.lock|^buf\.yaml'; then
PKG_CHANGED=true
fi
# Also run everything when CI config itself changes.
if echo "$CHANGED" | grep -qE '^\.github/workflows/ci\.yml'; then
PKG_CHANGED=true
fi
if [ "$PKG_CHANGED" = "true" ]; then
echo "modules=$ALL_MODULES" >> "$GITHUB_OUTPUT"
exit 0
fi
# Otherwise collect only the services that changed, always including pkg.
RESULT='["internal/pkg"'
for SVC in userservice catalogservice paymentservice spotservice errandservice; do
if echo "$CHANGED" | grep -qE "^internal/service/$SVC/"; then
RESULT="$RESULT,\"internal/service/$SVC\""
fi
done
RESULT="$RESULT]"
# If nothing service-specific changed (e.g. only proto/docs), still run pkg.
echo "modules=$RESULT" >> "$GITHUB_OUTPUT"
lint:
name: Lint (${{ matrix.module }})
needs: changes
if: ${{ needs.changes.outputs.modules != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.changes.outputs.modules) }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: |
internal/pkg/go.sum
internal/service/userservice/go.sum
internal/service/catalogservice/go.sum
internal/service/paymentservice/go.sum
internal/service/spotservice/go.sum
internal/service/errandservice/go.sum
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Generate proto
run: make proto
- name: Lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.12.2
working-directory: ${{ matrix.module }}
build:
name: Build (${{ matrix.module }})
needs: changes
if: ${{ needs.changes.outputs.modules != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.changes.outputs.modules) }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: ${{ matrix.module }}/go.sum
- uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ github.token }}
- name: Generate proto
run: make proto
- name: Build
working-directory: ${{ matrix.module }}
run: go build ./...
# TODO: uncomment after tests are added
# - name: Test
# working-directory: ${{ matrix.module }}
# run: go test -race -count=1 ./...
# For integration tests (PostgreSQL/Redis), consider testcontainers-go