Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14472b4

Browse filesBrowse files
zandersojtmcdole
andauthored
Reland workflow cache (#170111)
Put the Android SDK and pub cache under the workflow's workspace directory instead of the worker's `$HOME` directory. In order to avoid the pub cache and Android SDK being nested inside of the Flutter checkout, this change also moves the Flutter checkout to a subdirectory of the workspace directory called `flutter`. --------- Co-authored-by: John "codefu" McDole <codefu@google.com>
1 parent ea83a6a commit 14472b4
Copy full SHA for 14472b4

File tree

Expand file treeCollapse file tree

1 file changed

+76
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+76
-9
lines changed

‎.github/workflows/tool-test-general.yml

Copy file name to clipboardExpand all lines: .github/workflows/tool-test-general.yml
+76-9Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ on:
1414
push:
1515
branches: [master]
1616

17+
env:
18+
ANDROID_TOOLS_VERSION: 13114758
19+
ANDROID_PLATFORM: android-36
20+
ANDROID_BUILDTOOLS: 36.0.0
21+
1722
jobs:
1823
Linux_tool-tests-general:
1924
permissions:
@@ -31,6 +36,7 @@ jobs:
3136
fetch-tags: true
3237
# Checkout the PR; not the merge commit - we need to describe tags
3338
ref: ${{ github.event.pull_request.head.sha }}
39+
path: 'flutter'
3440

3541
# Real checkout on github actions for post submit
3642
- name: Checkout code (non-act push)
@@ -41,16 +47,20 @@ jobs:
4147
fetch-tags: true
4248
# Checkout the PR; not the merge commit - we need to describe tags
4349
ref: ${{ github.event.pull_request.head.sha }}
50+
path: 'flutter'
4451

4552
# Fake checkout if running locally
4653
- name: Checkout code (act local)
4754
uses: actions/checkout@v4
4855
if: env.ACT
56+
with:
57+
path: 'flutter'
4958

5059
# If this is a branch / pr NOT on fluter/flutter, set the remote upstream
5160
# so the flutter tool can figure out the version
5261
- name: Set upstream (if not flutter/flutter)
5362
if: github.repository != 'flutter/flutter' && !env.ACT
63+
working-directory: ${{ github.workspace }}/flutter
5464
run: |
5565
git remote add upstream https://github.com/flutter/flutter.git
5666
git fetch --all --tags
@@ -64,30 +74,87 @@ jobs:
6474
distribution: 'temurin'
6575

6676
# If running locally; install Android SDK tools - Github runners have everything on them
67-
- name: Setup Android SDK
77+
- name: Set Android SDK environment variable
6878
if: env.ACT
79+
run: |
80+
echo "ANDROID_SDK_ROOT=$GITHUB_WORKSPACE/.android/sdk" >> $GITHUB_ENV
81+
echo "ANDROID_HOME=$GITHUB_WORKSPACE/.android/sdk" >> $GITHUB_ENV
82+
- name: Get Android SDK version
83+
id: android-sdk-version
84+
if: env.ACT
85+
run: |
86+
echo "revision=${{env.ANDROID_TOOLS_VERSION}};${{env.ANDROID_PLATFORM}};build-tools;${{env.ANDROID_BUILDTOOLS}}" >> "$GITHUB_OUTPUT"
87+
- name: Android SDK Cache
88+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
89+
id: android-sdk-setup
90+
if: env.ACT
91+
with:
92+
path: ${{ github.workspace }}/.android/sdk
93+
key: ${{ runner.os }}-${{ steps.android-sdk-version.outputs.revision }}
94+
- name: Setup Android SDK (cold cache)
95+
if: env.ACT && steps.android-sdk-setup.outputs.cache-hit != 'true'
6996
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407
7097
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
98+
packages: 'tools platform-tools platforms;${{env.ANDROID_PLATFORM}} build-tools;${{env.ANDROID_BUILDTOOLS}}'
99+
log-accepted-android-sdk-licenses: false
100+
cmdline-tools-version: ${{ env.ANDROID_TOOLS_VERSION }}
101+
- name: Setup Android SDK (warm cache)
102+
if: env.ACT && steps.android-sdk-setup.outputs.cache-hit == 'true'
76103
run: |
77-
sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0"
104+
echo "$GITHUB_WORKSPACE/.android/sdk/cmdline-tools/${{ env.ANDROID_TOOLS_VERSION }}/bin" >> "$GITHUB_PATH"
105+
echo "$GITHUB_WORKSPACE/.android/sdk/platform-tools" >> "$GITHUB_PATH"
78106
79107
- name: Add `flutter` to the PATH
80108
run: |
81-
echo "$PWD/bin" >> "$GITHUB_PATH"
109+
echo "$GITHUB_WORKSPACE/flutter/bin" >> "$GITHUB_PATH"
110+
111+
- name: Setup PUB_CACHE environment variable
112+
run: |
113+
echo "PUB_CACHE=$GITHUB_WORKSPACE/.pub-cache" >> $GITHUB_ENV
114+
115+
# Get the Flutter revision. This is the key for the cache for artifacts
116+
# under bin/cache
117+
- name: Get Flutter version
118+
id: flutter-revision
119+
working-directory: ${{ github.workspace }}/flutter
120+
run: |
121+
echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
122+
- name: Flutter artifacts cache
123+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
124+
id: flutter-artifacts
125+
with:
126+
path: ${{ github.workspace }}/flutter/bin/cache
127+
key: ${{ runner.os }}-flutter-${{ steps.flutter-revision.outputs.revision }}
128+
129+
- name: pub deps hash
130+
id: pub-deps-hash
131+
working-directory: ${{ github.workspace }}/flutter
132+
run: |
133+
# Generate stable hash of pubspec.yaml files
134+
find dev examples packages -name "pubspec.yaml" -print0 | sort -z | xargs -0 cat | sha256sum >> "$RUNNER_TEMP/pub_deps_sha"
135+
echo "revision=$(cat "$RUNNER_TEMP/pub_deps_sha")" >> "$GITHUB_OUTPUT"
136+
- name: pub package cache
137+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684
138+
id: pub-cache
139+
with:
140+
path: |
141+
${{ github.workspace }}/.pub-cache
142+
${{ github.workspace }}/flutter/**/.dart_tool
143+
${{ github.workspace }}/flutter/**/pubspec.lock
144+
key: ${{ runner.os }}-pub-${{ steps.pub-deps-hash.outputs.revision }}
82145

83146
- name: Flutter Doctor
147+
working-directory: ${{ github.workspace }}/flutter
84148
run: |
85149
flutter doctor
86150
87-
- name: update-packages
151+
- name: update-packages (online)
152+
if: steps.pub-cache.outputs.cache-hit != 'true'
153+
working-directory: ${{ github.workspace }}/flutter
88154
run: |
89155
flutter update-packages
90156
91157
- name: Tool Test
158+
working-directory: ${{ github.workspace }}/flutter
92159
run: |
93160
SHARD=tool_tests SUBSHARD=general dart --enable-asserts dev/bots/test.dart

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.