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
 14concurrency:
 15  # Allow only one workflow per any non-`main` branch.
 16  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
 17  cancel-in-progress: true
 18
 19env:
 20  CARGO_TERM_COLOR: always
 21  CARGO_INCREMENTAL: 0
 22  RUST_BACKTRACE: 1
 23  RUSTFLAGS: "-D warnings"
 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 FIX​ME 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: cargo clippy
105        run: ./script/clippy
106
107      - name: Check unused dependencies
108        uses: bnjbvr/cargo-machete@main
109
110      - name: Check licenses
111        run: |
112          script/check-licenses
113          script/generate-licenses /tmp/zed_licenses_output
114
115      - name: Check for new vulnerable dependencies
116        if: github.event_name == 'pull_request'
117        uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4
118        with:
119          license-check: false
120
121      - name: Run tests
122        uses: ./.github/actions/run_tests
123
124      - name: Build collab
125        run: cargo build -p collab
126
127      - name: Build other binaries and features
128        run: |
129          cargo build --workspace --bins --all-features
130          cargo check -p gpui --features "macos-blade"
131          cargo check -p workspace
132          cargo build -p remote_server
133          script/check-rust-livekit-macos
134
135  linux_tests:
136    timeout-minutes: 60
137    name: (Linux) Run Clippy and tests
138    if: github.repository_owner == 'zed-industries'
139    runs-on:
140      - buildjet-16vcpu-ubuntu-2204
141    steps:
142      - name: Add Rust to the PATH
143        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
144
145      - name: Checkout repo
146        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
147        with:
148          clean: false
149
150      - name: Cache dependencies
151        uses: swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2
152        with:
153          save-if: ${{ github.ref == 'refs/heads/main' }}
154          cache-provider: "buildjet"
155
156      - name: Install Linux dependencies
157        run: ./script/linux
158
159      - name: cargo clippy
160        run: ./script/clippy
161
162      - name: Run tests
163        uses: ./.github/actions/run_tests
164
165      - name: Build other binaries and features
166        run: |
167          cargo build -p zed
168          cargo check -p workspace
169
170  build_remote_server:
171    timeout-minutes: 60
172    name: (Linux) Build Remote Server
173    if: github.repository_owner == 'zed-industries'
174    runs-on:
175      - buildjet-16vcpu-ubuntu-2204
176    steps:
177      - name: Add Rust to the PATH
178        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
179
180      - name: Checkout repo
181        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
182        with:
183          clean: false
184
185      - name: Cache dependencies
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 Clang & Mold
192        run: ./script/remote-server && ./script/install-mold 2.34.0
193
194      - name: Build Remote Server
195        run: cargo build -p remote_server
196
197  # todo(windows): Actually run the tests
198  windows_tests:
199    timeout-minutes: 60
200    name: (Windows) Run Clippy and tests
201    if: github.repository_owner == 'zed-industries'
202    runs-on: hosted-windows-1
203    steps:
204      # more info here:- https://github.com/rust-lang/cargo/issues/13020
205      - name: Enable longer pathnames for git
206        run: git config --system core.longpaths true
207      - name: Checkout repo
208        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
209        with:
210          clean: false
211
212      - name: Cache dependencies
213        uses: swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2
214        with:
215          save-if: ${{ github.ref == 'refs/heads/main' }}
216          cache-provider: "github"
217
218      - name: cargo clippy
219        # Windows can't run shell scripts, so we need to use `cargo xtask`.
220        run: cargo xtask clippy
221
222      - name: Build Zed
223        run: cargo build
224
225  bundle-mac:
226    timeout-minutes: 120
227    name: Create a macOS bundle
228    runs-on:
229      - self-hosted
230      - bundle
231    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
232    needs: [macos_tests]
233    env:
234      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
235      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
236      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
237      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
238      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
239      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
240      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
241      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
242    steps:
243      - name: Install Node
244        uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
245        with:
246          node-version: "18"
247
248      - name: Checkout repo
249        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
250        with:
251          # We need to fetch more than one commit so that `script/draft-release-notes`
252          # is able to diff between the current and previous tag.
253          #
254          # 25 was chosen arbitrarily.
255          fetch-depth: 25
256          clean: false
257          ref: ${{ github.ref }}
258
259      - name: Limit target directory size
260        run: script/clear-target-dir-if-larger-than 100
261
262      - name: Determine version and release channel
263        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
264        run: |
265          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
266          script/determine-release-channel
267
268      - name: Draft release notes
269        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
270        run: |
271          mkdir -p target/
272          # Ignore any errors that occur while drafting release notes to not fail the build.
273          script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md || true
274          script/create-draft-release target/release-notes.md
275        env:
276          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
277
278      - name: Create macOS app bundle
279        run: script/bundle-mac
280
281      - name: Rename binaries
282        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
283        run: |
284          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
285          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
286
287      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
288        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
289        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
290        with:
291          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
292          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
293
294      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
295        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
296        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
297        with:
298          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
299          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
300
301      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
302        name: Upload app bundle to release
303        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
304        with:
305          draft: true
306          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
307          files: |
308            target/zed-remote-server-macos-x86_64.gz
309            target/zed-remote-server-macos-aarch64.gz
310            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
311            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
312        env:
313          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
314
315  bundle-linux-x86_x64:
316    timeout-minutes: 60
317    name: Linux x86_x64 release bundle
318    runs-on:
319      - buildjet-16vcpu-ubuntu-2004
320    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
321    needs: [linux_tests]
322    env:
323      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
324      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
325      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
326      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
327    steps:
328      - name: Checkout repo
329        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
330        with:
331          clean: false
332
333      - name: Install Linux dependencies
334        run: ./script/linux && ./script/install-mold 2.34.0
335
336      - name: Determine version and release channel
337        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
338        run: |
339          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
340          script/determine-release-channel
341
342      - name: Create Linux .tar.gz bundle
343        run: script/bundle-linux
344
345      - name: Upload Linux bundle to workflow run if main branch or specific label
346        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
347        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
348        with:
349          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
350          path: target/release/zed-*.tar.gz
351
352      - name: Upload app bundle to release
353        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
354        with:
355          draft: true
356          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
357          files: |
358            target/zed-remote-server-linux-x86_64.gz
359            target/release/zed-linux-x86_64.tar.gz
360        env:
361          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
362
363  bundle-linux-aarch64: # this runs on ubuntu22.04
364    timeout-minutes: 60
365    name: Linux arm64 release bundle
366    runs-on:
367      - buildjet-16vcpu-ubuntu-2204-arm
368    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
369    needs: [linux_tests]
370    env:
371      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
372      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
373      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
374      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
375    steps:
376      - name: Checkout repo
377        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
378        with:
379          clean: false
380
381      - name: Install Linux dependencies
382        run: ./script/linux
383
384      - name: Determine version and release channel
385        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
386        run: |
387          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
388          script/determine-release-channel
389
390      - name: Create and upload Linux .tar.gz bundle
391        run: script/bundle-linux
392
393      - name: Upload Linux bundle to workflow run if main branch or specific label
394        uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
395        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
396        with:
397          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
398          path: target/release/zed-*.tar.gz
399
400      - name: Upload app bundle to release
401        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
402        with:
403          draft: true
404          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
405          files: |
406            target/zed-remote-server-linux-aarch64.gz
407            target/release/zed-linux-aarch64.tar.gz
408        env:
409          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
410
411  auto-release-preview:
412    name: Auto release preview
413    if: ${{ startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre') }}
414    needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64]
415    runs-on:
416      - self-hosted
417      - bundle
418    steps:
419      - name: gh release
420        run: gh release edit $GITHUB_REF_NAME --draft=false
421        env:
422          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}