-
Notifications
You must be signed in to change notification settings - Fork 135
153 lines (140 loc) · 5.54 KB
/
flutter_packages.yaml
File metadata and controls
153 lines (140 loc) · 5.54 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
# 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:
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/**"
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@93cb6efe18208431cddfb8368fd83d5badbf9bfd
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 and examples.
ALL_DIRS=$(find packages examples -name pubspec.yaml -not -path "*/.dart_tool/*" -exec dirname {} \;)
# Get the list of changed files. The method depends on the event type.
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# For PRs, use the GitHub CLI to get a precise list of changed files.
CHANGED_FILES=$(gh pr diff --name-only ${{ github.event.pull_request.number }})
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@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
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@0400d5f644dc74513175e3cd8d07132dd4860809
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: Stub firebase_options.dart
run: sh tool/stub_firebase_options.sh
- 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"