mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
ci: reduce yarn cache (#2983)
This commit is contained in:
68
.github/actions/setup-node/action.yml
vendored
68
.github/actions/setup-node/action.yml
vendored
@@ -13,10 +13,18 @@ inputs:
|
|||||||
description: 'Run the install step for Playwright.'
|
description: 'Run the install step for Playwright.'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
electron-install:
|
||||||
|
description: 'Download the Electron binary'
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
npm-token:
|
npm-token:
|
||||||
description: 'The NPM token to use for private packages.'
|
description: 'The NPM token to use for private packages.'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
hard-link-nm:
|
||||||
|
description: 'set nmMode to hardlinks-local in .yarnrc.yml'
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
@@ -29,33 +37,10 @@ runs:
|
|||||||
scope: '@toeverything'
|
scope: '@toeverything'
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Expose yarn config as "$GITHUB_OUTPUT"
|
- name: Set nmMode
|
||||||
id: yarn-config
|
if: ${{ inputs.hard-link-nm == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: yarn config set nmMode hardlinks-local
|
||||||
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Restore yarn cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: yarn-download-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
|
|
||||||
key: yarn-download-cache-${{ hashFiles('yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
yarn-download-cache-
|
|
||||||
|
|
||||||
- name: Restore node_modules cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: '**/node_modules'
|
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Restore yarn install state
|
|
||||||
id: yarn-install-state-cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: .yarn/ci-cache/
|
|
||||||
key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
|
|
||||||
|
|
||||||
- name: yarn install
|
- name: yarn install
|
||||||
if: ${{ inputs.package-install == 'true' }}
|
if: ${{ inputs.package-install == 'true' }}
|
||||||
@@ -64,9 +49,9 @@ runs:
|
|||||||
run: yarn install ${{ inputs.extra-flags }}
|
run: yarn install ${{ inputs.extra-flags }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
||||||
YARN_ENABLE_GLOBAL_CACHE: 'false'
|
|
||||||
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz
|
|
||||||
HUSKY: '0'
|
HUSKY: '0'
|
||||||
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||||
|
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
||||||
|
|
||||||
- name: yarn install (try again)
|
- name: yarn install (try again)
|
||||||
if: ${{ steps.install.outcome == 'failure' }}
|
if: ${{ steps.install.outcome == 'failure' }}
|
||||||
@@ -74,9 +59,9 @@ runs:
|
|||||||
run: yarn install ${{ inputs.extra-flags }}
|
run: yarn install ${{ inputs.extra-flags }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
|
||||||
YARN_ENABLE_GLOBAL_CACHE: 'false'
|
|
||||||
YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz
|
|
||||||
HUSKY: '0'
|
HUSKY: '0'
|
||||||
|
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
|
||||||
|
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
|
||||||
|
|
||||||
- name: Get installed Playwright version
|
- name: Get installed Playwright version
|
||||||
id: playwright-version
|
id: playwright-version
|
||||||
@@ -113,3 +98,26 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
if: inputs.playwright-install == 'true' && steps.playwright-cache.outputs.cache-hit != 'true'
|
if: inputs.playwright-install == 'true' && steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
run: yarn playwright install --with-deps
|
run: yarn playwright install --with-deps
|
||||||
|
|
||||||
|
- name: Get installed Electron version
|
||||||
|
id: electron-version
|
||||||
|
if: ${{ inputs.electron-install == 'true' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "version=$(yarn why --json electron | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://' | head -n 1)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
id: electron-cache
|
||||||
|
if: ${{ inputs.electron-install == 'true' }}
|
||||||
|
with:
|
||||||
|
path: 'node_modules/.cache/electron'
|
||||||
|
key: '${{ runner.os }}-electron-${{ steps.electron-version.outputs.version }}'
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-electron-
|
||||||
|
|
||||||
|
- name: Install Electron binary
|
||||||
|
shell: bash
|
||||||
|
if: inputs.electron-install == 'true'
|
||||||
|
run: node apps/electron/node_modules/electron/install.js
|
||||||
|
env:
|
||||||
|
ELECTRON_OVERRIDE_DIST_PATH: ./node_modules/.cache/electron
|
||||||
|
|||||||
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@@ -43,6 +43,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
|
with:
|
||||||
|
electron-install: false
|
||||||
- name: Run i18n codegen
|
- name: Run i18n codegen
|
||||||
run: yarn i18n-codegen gen
|
run: yarn i18n-codegen gen
|
||||||
- name: Run Type Check
|
- name: Run Type Check
|
||||||
@@ -50,7 +52,10 @@ jobs:
|
|||||||
- name: Run ESLint
|
- name: Run ESLint
|
||||||
run: yarn lint --max-warnings=0 --cache
|
run: yarn lint --max-warnings=0 --cache
|
||||||
- name: Run Prettier
|
- name: Run Prettier
|
||||||
run: yarn prettier . --ignore-unknown --cache --check
|
# Set nmMode in `actions/setup-node` will modify the .yarnrc.yml
|
||||||
|
run: |
|
||||||
|
git checkout .yarnrc.yml
|
||||||
|
yarn prettier . --ignore-unknown --cache --check
|
||||||
- name: Run circular
|
- name: Run circular
|
||||||
run: yarn circular
|
run: yarn circular
|
||||||
- name: Upload server dist
|
- name: Upload server dist
|
||||||
@@ -69,6 +74,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
|
with:
|
||||||
|
electron-install: false
|
||||||
- run: yarn nx build @affine/docs
|
- run: yarn nx build @affine/docs
|
||||||
env:
|
env:
|
||||||
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
||||||
@@ -82,6 +89,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
|
with:
|
||||||
|
electron-install: false
|
||||||
- run: yarn nx build @affine/storybook
|
- run: yarn nx build @affine/storybook
|
||||||
env:
|
env:
|
||||||
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
|
||||||
@@ -187,6 +196,7 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
playwright-install: true
|
playwright-install: true
|
||||||
|
electron-install: false
|
||||||
- name: Download storybook artifact
|
- name: Download storybook artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -213,6 +223,7 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
playwright-install: true
|
playwright-install: true
|
||||||
|
electron-install: false
|
||||||
- name: Download artifact
|
- name: Download artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -256,6 +267,7 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
playwright-install: true
|
playwright-install: true
|
||||||
|
electron-install: false
|
||||||
|
|
||||||
- name: Download next static
|
- name: Download next static
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
@@ -327,6 +339,7 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
playwright-install: true
|
playwright-install: true
|
||||||
|
hard-link-nm: false
|
||||||
- name: Build AFFiNE native
|
- name: Build AFFiNE native
|
||||||
uses: ./.github/actions/build-rust
|
uses: ./.github/actions/build-rust
|
||||||
with:
|
with:
|
||||||
@@ -396,6 +409,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: ./.github/actions/setup-node
|
uses: ./.github/actions/setup-node
|
||||||
|
with:
|
||||||
|
electron-install: false
|
||||||
|
|
||||||
- name: Build Infra
|
- name: Build Infra
|
||||||
run: yarn run build:infra
|
run: yarn run build:infra
|
||||||
|
|||||||
Reference in New Issue
Block a user