Copilot Cron Test #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Copilot Cron Test | |
on: | |
workflow_dispatch: | |
env: | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/node_modules/.cache/ms-playwright | |
jobs: | |
build-server-native: | |
name: Build Server native | |
runs-on: ubuntu-latest | |
env: | |
CARGO_PROFILE_RELEASE_DEBUG: '1' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: ./.github/actions/setup-node | |
with: | |
extra-flags: workspaces focus @affine/server-native | |
electron-install: false | |
- name: Build Rust | |
uses: ./.github/actions/build-rust | |
with: | |
target: 'x86_64-unknown-linux-gnu' | |
package: '@affine/server-native' | |
nx_token: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
- name: Upload server-native.node | |
uses: actions/upload-artifact@v4 | |
with: | |
name: server-native.node | |
path: ./packages/backend/native/server-native.node | |
if-no-files-found: error | |
copilot-api-test: | |
name: Server Copilot Api Test | |
runs-on: ubuntu-latest | |
needs: | |
- build-server-native | |
env: | |
NODE_ENV: test | |
DISTRIBUTION: web | |
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: affine | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
mailer: | |
image: mailhog/mailhog | |
ports: | |
- 1025:1025 | |
- 8025:8025 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: ./.github/actions/setup-node | |
with: | |
playwright-install: true | |
electron-install: false | |
full-cache: true | |
- name: Download server-native.node | |
uses: actions/download-artifact@v4 | |
with: | |
name: server-native.node | |
path: ./packages/backend/server | |
- name: Prepare Server Test Environment | |
uses: ./.github/actions/server-test-env | |
- name: Run server tests | |
run: yarn workspace @affine/server test:copilot:coverage --forbid-only | |
env: | |
CARGO_TARGET_DIR: '${{ github.workspace }}/target' | |
COPILOT_OPENAI_API_KEY: ${{ secrets.COPILOT_OPENAI_API_KEY }} | |
COPILOT_FAL_API_KEY: ${{ secrets.COPILOT_FAL_API_KEY }} | |
- name: Upload server test coverage results | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./packages/backend/server/.coverage/lcov.info | |
flags: server-test | |
name: affine | |
fail_ci_if_error: false | |
copilot-e2e-test: | |
name: Server Copilot E2E Test | |
runs-on: ubuntu-latest | |
env: | |
DISTRIBUTION: web | |
DATABASE_URL: postgresql://affine:affine@localhost:5432/affine | |
IN_CI_TEST: true | |
strategy: | |
fail-fast: false | |
matrix: | |
shardIndex: [1, 2, 3] | |
shardTotal: [3] | |
needs: | |
- build-server-native | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: affine | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: ./.github/actions/setup-node | |
with: | |
playwright-install: true | |
electron-install: false | |
hard-link-nm: false | |
- name: Download server-native.node | |
uses: actions/download-artifact@v4 | |
with: | |
name: server-native.node | |
path: ./packages/backend/server | |
- name: Run Copilot E2E Test ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
uses: ./.github/actions/copilot-test | |
with: | |
script: yarn workspace @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
openai-key: ${{ secrets.COPILOT_OPENAI_API_KEY }} | |
fal-key: ${{ secrets.COPILOT_FAL_API_KEY }} | |
test-done: | |
needs: | |
- copilot-api-test | |
- copilot-e2e-test | |
if: always() | |
runs-on: ubuntu-latest | |
name: Post test result message | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: ./.github/actions/setup-node | |
with: | |
extra-flags: 'workspaces focus @affine/copilot-result' | |
electron-install: false | |
- name: Post Success event to a Slack channel | |
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} | |
run: node ./tools/copilot-result/index.js | |
env: | |
CHANNEL_ID: ${{ secrets.RELEASE_SLACK_CHNNEL_ID }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
BRANCH_SHA: ${{ github.sha }} | |
BRANCH_NAME: ${{ github.ref }} | |
COPILOT_RESULT: success | |
- name: Post Failed event to a Slack channel | |
id: failed-slack | |
if: ${{ always() && contains(needs.*.result, 'failure') }} | |
run: node ./tools/copilot-result/index.js | |
env: | |
CHANNEL_ID: ${{ secrets.RELEASE_SLACK_CHNNEL_ID }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
BRANCH_SHA: ${{ github.sha }} | |
BRANCH_NAME: ${{ github.ref }} | |
COPILOT_RESULT: failed | |
- name: Post Cancel event to a Slack channel | |
id: cancel-slack | |
if: ${{ always() && contains(needs.*.result, 'cancelled') && !contains(needs.*.result, 'failure') }} | |
run: node ./tools/copilot-result/index.js | |
env: | |
CHANNEL_ID: ${{ secrets.RELEASE_SLACK_CHNNEL_ID }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
BRANCH_SHA: ${{ github.sha }} | |
BRANCH_NAME: ${{ github.ref }} | |
COPILOT_RESULT: canceled |