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 18, 2024
1 parent cbb52c6 commit 5d8dd7c
Show file tree
Hide file tree
Showing 23 changed files with 206 additions and 131 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
68 changes: 53 additions & 15 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 @@ -699,10 +730,17 @@ jobs:
shell: bash
run: yarn workspace @affine/electron vitest

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

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

- name: Build Desktop Layers
run: yarn workspace @affine/electron build
Expand Down Expand Up @@ -745,7 +783,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 +812,7 @@ jobs:
- unit-test
- build-native
- build-server-native
- build-electron-renderer
- build-static-assets
- server-test
- rust-test
- copilot-api-test
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ jobs:
SKIP_NX_CACHE: 'true'
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}

- name: Upload web artifact
- name: Upload desktop artifact
uses: actions/upload-artifact@v4
with:
name: web
name: desktop
path: packages/frontend/apps/electron/resources/web-static

make-distribution:
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: web
name: desktop
path: packages/frontend/apps/electron/resources/web-static

- name: Build Desktop Layers
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 @@ -26,14 +26,16 @@ const config: PlaywrightTestConfig = {
retries: 3,
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,
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 @@ -26,14 +26,16 @@ const config: PlaywrightTestConfig = {
retries: process.env.COPILOT ? 1 : 3,
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,
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
2 changes: 1 addition & 1 deletion tests/affine-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@affine-test/affine-desktop",
"private": true,
"scripts": {
"e2e": "DEBUG=pw:browser yarn playwright test"
"e2e": "yarn playwright test"
},
"devDependencies": {
"@affine-test/kit": "workspace:*",
Expand Down
7 changes: 5 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,16 @@ 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',
PLAYWRIGHT_DEV_SERVER: 'true',
...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 @@ -44,14 +43,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 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
6 changes: 5 additions & 1 deletion tests/affine-mobile/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ const config: PlaywrightTestConfig = {
webServer: [
// 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 5d8dd7c

Please sign in to comment.