-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Github composite action for setting up flutter on runner (#1710)
* Use workflow_dispatch * source ~/.profile to update paths after install of puro * Update $GITHUB_PATH * Checkout first * Add cache + simplify puro install * use --global, no melos setup, and some cleanup * .puro != ~/.puro * export $PUB_CACHE and $PURO_ROOT * Don't source ~/.profile. Set env variables explicitly * Tweak cache key * Support windows * Convert setup-runner from workflow to action * Blunt hack to get windows working * Skip stuff on partial (or exact) cache-hit * Switch from run_id to hashFiles * Use runPubGetOffline * Populate pub-cache explicitly on cache miss, as melos bootstrap no longer does * Update cSpell.words * Use for: compile for web * Remove inverted save cache condition (Debug code) * Update CHANGELOG * Ensure caches are cycled atleast once a week
- Loading branch information
Showing
12 changed files
with
136 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Setup runner | ||
description: Setup the runner with the necessary tools and dependencies. | ||
|
||
inputs: | ||
flutter-version: | ||
description: Flutter version to use. | ||
default: stable | ||
cache-key: | ||
description: Cache key to use for restoring and saving the cache. | ||
default: ${{ hashFiles('**/pubspec.yaml') }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup environment | ||
# By forcing puro (and hence the pub-cache) onto the same drive as the checkout, | ||
# we can avoid symlink issue between local and network drives on windows. | ||
id: setup | ||
shell: bash | ||
run: | | ||
export PURO_ROOT=$(dirname $GITHUB_WORKSPACE)/puro | ||
mkdir -p $PURO_ROOT | ||
echo $PURO_ROOT/bin >> $GITHUB_PATH | ||
echo $PURO_ROOT/shared/pub_cache/bin/ >> $GITHUB_PATH | ||
echo $PURO_ROOT/envs/default/flutter/bin/ >> $GITHUB_PATH | ||
echo PURO_ROOT=$PURO_ROOT >> $GITHUB_ENV | ||
echo PUB_CACHE=$PURO_ROOT/shared/pub_cache >> $GITHUB_ENV | ||
echo MELOS_SDK_PATH=$PURO_ROOT/envs/default/flutter/ >> $GITHUB_ENV | ||
echo "week = $(date +'%Y-%U')" >> $GITHUB_OUTPUT | ||
- name: Restore cache | ||
# TODO: Avoid skipping restore on Windows | ||
# (see https://github.com/pingbird/puro/issues/87) | ||
if: runner.os != 'Windows' | ||
id: restore | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ${{ env.PURO_ROOT }} | ||
key: setup-runner-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup.outputs.week }}-${{ inputs.cache-key }} | ||
restore-keys: setup-runner-${{ runner.os }}-${{ runner.arch }}- | ||
|
||
- name: Install puro (posix) | ||
# See https://puro.dev/ | ||
# Skip on any cache hit (partial or full) | ||
if: runner.os != 'Windows' && steps.restore.outputs.cache-matched-key == '' | ||
shell: bash | ||
run: curl -sS -o- https://puro.dev/install.sh | PURO_VERSION="1.4.6" bash | ||
|
||
- name: Install puro (windows) | ||
# We always install on windows, as we currently don't restore a cache (see TODO above) | ||
if: runner.os == 'Windows' && steps.restore.outputs.cache-matched-key == '' | ||
shell: pwsh | ||
run: >- | ||
Invoke-WebRequest | ||
-Uri "https://puro.dev/builds/1.4.6/windows-x64/puro.exe" | ||
-OutFile "$Env:PURO_ROOT"; | ||
&"$Env:PURO_ROOT\puro.exe" install-puro --promote | ||
- name: Upgrade puro and flutter | ||
shell: bash | ||
run: | | ||
puro upgrade-puro | ||
puro use --global ${{ inputs.flutter-version }} | ||
puro upgrade ${{ inputs.flutter-version }} | ||
puro gc | ||
- name: Activate melos | ||
if: steps.restore.outputs.cache-matched-key == '' | ||
shell: bash | ||
run: puro pub global run melos --version || puro pub global activate melos | ||
|
||
- name: Pub get | ||
# We need to run `flutter pub get` first, to ensure the pub-cache is populated, | ||
# if we don't have an exact cache hit. | ||
if: steps.restore.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: puro pub global run melos exec -- flutter pub get | ||
|
||
- name: Melos bootstrap | ||
shell: bash | ||
run: puro pub global run melos bootstrap | ||
|
||
- name: Save cache | ||
# Saving on feature branches will only benefit reruns, so we don't bother. | ||
# Feature branches inherit the cache from the main branch anyway. | ||
# This saves on cache storage. | ||
if: github.ref == 'refs/heads/main' && steps.restore.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ env.PURO_ROOT }} | ||
key: ${{ steps.restore.outputs.cache-primary-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ | |
"nodoc", | ||
"nullptr", | ||
"posix", | ||
"puro", | ||
"pwsh", | ||
"riscv", | ||
"sublist", | ||
"sublists", | ||
|
Oops, something went wrong.