forked from a2ui-project/a2ui
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (115 loc) · 4.25 KB
/
Copy pathflutter_packages_test.yaml
File metadata and controls
126 lines (115 loc) · 4.25 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Flutter CI, except 'e2e_test'
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 * * * *" # hourly
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
flutter_version: ${{ steps.generate_matrix.outputs.flutter_version }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Generate testing matrix
id: generate_matrix
run: |
DIRS_TO_TEST=$(find samples -name pubspec.yaml -not -path "*/.dart_tool/*" -not -path "*/e2e_test/*" -exec dirname {} \;)
JSON_MATRIX="["
FIRST=true
for dir in $DIRS_TO_TEST; do
if [ "$FIRST" = false ]; then
JSON_MATRIX="$JSON_MATRIX,"
fi
FIRST=false
package_name=$(echo "$dir" | tr '/' '_')
package_path="$dir"
JSON_MATRIX="$JSON_MATRIX{\"name\":\"$package_name\",\"path\":\"$package_path\"}"
done
JSON_MATRIX="$JSON_MATRIX]"
echo "matrix=$JSON_MATRIX" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo 'flutter_version=["stable"]' >> $GITHUB_OUTPUT
else
echo 'flutter_version=["beta", "stable"]' >> $GITHUB_OUTPUT
fi
cycle-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- uses: ./.github/actions/setup-dart
- name: Check for cycles across packages
run: |
dart pub global activate layerlens
DIRS=$(find samples -name pubspec.yaml -not -path "*/.dart_tool/*" -not -path "*/e2e_test/*" -exec dirname {} \;)
for dir in $DIRS; do
echo "Checking cycles in $dir..."
(cd "$dir" && dart pub get && layerlens --fail-on-cycles --except "lib/src/schema" --except "lib/src/core")
done
analyze_and_test:
needs: matrix
name: ${{ matrix.package.name }} (${{ matrix.flutter_version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.matrix.outputs.matrix) }}
flutter_version: ${{ fromJson(needs.matrix.outputs.flutter_version) }}
os: [ubuntu-latest]
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- uses: ./.github/actions/setup-dart
with:
channel: ${{ matrix.flutter_version }}
- name: Print Flutter version
run: flutter --version
- name: Update submodules
working-directory: ${{ matrix.package.path }}
run: git submodule update --init --recursive
- name: Install dependencies
working-directory: ${{ matrix.package.path }}
run: dart pub get
- name: Check formatting
working-directory: ${{ matrix.package.path }}
run: dart format --output=none --set-exit-if-changed .
- name: Analyze code
working-directory: ${{ matrix.package.path }}
run: flutter analyze --fatal-infos
- name: Run tests
working-directory: ${{ matrix.package.path }}
run: |
if [ -d "test" ]; then
flutter test --test-randomize-ordering-seed=random
else
echo "No 'test' directory found in ${{ matrix.package.path }}, skipping tests."
fi