Repository navigation
86 lines (69 loc) · 2.9 KB
/
Copy pathci.yml
File metadata and controls
86 lines (69 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: CI
on:
push:
branches: [main, develop]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
env:
# 必须与 .fvmrc 和 pubspec.yaml 的 Flutter 约束保持一致
FLUTTER_VERSION: 3.38.10
# 三份 pubspec.lock 都记录此镜像;源地址不同也会导致严格锁定校验失败。
PUB_HOSTED_URL: https://pub.flutter-io.cn
jobs:
quality:
name: 格式、静态分析与生成一致性
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
pub-cache-key: "flutter-pub-:os:-:version:-:arch:-${{ hashFiles('pubspec.lock', 'tools/source_probe/pubspec.lock', 'tool/db_codegen/pubspec.lock') }}"
- name: 安装依赖
run: flutter pub get --enforce-lockfile
# 根目录 analyze 会扫描嵌套包,必须先生成调查包自己的 package_config。
- name: 安装调查包依赖
working-directory: tools/source_probe
run: dart pub get --enforce-lockfile
- name: 安装数据库生成器依赖
working-directory: tool/db_codegen
run: dart pub get --enforce-lockfile
- name: 检查工作流与锁文件
run: |
dart tool/check_ci_yaml.dart
git diff --exit-code -- pubspec.lock tools/source_probe/pubspec.lock tool/db_codegen/pubspec.lock
- name: 检查数据库生成代码
run: |
bash tool/generate_database.sh
git diff --exit-code -- tool/db_codegen/pubspec.lock lib/data/local/database
test -z "$(git ls-files --others --exclude-standard lib/data/local/database)"
- name: 检查本地化生成代码
run: |
flutter gen-l10n
git diff --exit-code -- lib/l10n/generated
test -z "$(git ls-files --others --exclude-standard lib/l10n/generated)"
- name: 格式检查
run: dart format --output=none --set-exit-if-changed lib test
- name: 静态分析
run: flutter analyze --no-pub
- name: 调查包格式检查
working-directory: tools/source_probe
run: dart format --output=none --set-exit-if-changed bin lib test
- name: 调查包静态分析
working-directory: tools/source_probe
run: dart --suppress-analytics analyze
- name: 调查样本离线校验
working-directory: tools/source_probe
# 先输出预检报告,避免样本损坏只表现为多项测试的连带失败。
# 默认不请求源站,不传 --live。
run: dart bin/source_probe.dart