Skip to content

Commit 1946081

Browse files
authored
feat: experimental tool tests workflow (attempt 2) (#169768)
- remote repo: set upstream and get tags (flutter tool reqs) - pull request to flutter: checkout the PR, not the merge commit - local runs: update utils.dart to safely call terminal width Now `act -W .github/workflows/tool-test-general.yml` works locally on the command line. Future improvements: - Offer another way to set the "version" rather than tags; this causes a longer checkout time. - Multi-proc the tests and use as many cores as possible? - Solve for packages downloading? 3.5 minutes isn't terrible.
1 parent 291a689 commit 1946081

2 files changed

Lines changed: 104 additions & 3 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Tool tests general - experiment
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- '.github/workflows/tool-test-general.yml'
8+
- 'dev/**'
9+
- 'packages/flutter_tools/**'
10+
- 'bin/**'
11+
- '.ci.yaml'
12+
- 'engine/**'
13+
- 'DEPS'
14+
push:
15+
branches: [master]
16+
17+
jobs:
18+
Linux_tool-tests-general:
19+
permissions:
20+
contents: read
21+
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
# Real checkout on github actions for pull requests
26+
- name: Checkout code (non-act pull_request)
27+
uses: actions/checkout@v4
28+
if: github.event_name == 'pull_request' && !env.ACT
29+
with:
30+
fetch-depth: 0
31+
fetch-tags: true
32+
# Checkout the PR; not the merge commit - we need to describe tags
33+
ref: ${{ github.event.pull_request.head.sha }}
34+
35+
# Real checkout on github actions for post submit
36+
- name: Checkout code (non-act push)
37+
uses: actions/checkout@v4
38+
if: github.event_name == 'push' && !env.ACT
39+
with:
40+
fetch-depth: 0
41+
fetch-tags: true
42+
# Checkout the PR; not the merge commit - we need to describe tags
43+
ref: ${{ github.event.pull_request.head.sha }}
44+
45+
# Fake checkout if running locally
46+
- name: Checkout code (act local)
47+
uses: actions/checkout@v4
48+
if: env.ACT
49+
50+
# If this is a branch / pr NOT on fluter/flutter, set the remote upstream
51+
# so the flutter tool can figure out the version
52+
- name: Set upstream (if not flutter/flutter)
53+
if: github.repository != 'flutter/flutter' && !env.ACT
54+
run: |
55+
git remote add upstream https://github.com/flutter/flutter.git
56+
git fetch --all --tags
57+
58+
# If running locally; install the JDK - Github runners have everything on them
59+
- name: Set up our JDK environment
60+
if: env.ACT
61+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00
62+
with:
63+
java-version: '21'
64+
distribution: 'temurin'
65+
66+
# If running locally; install Android SDK tools - Github runners have everything on them
67+
- name: Setup Android SDK
68+
if: env.ACT
69+
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
70+
with:
71+
cmdline-tools-version: 13114758
72+
73+
# If running locally; install Android SDK - Github runners have everything on them
74+
- name: install android
75+
if: env.ACT
76+
run: |
77+
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
78+
79+
- name: Add `flutter` to the PATH
80+
run: |
81+
echo "$PWD/bin" >> "$GITHUB_PATH"
82+
83+
- name: Flutter Doctor
84+
run: |
85+
flutter doctor
86+
87+
- name: update-packages
88+
run: |
89+
flutter update-packages
90+
91+
- name: Tool Test
92+
run: |
93+
SHARD=tool_tests SUBSHARD=general dart --enable-asserts dev/bots/test.dart

dev/bots/utils.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,17 @@ const int kCSIIntermediateRangeEnd = 0x2F;
107107
const int kCSIFinalRangeStart = 0x40;
108108
const int kCSIFinalRangeEnd = 0x7E;
109109

110+
int get terminalColumns {
111+
try {
112+
return stdout.terminalColumns;
113+
} catch (e) {
114+
return 40;
115+
}
116+
}
117+
110118
String get redLine {
111119
if (hasColor) {
112-
return '$red${'━' * stdout.terminalColumns}$reset';
120+
return '$red${'━' * terminalColumns}$reset';
113121
}
114122
return '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━';
115123
}
@@ -168,7 +176,7 @@ void foundError(List<String> messages) {
168176
assert(messages.isNotEmpty);
169177
// Make the error message easy to notice in the logs by
170178
// wrapping it in a red box.
171-
final int width = math.max(15, (hasColor ? stdout.terminalColumns : 80) - 1);
179+
final int width = math.max(15, (hasColor ? terminalColumns : 80) - 1);
172180
final String title = 'ERROR #${_errorMessages.length + 1}';
173181
print('$red╔═╡$bold$title$reset$red╞═${"═" * (width - 4 - title.length)}');
174182
for (final String message in messages.expand((String line) => line.split('\n'))) {
@@ -258,7 +266,7 @@ void _printQuietly(Object? message) {
258266
final int start = line.lastIndexOf(_lineBreak) + 1;
259267
int index = start;
260268
int length = 0;
261-
while (index < line.length && length < stdout.terminalColumns) {
269+
while (index < line.length && length < terminalColumns) {
262270
if (line.codeUnitAt(index) == kESC) {
263271
// 0x1B
264272
index += 1;

0 commit comments

Comments
 (0)