mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 08:38:34 +00:00
ci: simplify the CI (#1684)
This commit is contained in:
75
.github/actions/setup-node/action.yml
vendored
Normal file
75
.github/actions/setup-node/action.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
name: 'AFFiNE Node.js Setup'
|
||||||
|
description: 'Node.js setup for CI, including cache configuration'
|
||||||
|
inputs:
|
||||||
|
extra-flags:
|
||||||
|
description: 'Extra flags to pass to the yarn install.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
package-install:
|
||||||
|
description: 'Run the install step.'
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
registry-url: https://npm.pkg.github.com
|
||||||
|
scope: '@toeverything'
|
||||||
|
cache: 'yarn'
|
||||||
|
|
||||||
|
- name: CI Module Resolve
|
||||||
|
shell: bash
|
||||||
|
run: node scripts/module-resolve/ci.cjs
|
||||||
|
|
||||||
|
- name: yarn install
|
||||||
|
if: ${{ inputs.package-install == 'true' }}
|
||||||
|
continue-on-error: true
|
||||||
|
shell: bash
|
||||||
|
run: yarn install ${{ inputs.extra-flags }}
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
|
||||||
|
|
||||||
|
- name: yarn install (try again)
|
||||||
|
if: ${{ steps.install.outcome == 'failure' }}
|
||||||
|
shell: bash
|
||||||
|
run: yarn install ${{ inputs.extra-flags }}
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get installed Playwright version
|
||||||
|
id: playwright-version
|
||||||
|
shell: bash
|
||||||
|
run: echo "::set-output name=version::$(yarn why --json @playwright/test | grep -h 'workspace:.' | jq --raw-output '.children[].locator' | sed -e 's/@playwright\/test@.*://')"
|
||||||
|
|
||||||
|
# Attempt to restore the correct Playwright browser binaries based on the
|
||||||
|
# currently installed version of Playwright (The browser binary versions
|
||||||
|
# may change with Playwright versions).
|
||||||
|
# Note: Playwright's cache directory is hard coded because that's what it
|
||||||
|
# says to do in the docs. There doesn't appear to be a command that prints
|
||||||
|
# it out for us.
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
id: playwright-cache
|
||||||
|
with:
|
||||||
|
path: '~/.cache/ms-playwright'
|
||||||
|
key: '${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}'
|
||||||
|
# As a fallback, if the Playwright version has changed, try use the
|
||||||
|
# most recently cached version. There's a good chance that at least one
|
||||||
|
# of the browser binary versions haven't been updated, so Playwright can
|
||||||
|
# skip installing that in the next step.
|
||||||
|
# Note: When falling back to an old cache, `cache-hit` (used below)
|
||||||
|
# will be `false`. This allows us to restore the potentially out of
|
||||||
|
# date cache, but still let Playwright decide if it needs to download
|
||||||
|
# new binaries or not.
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-playwright-
|
||||||
|
|
||||||
|
# If the Playwright browser binaries weren't able to be restored, we tell
|
||||||
|
# paywright to install everything for us.
|
||||||
|
- name: Install Playwright's dependencies
|
||||||
|
shell: bash
|
||||||
|
if: steps.playwright-cache.outputs.cache-hit != 'true'
|
||||||
|
run: yarn playwright install --with-deps
|
||||||
43
.github/workflows/build-master.yml
vendored
43
.github/workflows/build-master.yml
vendored
@@ -12,29 +12,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js LTS
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: 'yarn'
|
|
||||||
registry-url: https://npm.pkg.github.com
|
|
||||||
scope: '@toeverything'
|
|
||||||
- name: Get yarn cache directory path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- run: node scripts/module-resolve/ci.cjs
|
|
||||||
|
|
||||||
- run: yarn install
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
@@ -125,22 +104,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js 18
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: 'yarn'
|
|
||||||
- name: Get yarn cache directory path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
- run: yarn install
|
|
||||||
- name: Download artifact
|
- name: Download artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
25
.github/workflows/build-test-version.yml
vendored
25
.github/workflows/build-test-version.yml
vendored
@@ -24,29 +24,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- name: Setup Node.js
|
||||||
with:
|
uses: ./.github/actions/setup-node
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
registry-url: https://npm.pkg.github.com
|
|
||||||
scope: '@toeverything'
|
|
||||||
cache: 'yarn'
|
|
||||||
- name: Get yarn cache directory path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
|
|
||||||
- run: node scripts/module-resolve/ci.cjs
|
|
||||||
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- run: yarn install
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
59
.github/workflows/build.yml
vendored
59
.github/workflows/build.yml
vendored
@@ -89,22 +89,13 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: ${{ needs.pull_request.outputs.pr_sha }}
|
ref: ${{ needs.pull_request.outputs.pr_sha }}
|
||||||
- name: Use Node.js LTS
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
# To prevent tampering with Yarn’s binary file
|
||||||
node-version-file: '.nvmrc'
|
- name: Check yarn releases
|
||||||
cache: 'yarn'
|
run: |
|
||||||
- name: Get yarn cache directory path
|
yarn set version self
|
||||||
id: yarn-cache-dir-path
|
git diff --exit-code
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
- run: yarn lint --max-warnings=0
|
- run: yarn lint --max-warnings=0
|
||||||
|
|
||||||
@@ -210,22 +201,8 @@ jobs:
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
return check.id;
|
return check.id;
|
||||||
- name: Use Node.js 18
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: 'yarn'
|
|
||||||
- name: Get yarn cache directory path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
- run: yarn install
|
|
||||||
- name: Download artifact
|
- name: Download artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -337,22 +314,8 @@ jobs:
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
return check.id;
|
return check.id;
|
||||||
- name: Use Node.js LTS
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
|
||||||
node-version-file: '.nvmrc'
|
|
||||||
cache: 'yarn'
|
|
||||||
- name: Get yarn cache directory path
|
|
||||||
id: yarn-cache-dir-path
|
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
- run: yarn install
|
|
||||||
- name: Download artifact
|
- name: Download artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
41
.github/workflows/client-app.yml
vendored
41
.github/workflows/client-app.yml
vendored
@@ -34,18 +34,8 @@ jobs:
|
|||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Get yarn cache directory path
|
- name: Setup Node.js
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install
|
|
||||||
|
|
||||||
- name: before-make
|
- name: before-make
|
||||||
working-directory: apps/electron
|
working-directory: apps/electron
|
||||||
@@ -76,13 +66,8 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- name: Setup Node.js
|
||||||
with:
|
uses: ./.github/actions/setup-node
|
||||||
node-version: 18
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install # that's right, yarn
|
|
||||||
working-directory: apps/electron
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -114,13 +99,8 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- name: Setup Node.js
|
||||||
with:
|
uses: ./.github/actions/setup-node
|
||||||
node-version: 18
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install # that's right, yarn
|
|
||||||
working-directory: apps/electron
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -152,13 +132,8 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- name: Setup Node.js
|
||||||
with:
|
uses: ./.github/actions/setup-node
|
||||||
node-version: 18
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install # that's right, yarn
|
|
||||||
working-directory: apps/electron
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
13
.github/workflows/languages-sync.yml
vendored
13
.github/workflows/languages-sync.yml
vendored
@@ -26,17 +26,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Get yarn cache directory path
|
- name: Setup Node.js
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
- run: yarn install
|
|
||||||
- name: Check Language Key
|
- name: Check Language Key
|
||||||
if: github.ref != 'refs/heads/master'
|
if: github.ref != 'refs/heads/master'
|
||||||
working-directory: ./packages/i18n
|
working-directory: ./packages/i18n
|
||||||
|
|||||||
16
.github/workflows/publish.yml
vendored
16
.github/workflows/publish.yml
vendored
@@ -20,20 +20,8 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Get yarn cache directory path
|
- name: Setup Node.js
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-
|
|
||||||
|
|
||||||
- run: yarn install
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_GITHUB_AUTH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
function getCustomize() {
|
|
||||||
const customed = fs.existsSync('./module-resolve.cjs');
|
|
||||||
if (!customed) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const script = require('./module-resolve.cjs');
|
|
||||||
return script && script.resolve;
|
|
||||||
}
|
|
||||||
|
|
||||||
const customize = getCustomize();
|
|
||||||
|
|
||||||
function readPackage(pkg) {
|
|
||||||
if (!customize) {
|
|
||||||
return pkg;
|
|
||||||
}
|
|
||||||
|
|
||||||
const customizedPkg = customize(pkg);
|
|
||||||
|
|
||||||
return customizedPkg;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
hooks: {
|
|
||||||
readPackage,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user