ci.yml

  1name: CI
  2
  3on:
  4  push:
  5    branches:
  6      - main
  7      - "v[0-9]+.[0-9]+.x"
  8    tags:
  9      - "v*"
 10  pull_request:
 11    branches:
 12      - "**"
 13  merge_group:
 14
 15concurrency:
 16  # Allow only one workflow per any non-`main` branch.
 17  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
 18  cancel-in-progress: true
 19
 20env:
 21  CARGO_TERM_COLOR: always
 22  CARGO_INCREMENTAL: 0
 23  RUST_BACKTRACE: 1
 24  RUSTFLAGS: "-D warnings"
 25
 26jobs:
 27  check_docs_only:
 28    runs-on: ubuntu-latest
 29    outputs:
 30      docs_only: ${{ steps.check_changes.outputs.docs_only }}
 31    steps:
 32      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
 33        with:
 34          fetch-depth: 0
 35      - name: Check for non-docs changes
 36        id: check_changes
 37        run: |
 38          if [ "${{ github.event_name }}" == "merge_group" ]; then
 39            # When we're running in a merge queue, never assume that the changes
 40            # are docs-only, as there could be other PRs in the group that
 41            # contain non-docs changes.
 42            echo "Running in the merge queue"
 43            echo "docs_only=false" >> $GITHUB_OUTPUT
 44          elif git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -qvE '^docs/'; then
 45            echo "Detected non-docs changes"
 46            echo "docs_only=false" >> $GITHUB_OUTPUT
 47          else
 48            echo "Docs-only change"
 49            echo "docs_only=true" >> $GITHUB_OUTPUT
 50          fi
 51
 52  migration_checks:
 53    name: Check Postgres and Protobuf migrations, mergability
 54    if: github.repository_owner == 'zed-industries'
 55    timeout-minutes: 60
 56    runs-on:
 57      - self-hosted
 58      - test
 59    steps:
 60      - name: Checkout repo
 61        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
 62        with:
 63          clean: false
 64          fetch-depth: 0 # fetch full history
 65
 66      - name: Remove untracked files
 67        run: git clean -df
 68
 69      - name: Find modified migrations
 70        shell: bash -euxo pipefail {0}
 71        run: |
 72          export SQUAWK_GITHUB_TOKEN=${{ github.token }}
 73          . ./script/squawk
 74
 75      - name: Ensure fresh merge
 76        shell: bash -euxo pipefail {0}
 77        run: |
 78          if [ -z "$GITHUB_BASE_REF" ];
 79          then
 80            echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> $GITHUB_ENV
 81          else
 82            git checkout -B temp
 83            git merge -q origin/$GITHUB_BASE_REF -m "merge main into temp"
 84            echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> $GITHUB_ENV
 85          fi
 86
 87      - uses: bufbuild/buf-setup-action@v1
 88        with:
 89          version: v1.29.0
 90      - uses: bufbuild/buf-breaking-action@v1
 91        with:
 92          input: "crates/proto/proto/"
 93          against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/"
 94
 95  style:
 96    timeout-minutes: 60
 97    name: Check formatting and spelling
 98    if: github.repository_owner == 'zed-industries'
 99    runs-on:
100      - buildjet-8vcpu-ubuntu-2204
101    steps:
102      - name: Checkout repo
103        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
104
105      # To support writing comments that they will certainly be revisited.
106      - name: Check for todo​! and FIX​ME comments
107        run: script/check-todos
108
109      - name: Run style checks
110        uses: ./.github/actions/check_style
111
112      - name: Check for typos
113        uses: crate-ci/typos@8e6a4285bcbde632c5d79900a7779746e8b7ea3f # v1.24.6
114        with:
115          config: ./typos.toml
116
117  macos_tests:
118    timeout-minutes: 60
119    name: (macOS) Run Clippy and tests
120    if: github.repository_owner == 'zed-industries'
121    runs-on:
122      - self-hosted
123      - test
124    needs: check_docs_only
125    steps:
126      - name: Checkout repo
127        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
128        with:
129          clean: false
130
131      - name: cargo clippy
132        if: needs.check_docs_only.outputs.docs_only == 'false'
133        run: ./script/clippy
134
135      - name: Check unused dependencies
136        if: needs.check_docs_only.outputs.docs_only == 'false'
137        uses: bnjbvr/cargo-machete@main
138
139      - name: Check licenses
140        if: needs.check_docs_only.outputs.docs_only == 'false'
141        run: |
142          script/check-licenses
143          script/generate-licenses /tmp/zed_licenses_output
144
145      - name: Check for new vulnerable dependencies
146        if: github.event_name == 'pull_request' && needs.check_docs_only.outputs.docs_only == 'false'
147        uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4
148        with:
149          license-check: false
150
151      - name: Run tests
152        if: needs.check_docs_only.outputs.docs_only == 'false'
153        uses: ./.github/actions/run_tests
154
155      - name: Build collab
156        if: needs.check_docs_only.outputs.docs_only == 'false'
157        run: cargo build -p collab
158
159      - name: Build other binaries and features
160        if: needs.check_docs_only.outputs.docs_only == 'false'
161        run: |
162          cargo build --workspace --bins --all-features
163          cargo check -p gpui --features "macos-blade"
164          cargo check -p workspace
165          cargo build -p remote_server
166          script/check-rust-livekit-macos
167
168  linux_tests:
169    timeout-minutes: 60
170    name: (Linux) Run Clippy and tests
171    if: github.repository_owner == 'zed-industries'
172    runs-on:
173      - buildjet-16vcpu-ubuntu-2204
174    needs: check_docs_only
175    steps:
176      - name: Add Rust to the PATH
177        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
178
179      - name: Checkout repo
180        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
181        with:
182          clean: false
183
184      - name: Cache dependencies
185        if: needs.check_docs_only.outputs.docs_only == 'false'
186        uses: swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2
187        with:
188          save-if: ${{ github.ref == 'refs/heads/main' }}
189          cache-provider: "buildjet"
190
191      - name: Install Linux dependencies
192        if: needs.check_docs_only.outputs.docs_only == 'false'
193        run: ./script/linux
194
195      - name: cargo clippy
196        if: needs.check_docs_only.outputs.docs_only == 'false'
197        run: ./script/clippy
198
199      - name: Run tests
200        if: needs.check_docs_only.outputs.docs_only == 'false'
201        uses: ./.github/actions/run_tests
202
203      - name: Build other binaries and features
204        if: needs.check_docs_only.outputs.docs_only == 'false'
205        run: |
206          cargo build -p zed
207          cargo check -p workspace
208
209  build_remote_server:
210    timeout-minutes: 60
211    name: (Linux) Build Remote Server
212    if: github.repository_owner == 'zed-industries'
213    runs-on:
214      - buildjet-16vcpu-ubuntu-2204
215    needs: check_docs_only
216    steps:
217      - name: Add Rust to the PATH
218        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
219
220      - name: Checkout repo
221        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
222        with:
223          clean: false
224
225      - name: Cache dependencies
226        if: needs.check_docs_only.outputs.docs_only == 'false'
227        uses: swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2
228        with:
229          save-if: ${{ github.ref == 'refs/heads/main' }}
230          cache-provider: "buildjet"
231
232      - name: Install Clang & Mold
233        if: needs.check_docs_only.outputs.docs_only == 'false'
234        run: ./script/remote-server && ./script/install-mold 2.34.0
235
236      - name: Build Remote Server
237        if: needs.check_docs_only.outputs.docs_only == 'false'
238        run: cargo build -p remote_server
239
240  # todo(windows): Actually run the tests
241  windows_tests:
242    timeout-minutes: 60
243    name: (Windows) Run Clippy and tests
244    if: github.repository_owner == 'zed-industries'
245    runs-on: hosted-windows-1
246    needs: check_docs_only
247    steps:
248      # more info here:- https://github.com/rust-lang/cargo/issues/13020
249      - name: Enable longer pathnames for git
250        run: git config --system core.longpaths true
251      - name: Checkout repo
252        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
253        with:
254          clean: false
255
256      - name: Cache dependencies
257        if: needs.check_docs_only.outputs.docs_only == 'false'
258        uses: swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2
259        with:
260          save-if: ${{ github.ref == 'refs/heads/main' }}
261          cache-provider: "github"
262
263      - name: cargo clippy
264        if: needs.check_docs_only.outputs.docs_only == 'false'
265        # Windows can't run shell scripts, so we need to use `cargo xtask`.
266        run: cargo xtask clippy
267
268      - name: Build Zed
269        if: needs.check_docs_only.outputs.docs_only == 'false'
270        run: cargo build
271
272  bundle-mac:
273    timeout-minutes: 60
274    name: Create a macOS bundle
275    runs-on:
276      - self-hosted
277      - bundle
278    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
279    needs: [macos_tests]
280    env:
281      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
282      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
283      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
284      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
285      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
286      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
287      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
288      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
289    steps:
290      - name: Install Node
291        uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
292        with:
293          node-version: "18"
294
295      - name: Checkout repo
296        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
297        with:
298          # We need to fetch more than one commit so that `script/draft-release-notes`
299          # is able to diff between the current and previous tag.
300          #
301          # 25 was chosen arbitrarily.
302          fetch-depth: 25
303          clean: false
304          ref: ${{ github.ref }}
305
306      - name: Limit target directory size
307        run: script/clear-target-dir-if-larger-than 100
308
309      - name: Determine version and release channel
310        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
311        run: |
312          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
313          script/determine-release-channel
314
315      - name: Draft release notes
316        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
317        run: |
318          mkdir -p target/
319          # Ignore any errors that occur while drafting release notes to not fail the build.
320          script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md || true
321          script/create-draft-release target/release-notes.md
322        env:
323          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
324
325      - name: Create macOS app bundle
326        run: script/bundle-mac
327
328      - name: Rename binaries
329        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
330        run: |
331          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
332          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
333
334      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
335        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
336        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
337        with:
338          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
339          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
340
341      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
342        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
343        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
344        with:
345          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
346          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
347
348      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
349        name: Upload app bundle to release
350        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
351        with:
352          draft: true
353          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
354          files: |
355            target/zed-remote-server-macos-x86_64.gz
356            target/zed-remote-server-macos-aarch64.gz
357            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
358            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
359        env:
360          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
361
362  bundle-linux:
363    timeout-minutes: 60
364    name: Create a Linux bundle
365    runs-on:
366      - buildjet-16vcpu-ubuntu-2004
367    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
368    needs: [linux_tests]
369    env:
370      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
371      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
372      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
373      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
374    steps:
375      - name: Checkout repo
376        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
377        with:
378          clean: false
379
380      - name: Install Linux dependencies
381        run: ./script/linux && ./script/install-mold 2.34.0
382
383      - name: Determine version and release channel
384        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
385        run: |
386          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
387          script/determine-release-channel
388
389      - name: Create Linux .tar.gz bundle
390        run: script/bundle-linux
391
392      - name: Upload Linux bundle to workflow run if main branch or specific label
393        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
394        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
395        with:
396          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
397          path: target/release/zed-*.tar.gz
398
399      - name: Upload app bundle to release
400        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
401        with:
402          draft: true
403          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
404          files: |
405            target/zed-remote-server-linux-x86_64.gz
406            target/release/zed-linux-x86_64.tar.gz
407        env:
408          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
409
410  bundle-linux-aarch64: # this runs on ubuntu22.04
411    timeout-minutes: 60
412    name: Create arm64 Linux bundle
413    runs-on:
414      - buildjet-16vcpu-ubuntu-2204-arm
415    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
416    needs: [linux_tests]
417    env:
418      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
419      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
420      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
421      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
422    steps:
423      - name: Checkout repo
424        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
425        with:
426          clean: false
427
428      - name: Install Linux dependencies
429        run: ./script/linux
430
431      - name: Determine version and release channel
432        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
433        run: |
434          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
435          script/determine-release-channel
436
437      - name: Create and upload Linux .tar.gz bundle
438        run: script/bundle-linux
439
440      - name: Upload Linux bundle to workflow run if main branch or specific label
441        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
442        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
443        with:
444          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
445          path: target/release/zed-*.tar.gz
446
447      - name: Upload app bundle to release
448        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
449        with:
450          draft: true
451          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
452          files: |
453            target/zed-remote-server-linux-aarch64.gz
454            target/release/zed-linux-aarch64.tar.gz
455        env:
456          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
457
458  auto-release-preview:
459    name: Auto release preview
460    if: ${{ startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre') }}
461    needs: [bundle-mac, bundle-linux, bundle-linux-aarch64]
462    runs-on:
463      - self-hosted
464      - bundle
465    steps:
466      - name: gh release
467        run: gh release edit $GITHUB_REF_NAME --draft=false
468        env:
469          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}