Skip to content

Commit

Permalink
ci: reuse artifacts from previous pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Dec 17, 2024
1 parent 36ac793 commit 4762add
Show file tree
Hide file tree
Showing 20 changed files with 182 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ inputs:
path:
description: 'Path to extract'
required: true
name:
description: 'Name of the artifact'
required: true

runs:
using: 'composite'
steps:
- name: Download tar.gz
uses: actions/download-artifact@v4
with:
name: web
name: ${{ inputs.name }}
path: .

- name: Extract core artifacts
Expand Down
53 changes: 42 additions & 11 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,23 @@ jobs:
path: ./packages/backend/native/server-native.node
if-no-files-found: error

build-electron-renderer:
build-static-assets:
name: Build @affine/electron renderer
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
apps:
- {
name: 'Electron renderer',
distribution: desktop,
directory: packages/frontend/apps/electron/renderer/dist,
}
- {
name: 'Web',
distribution: web,
directory: packages/frontend/apps/web/dist,
}

steps:
- uses: actions/checkout@v4
Expand All @@ -282,17 +296,17 @@ jobs:
with:
electron-install: false
full-cache: true
- name: Build Electron renderer
- name: Build ${{ matrix.apps.name }}
# always skip cache because its fast, and cache configuration is always changing
run: yarn build
env:
DISTRIBUTION: desktop
- name: zip web
run: tar -czf dist.tar.gz --directory=packages/frontend/apps/electron/renderer/dist .
- name: Upload web artifact
DISTRIBUTION: ${{ matrix.apps.distribution }}
- name: zip ${{ matrix.apps.name }}
run: tar -czf dist.tar.gz --directory=${{ matrix.apps.directory }} .
- name: Upload ${{ matrix.apps.name }} artifact
uses: actions/upload-artifact@v4
with:
name: web
name: ${{ matrix.apps.distribution }}
path: dist.tar.gz
if-no-files-found: error

Expand Down Expand Up @@ -555,12 +569,16 @@ jobs:
matrix:
tests:
- name: 'Server E2E Test 1/3'
artifact: test-results-e2e-server-1
script: yarn workspace @affine-test/affine-cloud e2e --forbid-only --shard=1/3
- name: 'Server E2E Test 2/3'
artifact: test-results-e2e-server-2
script: yarn workspace @affine-test/affine-cloud e2e --forbid-only --shard=2/3
- name: 'Server E2E Test 3/3'
artifact: test-results-e2e-server-3
script: yarn workspace @affine-test/affine-cloud e2e --forbid-only --shard=3/3
- name: 'Server Desktop E2E Test'
artifact: test-results-e2e-server-desktop
script: |
yarn workspace @affine/electron build:dev
# Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions
Expand Down Expand Up @@ -601,6 +619,18 @@ jobs:
playwright-install: true
hard-link-nm: false

- name: Download web artifact
uses: ./.github/actions/download-static-zip
with:
path: packages/frontend/apps/electron/renderer/dist
name: desktop

- name: Download web artifact
uses: ./.github/actions/download-static-zip
with:
path: packages/frontend/apps/web/dist
name: web

- name: Download server-native.node
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -628,7 +658,7 @@ jobs:
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-results-e2e-server
name: test-results-e2e-server-${{ matrix.tests.artifact }}
path: ./test-results
if-no-files-found: ignore

Expand Down Expand Up @@ -668,7 +698,7 @@ jobs:
test: true,
}
needs:
- build-electron-renderer
- build-static-assets
- build-native
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -700,9 +730,10 @@ jobs:
run: yarn workspace @affine/electron vitest

- name: Download web artifact
uses: ./.github/actions/download-web
uses: ./.github/actions/download-static-zip
with:
path: packages/frontend/apps/electron/resources/web-static
name: desktop

- name: Build Desktop Layers
run: yarn workspace @affine/electron build
Expand Down Expand Up @@ -774,7 +805,7 @@ jobs:
- unit-test
- build-native
- build-server-native
- build-electron-renderer
- build-static-assets
- server-test
- rust-test
- copilot-api-test
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"dev:electron": "yarn workspace @affine/electron dev",
"build:electron": "yarn nx build @affine/electron",
"build:server-native": "yarn nx run-many -t build -p @affine/server-native",
"start:web-static": "yarn workspace @affine/web static-server",
"serve:test-static": "yarn exec serve tests/fixtures --cors -p 8081",
"lint:eslint": "cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" eslint --report-unused-disable-directives-severity=off . --cache",
"lint:eslint:fix": "yarn lint:eslint --fix",
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/apps/android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=android yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"static-server": "cross-env DISTRIBUTION=android yarn workspace @affine/cli dev --static"
"dev": "yarn workspace @affine/cli dev"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/apps/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@electron-forge/plugin-auto-unpack-natives": "^7.6.0",
"@electron-forge/shared-types": "^7.6.0",
"@emotion/react": "^11.14.0",
"@oxc-node/core": "^0.0.16",
"@pengx17/electron-forge-maker-appimage": "^1.2.1",
"@sentry/electron": "^5.8.0",
"@sentry/esbuild-plugin": "^2.22.7",
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/apps/ios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"build": "cross-env DISTRIBUTION=ios yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"sync": "yarn cap sync",
"sync:dev": "CAP_SERVER_URL=http://localhost:8080 yarn cap sync",
"static-server": "cross-env DISTRIBUTION=ios yarn workspace @affine/cli dev --static"
"sync:dev": "CAP_SERVER_URL=http://localhost:8080 yarn cap sync"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=mobile yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"static-server": "cross-env DISTRIBUTION=mobile yarn workspace @affine/cli dev --static"
"dev": "yarn workspace @affine/cli dev"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"browser": "src/index.tsx",
"scripts": {
"build": "cross-env DISTRIBUTION=web yarn workspace @affine/cli bundle",
"dev": "yarn workspace @affine/cli dev",
"static-server": "yarn workspace @affine/cli dev --static"
"dev": "yarn workspace @affine/cli dev"
},
"dependencies": {
"@affine/component": "workspace:*",
Expand Down
6 changes: 4 additions & 2 deletions tests/affine-cloud-copilot/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ const config: PlaywrightTestConfig = {
ENABLE_DEBUG_PAGE: '1',
},
},
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn -T run start:web-static',
command: 'yarn -T run dev',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'web',
BUILD_TYPE: 'canary',
...process.env,
},
},
{
Expand Down
6 changes: 4 additions & 2 deletions tests/affine-cloud/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ const config: PlaywrightTestConfig = {
ENABLE_DEBUG_PAGE: '1',
},
},
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn -T run start:web-static',
command: 'yarn -T run dev',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'web',
BUILD_TYPE: 'canary',
...process.env,
},
},
{
Expand Down
16 changes: 13 additions & 3 deletions tests/affine-desktop-cloud/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { testResultDir } from '@affine-test/kit/playwright';
import type { PlaywrightTestConfig } from '@playwright/test';
// import { devices } from '@playwright/test';

/**
* Read environment variables from file.
Expand All @@ -21,16 +20,27 @@ const config: PlaywrightTestConfig = {
},
reporter: process.env.CI ? 'github' : 'list',
webServer: [
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn -T run start:web-static',
command: 'yarn run serve:test-static',
port: 8081,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
ENABLE_DEBUG_PAGE: '1',
},
},
{
command: 'yarn -T run dev --static',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
env: {
...process.env,
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'desktop',
BUILD_TYPE: 'canary',
},
},
{
Expand Down
6 changes: 4 additions & 2 deletions tests/affine-desktop/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from 'node:assert';

import { testResultDir } from '@affine-test/kit/playwright';
import type { PlaywrightTestConfig } from '@playwright/test';
// import { devices } from '@playwright/test';

/**
* Read environment variables from file.
Expand Down Expand Up @@ -41,12 +40,15 @@ if (process.env.DEV_SERVER_URL) {
);
config.webServer = [
{
command: 'yarn run start:web-static',
command: 'yarn -T run dev --static',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'desktop',
BUILD_TYPE: 'canary',
...process.env,
},
},
];
Expand Down
8 changes: 5 additions & 3 deletions tests/affine-local/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {
PlaywrightTestConfig,
PlaywrightWorkerOptions,
} from '@playwright/test';
// import { devices } from '@playwright/test';

/**
* Read environment variables from file.
Expand Down Expand Up @@ -54,14 +53,17 @@ const config: PlaywrightTestConfig = {
ENABLE_DEBUG_PAGE: '1',
},
},
// Intentionally not building the web, reminds you to run it by yourself.
{
command: 'yarn run start:web-static',
command: 'yarn -T run dev',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
...process.env,
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'web',
BUILD_TYPE: 'canary',
CI: '1',
},
},
],
Expand Down
16 changes: 5 additions & 11 deletions tests/affine-mobile/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,18 @@ const config: PlaywrightTestConfig = {
reporter: process.env.CI ? 'github' : 'list',

webServer: [
{
command: 'yarn run serve:test-static',
port: 8081,
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 workspace @affine/mobile static-server',
command: 'yarn -T run dev',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
env: {
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'mobile',
BUILD_TYPE: 'canary',
CI: '1',
...process.env,
},
},
],
Expand Down
8 changes: 4 additions & 4 deletions tools/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@clack/prompts": "^0.8.2",
"@magic-works/i18n-codegen": "^0.6.1",
"@napi-rs/simple-git": "^0.1.19",
"@oxc-node/core": "^0.0.16",
"@perfsee/webpack": "^1.13.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@sentry/webpack-plugin": "^2.22.7",
Expand All @@ -33,16 +34,15 @@
"style-loader": "^4.0.0",
"swc-loader": "^0.2.6",
"tailwindcss": "^3.4.16",
"terser-webpack-plugin": "^5.3.10",
"ts-node": "^10.9.2",
"terser-webpack-plugin": "^5.3.11",
"vite": "^6.0.3",
"webpack": "^5.97.1",
"webpack-dev-server": "^5.2.0",
"webpack-merge": "^6.0.1"
},
"scripts": {
"bundle": "node --loader ts-node/esm/transpile-only.mjs ./src/bin/build.ts",
"dev": "node --loader ts-node/esm/transpile-only.mjs ./src/bin/dev.ts"
"bundle": "node --import @oxc-node/core/register ./src/bin/build.ts",
"dev": "node --import @oxc-node/core/register ./src/bin/dev.ts"
},
"version": "0.18.0"
}
Loading

0 comments on commit 4762add

Please sign in to comment.