name: Copilot Cron Test on: workflow_dispatch: 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' - 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 REDIS_SERVER_HOST: localhost services: postgres: image: pgvector/pgvector:pg16 env: POSTGRES_PASSWORD: affine options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 redis: image: redis ports: - 6379:6379 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 affine @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 }} COPILOT_PERPLEXITY_API_KEY: ${{ secrets.COPILOT_PERPLEXITY_API_KEY }} - name: Upload server test coverage results uses: codecov/codecov-action@v5 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: Frontend Copilot E2E Test runs-on: ubuntu-latest env: DISTRIBUTION: web DATABASE_URL: postgresql://affine:affine@localhost:5432/affine REDIS_SERVER_HOST: localhost IN_CI_TEST: true strategy: fail-fast: false matrix: shardIndex: [1, 2, 3] shardTotal: [3] needs: - build-server-native services: postgres: image: pgvector/pgvector:pg16 env: POSTGRES_PASSWORD: affine options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 redis: image: redis ports: - 6379:6379 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 affine @affine-test/affine-cloud-copilot e2e --forbid-only --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} openai-key: ${{ secrets.COPILOT_OPENAI_API_KEY }} google-key: ${{ secrets.COPILOT_GOOGLE_API_KEY }} fal-key: ${{ secrets.COPILOT_FAL_API_KEY }} perplexity-key: ${{ secrets.COPILOT_PERPLEXITY_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