-
Notifications
You must be signed in to change notification settings - Fork 137
162 lines (149 loc) · 6.11 KB
/
flutter_packages.yaml
File metadata and controls
162 lines (149 loc) · 6.11 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Copyright 2025 The Flutter Authors.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Flutter GenUI CI
on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".github/workflows/flutter_packages.yaml"
- "packages/**"
- "examples/**"
- "tool/**"
pull_request:
branches:
- main
paths:
- ".github/workflows/flutter_packages.yaml"
- "packages/**"
- "examples/**"
- "tool/**"
schedule:
# Tests may fail due to new dependency releases.
# Regular execution provides early detection of such regressions.
- cron: '0 * * * *' # hourly
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
# Fetch the full history to be able to diff against the base branch
fetch-depth: 0
- name: Generate testing matrix
id: generate_matrix
env:
GH_TOKEN: ${{ github.token }}
run: |
# Find all directories containing pubspec.yaml in packages, tools, and examples.
ALL_DIRS=$(find packages examples tool -name pubspec.yaml -not -path "*/.dart_tool/*" -not -path "examples/eval/*" -exec dirname {} \;)
# Get the list of changed files. The method depends on the event type.
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Try using gh pr diff first to get the precise list of changed files.
# This avoids false positives if main has moved forward.
# We wrap it in an if statement to catch failures (e.g. diff too large).
if ! CHANGED_FILES=$(gh pr diff --name-only ${{ github.event.pull_request.number }}); then
echo "Warning: 'gh pr diff' failed. This usually happens when the PR is very large."
echo "Falling back to 'git diff' against origin/${{ github.base_ref }}."
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} HEAD)
fi
else
# For pushes, diff between the two SHAs of the push.
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
fi
# Build a regex to match any of the package directories or the workflow file.
REGEX="^\.github/workflows/flutter_packages.yaml$"
for dir in $ALL_DIRS; do
REGEX="$REGEX|^$dir/"
done
if echo "$CHANGED_FILES" | grep -q -E "$REGEX"; then
echo "Changes detected in package directories or workflow file. Testing all packages."
DIRS_TO_TEST=$ALL_DIRS
else
DIRS_TO_TEST=""
fi
# Build a JSON array of package objects for the matrix.
JSON_MATRIX="["
FIRST=true
for dir in $DIRS_TO_TEST; do
if [ "$FIRST" = false ]; then
JSON_MATRIX="$JSON_MATRIX,"
fi
FIRST=false
# The name for the job (path with '/' -> '_')
package_name=$(echo "$dir" | tr '/' '_')
# The actual path to the package
package_path="$dir"
JSON_MATRIX="$JSON_MATRIX{\"name\":\"$package_name\",\"path\":\"$package_path\"}"
done
JSON_MATRIX="$JSON_MATRIX]"
echo "matrix=$JSON_MATRIX" >> $GITHUB_OUTPUT
analyze_and_test:
needs: matrix
# Only run if the matrix job has produced a non-empty matrix.
if: github.repository == 'flutter/genui' && needs.matrix.outputs.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: [beta, stable]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
with:
distribution: "zulu"
java-version: "17"
cache: "gradle"
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: ${{ matrix.flutter_version }}
cache: true
- name: Print Flutter version
run: flutter --version
- name: Cache Pub dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
with:
path: ${{ env.PUB_CACHE }}
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: ${{ runner.os }}-pub-
- 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: Check copyrights
working-directory: ${{ matrix.package.path }}
run: |
(cd ${{ github.workspace }}/tool/fix_copyright && dart pub upgrade) > /dev/null 2>&1
dart ${{ github.workspace }}/tool/fix_copyright/bin/fix_copyright.dart --year 2025
- 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
- name: Check for cycles
working-directory: ${{ matrix.package.path }}
run: |
dart pub global activate layerlens
layerlens --fail-on-cycles --except "lib/src/schema"