Skip to content

Commit a3f0704

Browse files
authored
Formalize update_engine_version.{sh|ps1}. (#162118)
Towards flutter/flutter#162201. **NOTE**: This renames the environment variable to `FLUTTER_PREBUILT_ENGINE_VERSION`. --- We occasionally break ourselves, our users, and the Dart up (or is it down? side-ways) stream repos (i.e. HHH) when we change how the undocumented [`update_engine_version.sh`](https://github.com/flutter/flutter/blob/master/bin/internal/update_engine_version.sh) script, and it's Windows counterpart [`update_engine_version.ps1`](https://github.com/flutter/flutter/blob/master/bin/internal/update_engine_version.ps1) work, but have no way of knowing until N days/weeks later when someone tells us. For example, <https://flutter-review.googlesource.com/c/recipes/+/62400>. This is my attempt to encode "this is what you can guarantee by calling this script". It _still_ will be an internal only API that we might rev at any time, but at least we: 1. Can tell the Dart team "this is tested and how it works" 2. If we want to change it, the tests will keep us from changing it without informing folks it changed These tests should (in theory) cover both Linux/MacOS and Windows. /cc @a-siva
1 parent 586a592 commit a3f0704

File tree

6 files changed

+353
-22
lines changed

6 files changed

+353
-22
lines changed

.github/workflows/files-changed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: |
2323
git fetch --no-tags --prune --depth=1 origin ${{ github.event.pull_request.base.sha }}
2424
git fetch --no-tags --prune --depth=1 origin master
25-
echo "FLUTTER_ENGINE_VERSION=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_ENV"
25+
echo "FLUTTER_PREBUILT_ENGINE_VERSION=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_ENV"
2626
2727
- name: Initialize Dart SDK
2828
# This downloads the version of the Dart SDK for the current platform.

bin/internal/update_engine_version.ps1

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
# Want to test this script?
6+
# $ cd dev/tools
7+
# $ dart test test/update_engine_version_test.dart
58

69
# ---------------------------------- NOTE ---------------------------------- #
710
#
@@ -11,13 +14,28 @@
1114
#
1215
# -------------------------------------------------------------------------- #
1316

14-
$ErrorActionPreference = "Stop"
15-
1617
$progName = Split-Path -parent $MyInvocation.MyCommand.Definition
1718
$flutterRoot = (Get-Item $progName).parent.parent.FullName
1819

20+
# Allow overriding the intended engine version via FLUTTER_PREBUILT_ENGINE_VERSION.
21+
#
22+
# This is for systems, such as Github Actions, where we know ahead of time the
23+
# base-ref we want to use (to download the engine binaries and avoid trying
24+
# to compute one below), or for the Dart HH bot, which wants to try the current
25+
# Flutter framework/engine with a different Dart SDK.
26+
#
27+
# This environment variable is EXPERIMENTAL. If you are not on the Flutter infra
28+
# or Dart infra teams, this code path might be removed at anytime and cease
29+
# functioning. Please file an issue if you have workflow needs.
30+
if (![string]::IsNullOrEmpty($env:FLUTTER_PREBUILT_ENGINE_VERSION)) {
31+
$engineVersion = $env:FLUTTER_PREBUILT_ENGINE_VERSION
32+
Write-Error "[Unstable] Override: Setting engine SHA to $engineVersion"
33+
}
34+
35+
$ErrorActionPreference = "Stop"
36+
1937
# Test for fusion repository
20-
if ((Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot\engine\src\.gn" -PathType Leaf)) {
38+
if ([string]::IsNullOrEmpty($engineVersion) -and (Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot\engine\src\.gn" -PathType Leaf)) {
2139
# Calculate the engine hash from tracked git files.
2240
$branch = (git -C "$flutterRoot" rev-parse --abbrev-ref HEAD)
2341
if ($null -eq $Env:LUCI_CONTEXT) {
@@ -34,15 +52,15 @@ if ((Test-Path "$flutterRoot\DEPS" -PathType Leaf) -and (Test-Path "$flutterRoot
3452
else {
3553
$engineVersion = (git -C "$flutterRoot" rev-parse HEAD)
3654
}
55+
}
3756

38-
if (($branch -ne "stable" -and $branch -ne "beta")) {
39-
# Write the engine version out so downstream tools know what to look for.
40-
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
41-
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.version", $engineVersion, $utf8NoBom)
57+
if (($branch -ne "stable" -and $branch -ne "beta")) {
58+
# Write the engine version out so downstream tools know what to look for.
59+
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
60+
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.version", $engineVersion, $utf8NoBom)
4261

43-
# The realm on CI is passed in.
44-
if ($Env:FLUTTER_REALM) {
45-
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
46-
}
62+
# The realm on CI is passed in.
63+
if ($Env:FLUTTER_REALM) {
64+
[System.IO.File]::WriteAllText("$flutterRoot\bin\internal\engine.realm", $Env:FLUTTER_REALM, $utf8NoBom)
4765
}
48-
}
66+
}

bin/internal/update_engine_version.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Use of this source code is governed by a BSD-style license that can be
44
# found in the LICENSE file.
55

6+
# Want to test this script?
7+
# $ cd dev/tools
8+
# $ dart test test/update_engine_version_test.dart
69

710
# ---------------------------------- NOTE ---------------------------------- #
811
#
@@ -14,17 +17,18 @@
1417

1518
set -e
1619

17-
# Allow overriding the intended engine version via FLUTTER_ENGINE_VERSION.
20+
# Allow overriding the intended engine version via FLUTTER_PREBUILT_ENGINE_VERSION.
1821
#
1922
# This is for systems, such as Github Actions, where we know ahead of time the
2023
# base-ref we want to use (to download the engine binaries and avoid trying
21-
# to compute one below).
24+
# to compute one below), or for the Dart HH bot, which wants to try the current
25+
# Flutter framework/engine with a different Dart SDK.
2226
#
2327
# This environment variable is EXPERIMENTAL. If you are not on the Flutter infra
24-
# team, this code path might be removed at anytime and cease functioning. Please
25-
# file an issue if you have workflow needs.
26-
if [ -n "${FLUTTER_ENGINE_VERSION}" ]; then
27-
ENGINE_VERSION="${FLUTTER_ENGINE_VERSION}"
28+
# or Dart infra teams, this code path might be removed at anytime and cease
29+
# functioning. Please file an issue if you have workflow needs.
30+
if [ -n "${FLUTTER_PREBUILT_ENGINE_VERSION}" ]; then
31+
ENGINE_VERSION="${FLUTTER_PREBUILT_ENGINE_VERSION}"
2832
echo "[Unstable] Override: Setting engine SHA to $ENGINE_VERSION" 1>&2
2933
fi
3034

dev/tools/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ dev_dependencies:
3333
test: 1.25.14
3434
test_api: 0.7.4
3535

36+
file_testing: 3.0.2
37+
3638
_fe_analyzer_shared: 76.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3739
analyzer: 6.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
3840
boolean_selector: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -64,4 +66,4 @@ dev_dependencies:
6466
web_socket_channel: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
6567
webkit_inspection_protocol: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
6668

67-
# PUBSPEC CHECKSUM: 1d50
69+
# PUBSPEC CHECKSUM: 7e9e

0 commit comments

Comments
 (0)