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 95d1a4a commit 6c098e8
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 132 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
60 changes: 46 additions & 14 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:
name: Build @affine/electron renderer
build-static-assets:
name: Build ${{ matrix.apps.name }}
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
run: yarn build --static
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 All @@ -571,6 +589,7 @@ jobs:
needs:
- build-server-native
- build-native
- build-static-assets
services:
postgres:
image: postgres
Expand Down Expand Up @@ -601,6 +620,18 @@ jobs:
playwright-install: true
hard-link-nm: false

- name: Download desktop 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 +659,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 +699,7 @@ jobs:
test: true,
}
needs:
- build-electron-renderer
- build-static-assets
- build-native
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -700,9 +731,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 @@ -745,7 +777,7 @@ jobs:
- name: Output check
if: ${{ matrix.spec.os == 'macos-14' && matrix.spec.arch == 'arm64' }}
run: |
yarn workspace @affine/electron exec node --loader ts-node/esm/transpile-only ./scripts/macos-arm64-output-check.ts
yarn workspace @affine/electron exec node --import @oxc-node/core/register ./scripts/macos-arm64-output-check.ts
- name: Upload test results
if: ${{ failure() }}
Expand Down Expand Up @@ -774,7 +806,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: {
...process.env,
COVERAGE: process.env.COVERAGE || 'false',
DISTRIBUTION: 'web',
BUILD_TYPE: 'canary',
},
},
{
Expand Down
10 changes: 7 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,17 @@ 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 -T run dev',
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 All @@ -49,7 +49,11 @@ const config: PlaywrightTestConfig = {
DEBUG: 'affine:*',
FORCE_COLOR: 'true',
DEBUG_COLORS: 'true',
MAILER_HOST: '0.0.0.0',
MAILER_PORT: '1025',
MAILER_SENDER: '[email protected]',
MAILER_USER: '[email protected]',
MAILER_PASSWORD: 'affine',
},
},
],
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
Loading

0 comments on commit 6c098e8

Please sign in to comment.