chore: improve ci build speed (#2953)

This commit is contained in:
Alex Yang 2023-07-01 18:47:26 +08:00 committed by GitHub
parent ed829dd43b
commit 6af454ceed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 102 additions and 58 deletions

View File

@ -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:

View File

@ -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 }}

46
.github/workflows/nx.yml vendored Normal file
View File

@ -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

View File

@ -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.

View File

@ -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": [
{

View File

@ -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"]
}
}
}

View File

@ -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"]
}
}
}

View File

@ -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',

View File

@ -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('');
});