Skip to content

Commit 8f7a20c

Browse files
authored
Try to cache the clean version of flutter Dartdoc uses (#2802)
* Just try to get something working * simplify * Store the current date in output * well it doesn't complain locally now? * Empty commit to trigger CI
1 parent f704565 commit 8f7a20c

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

.github/workflows/test.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ jobs:
3838
job: sdk-analyzer
3939

4040
steps:
41+
- name: Store date
42+
id: date
43+
run: echo "::set-output name=today::$(date +'%Y-%m-%d')"
44+
shell: bash
45+
- name: Cache clean flutter
46+
uses: actions/cache@v2
47+
if: matrix.job == 'flutter'
48+
env:
49+
# Increment version to invalidate bad/obsolete caches.
50+
cache-name: cache-grinder-flutter-v1
51+
with:
52+
path: ~/.dartdoc_grinder
53+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ steps.date.outputs.today }}
54+
- name: Cache .pub-cache
55+
uses: actions/cache@v2
56+
if: matrix.job == 'flutter'
57+
env:
58+
# Increment version to invalidate bad/obsolete caches.
59+
cache-name: cache-dart-pub-v1
60+
with:
61+
path: ~/.pub-cache
62+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ steps.date.outputs.today }}
4163
- name: Configure git
4264
if: runner.os == 'Windows'
4365
run: git config --global core.autocrlf input

tool/grind.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Future<FlutterRepo> get cleanFlutterRepo async {
8888
int.parse(lastSynced.readAsStringSync()));
8989
}
9090
if (lastSyncedTime == null ||
91-
DateTime.now().difference(lastSyncedTime) > Duration(hours: 4)) {
91+
DateTime.now().difference(lastSyncedTime) > Duration(hours: 24)) {
9292
// Rebuild the repository.
9393
if (cleanFlutterDir.existsSync()) {
9494
cleanFlutterDir.deleteSync(recursive: true);
@@ -185,7 +185,12 @@ final Directory flutterDirDevTools =
185185
Map<String, String> _createThrowawayPubCache() {
186186
var pubCache = Directory.systemTemp.createTempSync('pubcache');
187187
var pubCacheBin = Directory(path.join(pubCache.path, 'bin'));
188-
pubCacheBin.createSync();
188+
var defaultCache = Directory(defaultPubCache);
189+
if (defaultCache.existsSync()) {
190+
copy(defaultCache, pubCache);
191+
} else {
192+
pubCacheBin.createSync();
193+
}
189194
return Map.fromIterables([
190195
'PUB_CACHE',
191196
'PATH'
@@ -870,11 +875,6 @@ class FlutterRepo {
870875
['--version'],
871876
workingDirectory: flutterPath,
872877
);
873-
await launcher.runStreamed(
874-
bin,
875-
['precache'],
876-
workingDirectory: flutterPath,
877-
);
878878
await launcher.runStreamed(
879879
bin,
880880
['update-packages'],

0 commit comments

Comments
 (0)