ci.yml

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