blob: 6e7bcc3e63d21e338dfc8507838a99a2ef6b4f4c [file] [log] [blame]
# Copyright 2023 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
name: Flutter SDK prep
on:
workflow_call:
inputs:
os-name:
description: 'The OS to run against, either "macos" or "ubuntu". If neither is provided, will run against both.'
type: string
outputs:
latest_flutter_candidate:
description: "The latest Flutter candidate version."
value: ${{ jobs.reusable-flutter-prep.outputs.latest_flutter_candidate }}
jobs:
reusable-flutter-prep:
name: ${{ matrix.os }} Flutter Prep
outputs:
latest_flutter_candidate: ${{ steps.flutter-candidate.outputs.FLUTTER_CANDIDATE }}
strategy:
matrix:
os: ${{ (inputs.os-name == 'macos' && fromJSON('[ "macos-latest"]')) || (inputs.os-name == 'ubuntu' && fromJSON('[ "ubuntu-latest"]')) || fromJSON('["ubuntu-latest", "macos-latest"]') }}
runs-on: ${{ matrix.os }}
steps:
# TODO(https://github.com/flutter/devtools/issues/5729) Consider caching DevTools so that we
# don't check it out again is subsequent workflows.
- name: Checkout DevTools (default)
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
- name: Get Latest Flutter Candidate
id: flutter-candidate
run: |
LATEST_FLUTTER_CANDIDATE=$(./tool/latest_flutter_candidate.sh)
echo "FLUTTER_CANDIDATE=$LATEST_FLUTTER_CANDIDATE" >> $GITHUB_OUTPUT
- name: Load Cached Flutter SDK
id: cache-flutter
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
with:
path: |
./tool/flutter-sdk
key: flutter-sdk-${{ runner.os }}-${{ steps.flutter-candidate.outputs.FLUTTER_CANDIDATE }}
- if: ${{ steps.cache-flutter.outputs.cache-hit != 'true' }}
name: Clone Flutter SDK if none cached
run: |
git clone https://github.com/flutter/flutter.git ./tool/flutter-sdk
cd tool/flutter-sdk
git checkout $LATEST_FLUTTER_CANDIDATE
env:
LATEST_FLUTTER_CANDIDATE: ${{ steps.flutter-candidate.outputs.FLUTTER_CANDIDATE }}
- name: Assert that the Latest Flutter Candidate is checked out
run: |
cd tool/flutter-sdk
HEAD_SHA=$(git rev-parse HEAD)
LATEST_FLUTTER_CANDIDATE_SHA=$(git rev-list -1 "$LATEST_FLUTTER_CANDIDATE")
if [ "$HEAD_SHA" != "$LATEST_FLUTTER_CANDIDATE_SHA" ]; then
echo "::error ,title=Error checking out Latest Flutter Candidate::{expected HEAD to be at $LATEST_FLUTTER_CANDIDATE_SHA but got $HEAD_SHA}"
exit 1
fi
env:
LATEST_FLUTTER_CANDIDATE: ${{ steps.flutter-candidate.outputs.FLUTTER_CANDIDATE }}
- name: Setup Flutter SDK
run: |
./tool/flutter-sdk/bin/flutter config --disable-analytics
./tool/flutter-sdk/bin/cache/dart-sdk/bin/dart --disable-analytics
./tool/flutter-sdk/bin/flutter doctor