Skip to content

Commit

Permalink
Add pre-cache job.
Browse files Browse the repository at this point in the history
Enable caching on Windows as well.
  • Loading branch information
nielsenko committed Aug 28, 2024
1 parent 6f9395d commit 3b2fcca
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/actions/setup-runner/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ runs:
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:
Expand All @@ -53,7 +50,7 @@ runs:
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)
# Use pwsh on Windows
if: runner.os == 'Windows' && steps.restore.outputs.cache-matched-key == ''
shell: pwsh
run: >-
Expand All @@ -66,6 +63,9 @@ runs:
shell: bash
run: |
puro upgrade-puro
puro create stable || true
puro create beta || true
puro create master || true
puro use --global ${{ inputs.flutter-version }}
puro upgrade ${{ inputs.flutter-version }}
puro gc
Expand All @@ -74,7 +74,8 @@ runs:
# 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'
# if: github.ref == 'refs/heads/main'
if: steps.restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.PURO_ROOT }}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,36 @@ concurrency:
cancel-in-progress: true

jobs:
pre-cache:
# This job is used to setup the runner and cache the setup once per os.
# This is done to avoid running the setup multiple times in parallel later during test.
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- id: setup-env
shell: bash
run: |
export PURO_ROOT=$(dirname $GITHUB_WORKSPACE)/puro
echo PURO_ROOT=$PURO_ROOT >> $GITHUB_ENV
- id: cache-check
uses: actions/cache/restore@v4
with:
path: ${{ env.PURO_ROOT }}
lookup-only: true
key: setup-runner-${{ runner.os }}-${{ runner.arch }}-
restore-keys: setup-runner-${{ runner.os }}-${{ runner.arch }}-

- uses: actions/checkout@v4
if: steps.cache-check.outputs.cache-matched-key == ''
- name: Setup runner
if: steps.cache-check.outputs.cache-matched-key == ''
uses: ./.github/actions/setup-runner

build:
needs: pre-cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"cSpell.words": [
"codecov",
"posix",
"pubspec",
"puro",
"pwsh",
"Treap",
"treaps",
"upsert"
Expand Down

0 comments on commit 3b2fcca

Please sign in to comment.