* refactor: detach yarn prisma generate from yarn-install action Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add run-prisma-generate input for backward compatibility The yarn-install action now has a run-prisma-generate input that defaults to true for backward compatibility. This ensures CI works correctly since workflow files are pulled from the base branch (main) while actions are pulled from the PR branch. Workflows that have explicit yarn prisma generate steps now set run-prisma-generate: false to avoid running it twice after merge. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: completely remove prisma generate from yarn-install action Remove all prisma-related code from the yarn-install action: - Remove the run-prisma-generate input parameter - Remove the Generate Prisma client step Remove explicit yarn prisma generate steps from all workflow files. Prisma generation is now handled by the postinstall script in package.json which runs 'turbo run post-install' after yarn install. This triggers @calcom/prisma#post-install which runs 'prisma generate && prisma format'. This makes the yarn-install action have no knowledge of Prisma at all, as requested. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * fix: add generic post-install step to ensure generated files are up-to-date When all caches are hit, yarn install completes quickly without running the postinstall script. This means generated files (like Prisma types) may not be created. Add a generic 'turbo run post-install' step that runs after yarn install to ensure all post-install tasks complete regardless of cache state. This keeps the action from having Prisma-specific knowledge while ensuring the post-install pipeline runs. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * refactor: remove post-install step from yarn-install action Remove the turbo run post-install step as requested. The yarn-install action now only handles yarn install with caching, with no knowledge of post-install tasks or Prisma generation. Let CI show what fails without explicit post-install handling. Co-Authored-By: keith@cal.com <keithwillcode@gmail.com> * Add back Prisma schema loaded from schema.prisma ✔ Generated Prisma Client (6.16.1) to ./generated/prisma in 442ms ✔ Generated Zod Prisma Types to ./zod in 1.43s ✔ Generated Kysely types (2.2.0) to ./../kysely in 271ms ✔ Generated Prisma Enum Generator to ./enums/index.ts in 176ms where needed * Adding Prisma schema loaded from schema.prisma ✔ Generated Prisma Client (6.16.1) to ./generated/prisma in 451ms ✔ Generated Zod Prisma Types to ./zod in 1.40s ✔ Generated Kysely types (2.2.0) to ./../kysely in 271ms ✔ Generated Prisma Enum Generator to ./enums/index.ts in 205ms where needed for E2E --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
124 lines
5.5 KiB
YAML
124 lines
5.5 KiB
YAML
########################################################################################
|
|
# "yarn install" composite action for yarn 2/3/4+ and "nodeLinker: node-modules" #
|
|
#--------------------------------------------------------------------------------------#
|
|
# Cache: #
|
|
# - Downloaded zip archive (multi-arch, preserved across yarn.lock changes) #
|
|
# - Yarn install state (discarded on yarn.lock changes) #
|
|
# References: #
|
|
# - bench: https://gist.github.com/belgattitude/0ecd26155b47e7be1be6163ecfbb0f0b #
|
|
# - vs @setup/node: https://github.com/actions/setup-node/issues/325 #
|
|
########################################################################################
|
|
|
|
name: "Yarn install"
|
|
description: "Run yarn install with node_modules linker and cache enabled"
|
|
inputs:
|
|
node_version:
|
|
required: false
|
|
default: v20.x
|
|
skip-install-if-cache-hit:
|
|
description: "Skip yarn install if node_modules cache is hit. Use this for jobs that only need to check that cache exists."
|
|
required: false
|
|
default: "false"
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Use Node ${{ inputs.node_version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ inputs.node_version }}
|
|
- name: Expose yarn config as "$GITHUB_OUTPUT"
|
|
id: yarn-config
|
|
shell: bash
|
|
run: |
|
|
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
|
|
# When skip-install-if-cache-hit is true, first check if all caches exist without downloading (lookup-only mode)
|
|
# This avoids downloading ~1.2GB of cache data when we just want to verify caches exist
|
|
- name: Check yarn cache (lookup-only)
|
|
if: ${{ inputs.skip-install-if-cache-hit == 'true' }}
|
|
uses: actions/cache/restore@v4
|
|
id: yarn-download-cache-check
|
|
with:
|
|
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
|
|
key: yarn-download-cache-${{ hashFiles('yarn.lock') }}
|
|
lookup-only: true
|
|
|
|
- name: Check node_modules cache (lookup-only)
|
|
if: ${{ inputs.skip-install-if-cache-hit == 'true' }}
|
|
uses: actions/cache/restore@v4
|
|
id: yarn-nm-cache-check
|
|
with:
|
|
path: |
|
|
**/node_modules/
|
|
!**/.next/node_modules/
|
|
key: ${{ runner.os }}-yarn-nm-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
|
|
lookup-only: true
|
|
|
|
- name: Check yarn install state cache (lookup-only)
|
|
if: ${{ inputs.skip-install-if-cache-hit == 'true' }}
|
|
uses: actions/cache/restore@v4
|
|
id: yarn-install-state-cache-check
|
|
with:
|
|
path: .yarn/ci-cache/
|
|
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
|
|
lookup-only: true
|
|
|
|
# Compute whether all caches hit (only in skip mode)
|
|
- name: Check if all caches hit
|
|
if: ${{ inputs.skip-install-if-cache-hit == 'true' }}
|
|
id: all-caches-check
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ steps.yarn-download-cache-check.outputs.cache-hit }}" == "true" && \
|
|
"${{ steps.yarn-nm-cache-check.outputs.cache-hit }}" == "true" && \
|
|
"${{ steps.yarn-install-state-cache-check.outputs.cache-hit }}" == "true" ]]; then
|
|
echo "all-hit=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "all-hit=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325
|
|
# Yarn cache is also reusable between arch and os.
|
|
# Only restore if not in skip mode, or if skip mode but any cache check missed
|
|
- name: Restore yarn cache
|
|
if: ${{ inputs.skip-install-if-cache-hit != 'true' || steps.all-caches-check.outputs.all-hit != 'true' }}
|
|
uses: actions/cache@v4
|
|
id: yarn-download-cache
|
|
with:
|
|
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
|
|
key: yarn-download-cache-${{ hashFiles('yarn.lock') }}
|
|
|
|
# Invalidated on yarn.lock changes
|
|
- name: Restore node_modules
|
|
if: ${{ inputs.skip-install-if-cache-hit != 'true' || steps.all-caches-check.outputs.all-hit != 'true' }}
|
|
id: yarn-nm-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
**/node_modules/
|
|
!**/.next/node_modules/
|
|
key: ${{ runner.os }}-yarn-nm-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
|
|
|
|
# Invalidated on yarn.lock changes
|
|
- name: Restore yarn install state
|
|
if: ${{ inputs.skip-install-if-cache-hit != 'true' || steps.all-caches-check.outputs.all-hit != 'true' }}
|
|
id: yarn-install-state-cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .yarn/ci-cache/
|
|
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
|
|
|
|
- name: Install dependencies
|
|
if: ${{ inputs.skip-install-if-cache-hit != 'true' || steps.all-caches-check.outputs.all-hit != 'true' }}
|
|
shell: bash
|
|
run: yarn install --inline-builds
|
|
env:
|
|
# CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action.
|
|
YARN_ENABLE_IMMUTABLE_INSTALLS: "false" # So it doesn't try to remove our private submodule deps
|
|
YARN_ENABLE_GLOBAL_CACHE: "false" # Use local cache folder to keep downloaded archives
|
|
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change
|
|
YARN_NM_MODE: "hardlinks-local" # Reduce node_modules size
|
|
# Other environment variables
|
|
HUSKY: "0" # By default do not run HUSKY install
|