b0b816b0ee
- migrations/0001_init: 全部核心表(product/food_detail/product_msrp/product_source/brand/manufacturer/category/category_schema/unit/attribute_definition/product_image/merge_log) + 索引(gtin唯一/name trigram/JSONB GIN/category ltree/tsvector) + tsvector/updated_at 触发器 - 0002_seed_units: 单位字典(与 units.py 一致, 含中文别名) + 常用营养参数定义 - 0003_seed_categories: 食品品类骨架(GS1 GPC 映射 + 自建中文树, ltree) + 品类参数模板(营养基准 per_100g/ml) - CI 增加 migrations job: 用 postgres service 跑 migrate up + down 验证可逆 - 本地实跑 up/down/re-up 全部通过 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
75 lines
1.9 KiB
YAML
75 lines
1.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
jobs:
|
|
go:
|
|
name: Go (api)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.23"
|
|
cache-dependency-path: api/go.sum
|
|
- name: Verify gofmt
|
|
run: test -z "$(gofmt -l .)"
|
|
- run: go vet ./...
|
|
- run: go build ./...
|
|
- run: go test ./...
|
|
|
|
python:
|
|
name: Python (ingestion)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ingestion
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Install
|
|
run: pip install -e ".[dev]"
|
|
- name: Ruff lint
|
|
run: ruff check .
|
|
- name: Ruff format check
|
|
run: ruff format --check .
|
|
- name: Pytest
|
|
run: pytest -q
|
|
|
|
migrations:
|
|
name: Migrations (postgres)
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
env:
|
|
POSTGRES_USER: opengoods
|
|
POSTGRES_PASSWORD: opengoods
|
|
POSTGRES_DB: opengoods
|
|
ports:
|
|
- "5432:5432"
|
|
options: >-
|
|
--health-cmd "pg_isready -U opengoods"
|
|
--health-interval 5s --health-timeout 5s --health-retries 10
|
|
env:
|
|
DBURL: postgres://opengoods:opengoods@localhost:5432/opengoods?sslmode=disable
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.23"
|
|
- name: Install golang-migrate
|
|
run: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.18.1
|
|
- name: Migrate up
|
|
run: migrate -path migrations -database "$DBURL" up
|
|
- name: Migrate down (reversibility)
|
|
run: migrate -path migrations -database "$DBURL" down -all
|