From 6af454ceed7dfe2c10662fbad206f05caa0bacb0 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 1 Jul 2023 18:47:26 +0800 Subject: [PATCH] chore: improve ci build speed (#2953) --- .github/workflows/build.yml | 19 ++-------- .github/workflows/cancel.yml | 3 +- .github/workflows/nx.yml | 46 ++++++++++++++++++++++++ README.md | 2 +- nx.json | 5 +-- packages/native/project.json | 25 +++++++++++++ packages/storage/project.json | 25 +++++++++++++ playwright.config.ts | 11 ------ tests/parallels/storybook/button.spec.ts | 24 ------------- 9 files changed, 102 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/nx.yml create mode 100644 packages/native/project.json create mode 100644 packages/storage/project.json delete mode 100644 tests/parallels/storybook/button.spec.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccd7f49ba3..f519a107c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -203,18 +203,9 @@ jobs: strategy: fail-fast: false matrix: - shard: [1, 2, 3, 4] + shard: [1, 2, 3, 4, 5] environment: development - needs: [build-web, build-storybook] - services: - octobase: - image: ghcr.io/toeverything/cloud-self-hosted:nightly-latest - ports: - - 3000:3000 - env: - SIGN_KEY: 'test123' - RUST_LOG: 'debug' - JWST_DEV: '1' + needs: build-web steps: - uses: actions/checkout@v3 @@ -228,12 +219,6 @@ jobs: name: next-js-static path: ./apps/web/out - - name: Download storybook artifact - uses: actions/download-artifact@v3 - with: - name: storybook - path: ./apps/storybook/storybook-static - - name: Run playwright tests run: yarn e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }} env: diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml index b521fbcd2a..528df206fc 100644 --- a/.github/workflows/cancel.yml +++ b/.github/workflows/cancel.yml @@ -13,5 +13,6 @@ jobs: steps: - uses: styfle/cancel-workflow-action@0.11.0 with: - workflow_id: 44038251 + # See https://api.github.com/repos/toeverything/AFFiNE/actions/workflows + workflow_id: 44038251, 61883931 access_token: ${{ github.token }} diff --git a/.github/workflows/nx.yml b/.github/workflows/nx.yml new file mode 100644 index 0000000000..7f3326aac2 --- /dev/null +++ b/.github/workflows/nx.yml @@ -0,0 +1,46 @@ +name: NX + +on: + push: + branches: + - master + - v[0-9]+.[0-9]+.x-staging + - v[0-9]+.[0-9]+.x + paths-ignore: + - README.md + - .github/** + - '!.github/workflows/nx.yml' + - '!.github/actions/build-rust/action.yml' + - '!.github/actions/setup-node/action.yml' + pull_request: + merge_group: + branches: + - master + - v[0-9]+.[0-9]+.x-staging + - v[0-9]+.[0-9]+.x + paths-ignore: + - README.md + - .github/** + - '!.github/workflows/nx.yml' + - '!.github/actions/build-rust/action.yml' + - '!.github/actions/setup-node/action.yml' + +jobs: + main: + name: Nx Cloud - Main Job + uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.13.0 + with: + main-branch-name: master + number-of-agents: 5 + init-commands: | + yarn exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 + parallel-commands: | + yarn exec nx-cloud record -- yarn exec nx format:check + parallel-commands-on-agents: | + yarn exec nx affected --target=build --parallel=5 + + agents: + name: Nx Cloud - Agents + uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.0 + with: + number-of-agents: 5 diff --git a/README.md b/README.md index 36d9b17f84..18c34859ef 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ We would also like to give thanks to open-source projects that make AFFiNE possi - [BlockSuite](https://github.com/toeverything/BlockSuite) - 💠 BlockSuite is the open-source collaborative editor project behind AFFiNE. - [OctoBase](https://github.com/toeverything/OctoBase) - 🐙 OctoBase is the open-source database behind AFFiNE, local-first, yet collaborative. A light-weight, scalable, data engine written in Rust. -- [Yjs](https://github.com/yjs/yjs) & [Yrs](https://github.com/y-crdt/y-crdt) - Fundamental support of CRDTs for our implementation on state management and data sync. +- [Yjs](https://github.com/yjs/yjs) - Fundamental support of CRDTs for our implementation on state management and data sync. - [Electron](https://github.com/electron/electron) - Build cross-platform desktop apps with JavaScript, HTML, and CSS. - [React](https://github.com/facebook/react) - View layer support and web GUI framework. - [Rust](https://github.com/rust-lang/rust) - High performance language that extends the ability and availability of our real-time backend, OctoBase. diff --git a/nx.json b/nx.json index 89c86b472e..aac67bdf4f 100644 --- a/nx.json +++ b/nx.json @@ -35,10 +35,7 @@ "{projectRoot}/node_modules/.cache", "{projectRoot}/target", "{workspaceRoot}/apps/storybook/storybook-static", - "{workspaceRoot}/packages/i18n/src/i18n-generated.ts", - "{workspaceRoot}/packages/native/*.node", - "{workspaceRoot}/packages/storage/*.node", - "{workspaceRoot}/affine.db" + "{workspaceRoot}/packages/i18n/src/i18n-generated.ts" ], "inputs": [ { diff --git a/packages/native/project.json b/packages/native/project.json new file mode 100644 index 0000000000..f9287ff7a6 --- /dev/null +++ b/packages/native/project.json @@ -0,0 +1,25 @@ +{ + "name": "@affine/native", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "root": "packages/native", + "sourceRoot": "packages/native/src", + "targets": { + "build": { + "executor": "nx:run-script", + "dependsOn": ["^build"], + "options": { + "script": "build" + }, + "inputs": [ + { + "runtime": "rustc --version" + }, + { + "runtime": "node -v" + } + ], + "outputs": ["{projectRoot}/*.node", "{workspaceRoot}/affine.db"] + } + } +} diff --git a/packages/storage/project.json b/packages/storage/project.json new file mode 100644 index 0000000000..e06161aba6 --- /dev/null +++ b/packages/storage/project.json @@ -0,0 +1,25 @@ +{ + "name": "@affine/storage", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "root": "packages/storage", + "sourceRoot": "packages/storage/src", + "targets": { + "build": { + "executor": "nx:run-script", + "dependsOn": ["^build"], + "options": { + "script": "build" + }, + "inputs": [ + { + "runtime": "rustc --version" + }, + { + "runtime": "node -v" + } + ], + "outputs": ["{projectRoot}/*.node", "{workspaceRoot}/*.node"] + } + } +} diff --git a/playwright.config.ts b/playwright.config.ts index 020fa8b332..7ada61b239 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -52,17 +52,6 @@ const config: PlaywrightTestConfig = { ENABLE_DEBUG_PAGE: '1', }, }, - { - // Intentionally not building the storybook, reminds you to run it by yourself. - command: 'yarn run start:storybook', - port: 6006, - timeout: 120 * 1000, - reuseExistingServer: !process.env.CI, - env: { - COVERAGE: process.env.COVERAGE || 'false', - ENABLE_DEBUG_PAGE: '1', - }, - }, // Intentionally not building the web, reminds you to run it by yourself. { command: 'yarn run start:web-static', diff --git a/tests/parallels/storybook/button.spec.ts b/tests/parallels/storybook/button.spec.ts deleted file mode 100644 index 84c77a4cba..0000000000 --- a/tests/parallels/storybook/button.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { test } from '@affine-test/kit/playwright'; -import type { Page } from '@playwright/test'; -import { expect } from '@playwright/test'; - -async function openStorybook(page: Page) { - return page.goto(`http://localhost:6006`); -} - -test('Basic', async ({ page }) => { - await openStorybook(page); - await page.click('#storybook-explorer-tree >> #affine-button'); - await page.click('#affine-button--test'); - - const iframe = page.frameLocator('iframe'); - await iframe.locator('input[data-testid="test-input"]').type('Hello World!'); - - expect( - await iframe.locator('input[data-testid="test-input"]').inputValue() - ).toBe('Hello World!'); - await iframe.locator('[data-testid="clear-button"]').click(); - expect( - await iframe.locator('input[data-testid="test-input"]').textContent() - ).toBe(''); -});