Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add build cache to all workflows #474

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/actions/setup-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Setup Cache
description: Prepare Snack's build cache in GitHub Actions

runs:
using: composite
steps:
- name: 🔍 Find modules cache
id: modules-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
shell: bash

- name: ♻️ Restore modules cache
uses: actions/cache@v3
with:
path: ${{ steps.modules-cache.outputs.dir }}
key: yarn-TEST_1-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-TEST_1-${{ runner.os }}-

- name: 📦 Install monorepo dependencies
run: yarn install --frozen-lockfile
shell: bash

- name: ♻️ Restore build cache
uses: actions/cache@v3
with:
key: turbo-TEST_4-${{ runner.os }}-${{ github.sha }}
restore-keys: |
turbo-TEST_4-${{ runner.os }}-
path: |
node_modules/.cache/turbo
packages/*/.turbo
7 changes: 4 additions & 3 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
workflow_dispatch:
pull_request:
paths:
- .github/actions/setup-cache/**
- .github/workflows/packages.yml
- packages/**
- .eslint*
Expand All @@ -17,6 +18,7 @@ on:
push:
branches: [main]
paths:
- .github/actions/setup-cache/**
- .github/workflows/packages.yml
- packages/**
- .eslint*
Expand Down Expand Up @@ -54,10 +56,9 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn

- name: 📦 Install monorepo dependencies
run: yarn install --frozen-lockfile
- name: 🏗 Setup cache
uses: ./.github/actions/setup-cache

# When coupled within the monorepo, make sure to build all packages related to the tested one
- name: 🛠 Build dependencies
Expand Down