Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 40 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
description: 'Enable debug mode'
required: false
default: false
full_run:
type: boolean
description: 'Run all heavy jobs on manual dispatch'
required: false
default: false

permissions:
contents: read
Expand All @@ -22,7 +27,7 @@ env:
RUST_VERSION: '1.89.0'

concurrency:
group: core-ci-${{ github.ref }}
group: core-ci-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
Expand All @@ -31,6 +36,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
docs_only: ${{ steps.out.outputs.docs_only }}
flutter_changed: ${{ steps.out.outputs.flutter_changed }}
steps:
- uses: actions/checkout@v4
- name: Paths filter
Expand All @@ -48,6 +54,9 @@ jobs:
- 'PR_DESCRIPTIONS/**'
code:
- '!**/*.md'
flutter:
- 'jive-flutter/**'
- 'jive-flutter/pubspec.yaml'
- name: Set outputs
id: out
run: |
Expand All @@ -56,6 +65,7 @@ jobs:
else
echo "docs_only=false" >> "$GITHUB_OUTPUT"
fi
echo "flutter_changed=${{ steps.filter.outputs.flutter }}" >> "$GITHUB_OUTPUT"
rustfmt-check:
name: Rustfmt Check
runs-on: ubuntu-latest
Expand All @@ -73,13 +83,13 @@ jobs:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
- name: Check formatting (jive-api)
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-api
run: |
cargo fmt --all -- --check

- name: Check formatting (jive-core)
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-core
run: |
cargo fmt --all -- --check
Expand All @@ -96,13 +106,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install cargo-deny
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
run: |
curl -sSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.14.24/cargo-deny-0.14.24-x86_64-unknown-linux-musl.tar.gz | tar xz
sudo mv cargo-deny*/cargo-deny /usr/local/bin/cargo-deny
cargo-deny --version
- name: Run cargo-deny (API)
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-api
run: |
set -o pipefail
Expand All @@ -122,19 +132,25 @@ jobs:
needs: [changes]
env:
DOCS_ONLY: ${{ needs.changes.outputs.docs_only }}
FLUTTER_CHANGED: ${{ needs.changes.outputs.flutter_changed }}

steps:
- uses: actions/checkout@v4

- name: No Flutter changes detected (short-circuit)
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED != 'true'
run: |
echo "No Flutter changes; skipping analysis/tests to keep pipeline efficient."

- name: Setup Flutter
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED == 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'

- name: Cache Flutter dependencies
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED == 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
uses: actions/cache@v4
with:
path: |
Expand All @@ -146,33 +162,33 @@ jobs:
${{ runner.os }}-flutter-

- name: Install dependencies
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED == 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-flutter
run: flutter pub get

- name: Generate code (build_runner)
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED == 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-flutter
run: |
flutter pub run build_runner build --delete-conflicting-outputs || true

- name: Analyze code (non-fatal for now)
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED == 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-flutter
run: |
set -o pipefail
# Temporarily non-fatal due to high analyzer warnings; see CI_TEST_RESULT_REPORT.md
flutter analyze --no-fatal-warnings 2>&1 | tee ../flutter-analyze-output.txt || true

- name: Upload analyzer output
if: always()
if: always() && env.FLUTTER_CHANGED == 'true'
uses: actions/upload-artifact@v4
with:
name: flutter-analyze-output
path: flutter-analyze-output.txt

- name: Run tests
if: env.DOCS_ONLY != 'true'
if: env.DOCS_ONLY != 'true' && env.FLUTTER_CHANGED == 'true' && (github.event_name != 'workflow_dispatch' || inputs.full_run == 'true')
working-directory: jive-flutter
run: |
# Generate machine-readable test results (non-fatal for reporting)
Expand All @@ -185,15 +201,15 @@ jobs:
flutter test test/settings_manual_overrides_navigation_test.dart --machine > ../flutter-widget-manual-overrides.json || true

- name: Upload manual-overrides widget test output
if: always()
if: always() && env.FLUTTER_CHANGED == 'true'
uses: actions/upload-artifact@v4
with:
name: flutter-manual-overrides-widget
path: flutter-widget-manual-overrides.json
if-no-files-found: ignore

- name: Generate test report
if: always()
if: always() && env.FLUTTER_CHANGED == 'true'
working-directory: jive-flutter
run: |
echo "# Flutter Test Report" > ../test-report.md
Expand All @@ -217,7 +233,7 @@ jobs:
fi

- name: Upload test report
if: always()
if: always() && env.FLUTTER_CHANGED == 'true'
uses: actions/upload-artifact@v4
with:
name: test-report
Expand Down Expand Up @@ -538,7 +554,10 @@ jobs:
name: Field Comparison Check
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [flutter-test, rust-test]
needs: [changes, flutter-test, rust-test]
if: needs.changes.outputs.flutter_changed == 'true'
env:
FLUTTER_CHANGED: ${{ needs.changes.outputs.flutter_changed }}

steps:
- uses: actions/checkout@v4
Expand All @@ -548,15 +567,17 @@ jobs:
with:
name: test-report
path: .
if-no-files-found: ignore

- name: Download Flutter analyzer output
uses: actions/download-artifact@v4
with:
name: flutter-analyze-output
path: .
if-no-files-found: ignore

- name: Upload analyzer output for comparison
if: always()
if: always() && env.FLUTTER_CHANGED == 'true'
uses: actions/upload-artifact@v4
with:
name: flutter-analyze-output-comparison
Expand All @@ -568,6 +589,7 @@ jobs:
sudo apt-get install -y jq

- name: Compare Flutter and Rust fields
if: env.FLUTTER_CHANGED == 'true'
run: |
echo "# Field Comparison Report" > field-compare-report.md
echo "## Flutter vs Rust Model Comparison" >> field-compare-report.md
Expand Down Expand Up @@ -606,7 +628,7 @@ jobs:
fi

- name: Upload field comparison report
if: always()
if: always() && env.FLUTTER_CHANGED == 'true'
uses: actions/upload-artifact@v4
with:
name: field-compare-report
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Cargo.lock
# 日志文件
*.log
logs/
/.pids/
*.pid
*.seed
*.pid.lock
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ api-safe:
@echo "启动完整版 API (安全 CORS 模式, 端口 $${API_PORT:-8012})..."
@cd jive-api && unset CORS_DEV && API_PORT=$${API_PORT:-8012} cargo run --bin jive-api

# Enable local git hooks to run pre-commit (api-lint)
.PHONY: hooks
hooks:
@git config core.hooksPath .githooks
@echo "Git hooks enabled (pre-commit will run make api-lint)"
Comment on lines +163 to +166

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change introduces a hooks target that duplicates an existing one on lines 148-150. Having duplicate targets in a Makefile can lead to unpredictable behavior and makes the file harder to maintain.

Please remove this duplicated block. You can enhance the existing target by adding .PHONY: hooks above it for correctness, like so:

.PHONY: hooks
hooks:
	@git config core.hooksPath .githooks
	@echo "✅ Git hooks enabled (pre-commit runs make api-lint)"


# 代码格式化
format:
@echo "格式化 Rust 代码..."
Expand Down
6 changes: 3 additions & 3 deletions jive-api/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
POSTGRES_DB: jive_money
POSTGRES_HOST_AUTH_METHOD: md5
ports:
- "15432:5432" # 修改为15432避免与本地5433冲突
- "5433:5432" # 对齐本地开发默认端口 5433(jive-manager)
volumes:
- postgres_dev_data:/var/lib/postgresql/data
- ./migrations:/docker-entrypoint-initdb.d:ro
Expand All @@ -28,7 +28,7 @@ services:
container_name: jive-redis-dev
restart: unless-stopped
ports:
- "16379:6379" # 修改为16379避免与本地6380冲突
- "6380:6379" # 对齐本地开发默认端口 6380(jive-manager)
volumes:
- redis_dev_data:/data
networks:
Expand Down Expand Up @@ -69,7 +69,7 @@ services:
container_name: jive-adminer-dev
restart: unless-stopped
ports:
- "19080:8080" # 修改为19080避免与本地8080冲突
- "9080:8080" # 对齐管理脚本使用的 Adminer 端口 9080
environment:
ADMINER_DEFAULT_SERVER: postgres
ADMINER_DESIGN: pepa-linha
Expand Down