unit_evals.yml

 1name: Run Unit Evals
 2
 3on:
 4  schedule:
 5    # GitHub might drop jobs at busy times, so we choose a random time in the middle of the night.
 6    - cron: "47 1 * * *"
 7  workflow_dispatch:
 8
 9concurrency:
10  # Allow only one workflow per any non-`main` branch.
11  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
12  cancel-in-progress: true
13
14env:
15  CARGO_TERM_COLOR: always
16  CARGO_INCREMENTAL: 0
17  RUST_BACKTRACE: 1
18  ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
19
20jobs:
21  unit_evals:
22    timeout-minutes: 60
23    name: Run unit evals
24    runs-on:
25      - buildjet-16vcpu-ubuntu-2204
26    steps:
27      - name: Add Rust to the PATH
28        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
29
30      - name: Checkout repo
31        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
32        with:
33          clean: false
34
35      - name: Cache dependencies
36        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
37        with:
38          save-if: ${{ github.ref == 'refs/heads/main' }}
39          cache-provider: "buildjet"
40
41      - name: Install Linux dependencies
42        run: ./script/linux
43
44      - name: Configure CI
45        run: |
46          mkdir -p ./../.cargo
47          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
48
49      - name: Install Rust
50        shell: bash -euxo pipefail {0}
51        run: |
52          cargo install cargo-nextest --locked
53
54      - name: Install Node
55        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
56        with:
57          node-version: "18"
58
59      - name: Limit target directory size
60        shell: bash -euxo pipefail {0}
61        run: script/clear-target-dir-if-larger-than 100
62
63      - name: Run unit evals
64        shell: bash -euxo pipefail {0}
65        run: cargo nextest run --workspace --no-fail-fast --features eval --no-capture -E 'test(::eval_)' --test-threads 1
66        env:
67          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
68
69      - name: Send failure message to Slack channel if needed
70        if: ${{ failure() }}
71        uses: slackapi/slack-github-action@b0fa283ad8fea605de13dc3f449259339835fc52
72        with:
73          method: chat.postMessage
74          token: ${{ secrets.SLACK_APP_ZED_UNIT_EVALS_BOT_TOKEN }}
75          payload: |
76            channel: C04UDRNNJFQ
77            text: "Unit Evals Failed: https://github.com/zed-industries/zed/actions/runs/${{ github.run_id }}"
78
79      # Even the Linux runner is not stateful, in theory there is no need to do this cleanup.
80      # But, to avoid potential issues in the future if we choose to use a stateful Linux runner and forget to add code
81      # to clean up the config file, I’ve included the cleanup code here as a precaution.
82      # While it’s not strictly necessary at this moment, I believe it’s better to err on the side of caution.
83      - name: Clean CI config file
84        if: always()
85        run: rm -rf ./../.cargo