Skip to content

Commit

Permalink
Merge branch 'v36' into feat/20926-match-package-names
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored Jun 18, 2023
2 parents ca6bdfa + 6515df8 commit 78e9b8a
Show file tree
Hide file tree
Showing 185 changed files with 3,624 additions and 1,646 deletions.
54 changes: 21 additions & 33 deletions .github/actions/calculate-prefetch-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ inputs:
node-version:
description: 'Node version'
required: true
hash:
description: 'Yarn lock hash'
required: true
outputs:
matrix:
description: 'Matrix of OSes to prefetch `node_modules` for'
Expand All @@ -29,44 +26,35 @@ runs:
- name: Calculate cache keys
id: cache-keys
env:
LOCK_HASH: ${{ steps.yarn-lock-hash.outputs.yarn-lock-hash }}
HASH: ${{ hashFiles('yarn.lock') }}
shell: bash
run: |
echo 'macos-cache-key=node-modules-macOS-${{ inputs.node-version }}-${{ inputs.hash }}' >> "$GITHUB_OUTPUT"
echo 'windows-cache-key=node-modules-Windows-${{ inputs.node-version }}-${{ inputs.hash }}' >> "$GITHUB_OUTPUT"
echo 'MACOS_KEY=node_modules-macOS-${{ inputs.node-version }}-${{ env.HASH }}' >> "$GITHUB_ENV"
echo 'WINDOWS_KEY=node_modules-Windows-${{ inputs.node-version }}-${{ env.HASH }}' >> "$GITHUB_ENV"
- name: Fetch available cache keys
id: caches-list
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPO: ${{ inputs.repo }}
CACHES_URL: /repos/{owner}/{repo}/actions/caches
JQ_FILTER: >-
"keys=" + ([.[].actions_caches[].key] | tostring)
shell: bash
run: |
gh api ${{ env.CACHES_URL }} --paginate | jq -rcs '${{ env.JQ_FILTER }}' >> "$GITHUB_OUTPUT"
- name: Check cache miss for MacOS
id: macos-cache
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: node_modules
key: ${{ env.MACOS_KEY }}
lookup-only: true
enableCrossOsArchive: true

- name: Calculate cache misses for Windows and MacOS
id: modules-caches
env:
ACTIONS_CACHE_KEYS: ${{ steps.caches-list.outputs.keys }}
MACOS_CACHE_KEY: ${{ steps.cache-keys.outputs.macos-cache-key }}
WINDOWS_CACHE_KEY: ${{ steps.cache-keys.outputs.windows-cache-key }}
shell: bash
run: |
echo 'macos=${{
!contains(fromJSON(env.ACTIONS_CACHE_KEYS), env.MACOS_CACHE_KEY) && 'true' || ''
}}' >> "$GITHUB_OUTPUT"
echo 'windows=${{
!contains(fromJSON(env.ACTIONS_CACHE_KEYS), env.WINDOWS_CACHE_KEY) && 'true' || ''
}}' >> "$GITHUB_OUTPUT"
- name: Check cache miss for Windows
id: windows-cache
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: node_modules
key: ${{ env.WINDOWS_KEY }}
lookup-only: true
enableCrossOsArchive: true

- name: Dispatch `node_modules` prefetch for MacOS and Windows
id: os-matrix-prefetch
env:
MACOS_MISS: ${{ steps.modules-caches.outputs.macos }}
WINDOWS_MISS: ${{ steps.modules-caches.outputs.windows }}
MACOS_MISS: ${{ steps.macos-cache.outputs.cache-hit != 'true' && 'true' || '' }}
WINDOWS_MISS: ${{ steps.windows-cache.outputs.cache-hit != 'true' && 'true' || '' }}
PREFETCH_MAC_ONLY: '["macos-latest"]'
PREFETCH_WINDOWS_ONLY: '["windows-latest"]'
PREFETCH_BOTH: '["macos-latest", "windows-latest"]'
Expand Down
66 changes: 53 additions & 13 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,74 @@ inputs:
os:
description: 'Composite actions do not support `runner.os`, so it must be passed in as an input'
required: true
outputs:
cache-hit:
description: 'Cache hit for `node_modules`'
value: ${{ steps.node-modules-cache.outputs.cache-hit }}
save-cache:
description: 'Save cache when needed'
required: false
default: false
runs:
using: 'composite'
steps:
- name: Cache node_modules
id: node-modules-cache
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
- name: Calculate `CACHE_KEY`
shell: bash
run: |
echo 'CACHE_KEY=node_modules-${{
inputs.os
}}-${{
inputs.node-version
}}-${{
hashFiles('yarn.lock')
}}' >> "$GITHUB_ENV"
- name: Restore `node_modules`
id: node-modules-restore
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: node_modules
key: node-modules-${{ inputs.os }}-${{ inputs.node-version }}-${{ hashFiles('yarn.lock') }}
key: ${{ env.CACHE_KEY }}
enableCrossOsArchive: true

- name: Calculate `CACHE_HIT`
shell: bash
run: |
echo 'CACHE_HIT=${{
(steps.node-modules-restore.outputs.cache-hit == 'true') && 'true' || ''
}}' >> "$GITHUB_ENV"
- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ inputs.node-version }}
cache: ${{ steps.node-modules-cache.outputs.cache-hit != 'true' && 'yarn' || '' }}
cache: ${{ env.CACHE_HIT != 'true' && 'yarn' || '' }}

- name: Install dependencies
uses: nick-fields/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd # v2.8.3
if: steps.node-modules-cache.outputs.cache-hit != 'true'
if: env.CACHE_HIT != 'true'
with:
timeout_minutes: 10
max_attempts: 3
command: yarn install --frozen-lockfile --ignore-scripts
command: |
yarn install --frozen-lockfile --ignore-scripts
yarn prepare:re2
- name: Write `node_modules` cache
if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true'
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: node_modules
key: ${{ env.CACHE_KEY }}
enableCrossOsArchive: true

- name: Generate files
shell: bash
run: >
if [[ -d lib ]]; then
yarn prepare:generate;
fi
- name: Run scripts
- name: Git config
shell: bash
run: yarn prepare
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email '[email protected]'
git config --global user.name 'Renovate Bot'
Loading

0 comments on commit 78e9b8a

Please sign in to comment.