ci.yml

  1name: CI
  2
  3on:
  4  push:
  5    branches:
  6      - main
  7      - "v[0-9]+.[0-9]+.x"
  8    tags:
  9      - "v*"
 10    paths-ignore:
 11      - "docs/**"
 12  pull_request:
 13    branches:
 14      - "**"
 15    paths-ignore:
 16      - "docs/**"
 17      - ".github/workflows/community_*"
 18
 19concurrency:
 20  # Allow only one workflow per any non-`main` branch.
 21  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
 22  cancel-in-progress: true
 23
 24env:
 25  CARGO_TERM_COLOR: always
 26  CARGO_INCREMENTAL: 0
 27  RUST_BACKTRACE: 1
 28
 29jobs:
 30  migration_checks:
 31    name: Check Postgres and Protobuf migrations, mergability
 32    if: github.repository_owner == 'zed-industries'
 33    timeout-minutes: 60
 34    runs-on:
 35      - self-hosted
 36      - test
 37    steps:
 38      - name: Checkout repo
 39        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
 40        with:
 41          clean: false
 42          fetch-depth: 0 # fetch full history
 43
 44      - name: Remove untracked files
 45        run: git clean -df
 46
 47      - name: Find modified migrations
 48        shell: bash -euxo pipefail {0}
 49        run: |
 50          export SQUAWK_GITHUB_TOKEN=${{ github.token }}
 51          . ./script/squawk
 52
 53      - name: Ensure fresh merge
 54        shell: bash -euxo pipefail {0}
 55        run: |
 56          if [ -z "$GITHUB_BASE_REF" ];
 57          then
 58            echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> $GITHUB_ENV
 59          else
 60            git checkout -B temp
 61            git merge -q origin/$GITHUB_BASE_REF -m "merge main into temp"
 62            echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> $GITHUB_ENV
 63          fi
 64
 65      - uses: bufbuild/buf-setup-action@v1
 66        with:
 67          version: v1.29.0
 68      - uses: bufbuild/buf-breaking-action@v1
 69        with:
 70          input: "crates/proto/proto/"
 71          against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/"
 72
 73  style:
 74    timeout-minutes: 60
 75    name: Check formatting and spelling
 76    if: github.repository_owner == 'zed-industries'
 77    runs-on:
 78      - buildjet-8vcpu-ubuntu-2204
 79    steps:
 80      - name: Checkout repo
 81        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
 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: Run tests
116        uses: ./.github/actions/run_tests
117
118      - name: Build collab
119        run: RUSTFLAGS="-D warnings" cargo build -p collab
120
121      - name: Build other binaries and features
122        run: |
123          RUSTFLAGS="-D warnings" cargo build --workspace --bins --all-features
124          cargo check -p gpui --features "macos-blade"
125          RUSTFLAGS="-D warnings" cargo build -p remote_server
126
127  linux_tests:
128    timeout-minutes: 60
129    name: (Linux) Run Clippy and tests
130    if: github.repository_owner == 'zed-industries'
131    runs-on:
132      - buildjet-16vcpu-ubuntu-2204
133    steps:
134      - name: Add Rust to the PATH
135        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
136
137      - name: Checkout repo
138        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
139        with:
140          clean: false
141
142      - name: Cache dependencies
143        uses: swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2
144        with:
145          save-if: ${{ github.ref == 'refs/heads/main' }}
146          cache-provider: "buildjet"
147
148      - name: Install Linux dependencies
149        run: ./script/linux
150
151      - name: cargo clippy
152        run: ./script/clippy
153
154      - name: Run tests
155        uses: ./.github/actions/run_tests
156
157      - name: Build Zed
158        run: RUSTFLAGS="-D warnings" cargo build -p zed
159
160  build_remote_server:
161    timeout-minutes: 60
162    name: (Linux) Build Remote Server
163    if: github.repository_owner == 'zed-industries'
164    runs-on:
165      - buildjet-16vcpu-ubuntu-2204
166    steps:
167      - name: Add Rust to the PATH
168        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
169
170      - name: Checkout repo
171        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
172        with:
173          clean: false
174
175      - name: Cache dependencies
176        uses: swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2
177        with:
178          save-if: ${{ github.ref == 'refs/heads/main' }}
179          cache-provider: "buildjet"
180
181      - name: Install Clang & Mold
182        run: ./script/remote-server && ./script/install-mold 2.34.0
183
184      - name: Build Remote Server
185        run: RUSTFLAGS="-D warnings" cargo build -p remote_server
186
187  # todo(windows): Actually run the tests
188  windows_tests:
189    timeout-minutes: 60
190    name: (Windows) Run Clippy and tests
191    if: github.repository_owner == 'zed-industries'
192    runs-on: hosted-windows-1
193    steps:
194      - name: Checkout repo
195        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
196        with:
197          clean: false
198
199      - name: Cache dependencies
200        uses: swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2
201        with:
202          save-if: ${{ github.ref == 'refs/heads/main' }}
203          cache-provider: "github"
204
205      - name: cargo clippy
206        # Windows can't run shell scripts, so we need to use `cargo xtask`.
207        run: cargo xtask clippy
208
209      - name: Build Zed
210        run: $env:RUSTFLAGS="-D warnings"; cargo build
211
212  bundle-mac:
213    timeout-minutes: 60
214    name: Create a macOS bundle
215    runs-on:
216      - self-hosted
217      - bundle
218    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
219    needs: [macos_tests]
220    env:
221      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
222      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
223      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
224      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
225      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
226      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
227      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
228      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
229    steps:
230      - name: Install Node
231        uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
232        with:
233          node-version: "18"
234
235      - name: Checkout repo
236        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
237        with:
238          # We need to fetch more than one commit so that `script/draft-release-notes`
239          # is able to diff between the current and previous tag.
240          #
241          # 25 was chosen arbitrarily.
242          fetch-depth: 25
243          clean: false
244
245      - name: Limit target directory size
246        run: script/clear-target-dir-if-larger-than 100
247
248      - name: Determine version and release channel
249        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
250        run: |
251          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
252          script/determine-release-channel
253
254      - name: Draft release notes
255        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
256        run: |
257          mkdir -p target/
258          # Ignore any errors that occur while drafting release notes to not fail the build.
259          script/draft-release-notes "$version" "$channel" > target/release-notes.md || true
260
261      - name: Generate license file
262        run: script/generate-licenses
263
264      - name: Create macOS app bundle
265        run: script/bundle-mac
266
267      - name: Rename single-architecture binaries
268        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
269        run: |
270          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
271          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
272
273      - name: Upload app bundle (universal) to workflow run if main branch or specific label
274        uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
275        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
276        with:
277          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
278          path: target/release/Zed.dmg
279      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
280        uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
281        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
282        with:
283          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
284          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
285
286      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
287        uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
288        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
289        with:
290          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
291          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
292
293      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
294        name: Upload app bundle to release
295        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
296        with:
297          draft: true
298          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
299          files: |
300            target/zed-remote-server-macos-x86_64.gz
301            target/zed-remote-server-macos-aarch64.gz
302            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
303            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
304            target/release/Zed.dmg
305          body_path: target/release-notes.md
306        env:
307          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
308
309  bundle-linux:
310    timeout-minutes: 60
311    name: Create a Linux bundle
312    runs-on:
313      - buildjet-16vcpu-ubuntu-2004
314    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
315    needs: [linux_tests]
316    env:
317      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
318      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
319    steps:
320      - name: Checkout repo
321        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
322        with:
323          clean: false
324
325      - name: Install Linux dependencies
326        run: ./script/linux && ./script/install-mold 2.34.0
327
328      - name: Determine version and release channel
329        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
330        run: |
331          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
332          script/determine-release-channel
333
334      - name: Create Linux .tar.gz bundle
335        run: script/bundle-linux
336
337      - name: Upload Linux bundle to workflow run if main branch or specific label
338        uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
339        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
340        with:
341          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
342          path: target/release/zed-*.tar.gz
343
344      - name: Upload app bundle to release
345        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
346        with:
347          draft: true
348          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
349          files: |
350            target/zed-remote-server-linux-x86_64.gz
351            target/release/zed-linux-x86_64.tar.gz
352          body: ""
353        env:
354          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
355
356  bundle-linux-aarch64: # this runs on ubuntu22.04
357    timeout-minutes: 60
358    name: Create arm64 Linux bundle
359    runs-on:
360      - buildjet-16vcpu-ubuntu-2204-arm
361    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
362    needs: [linux_tests]
363    env:
364      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
365      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
366    steps:
367      - name: Checkout repo
368        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
369        with:
370          clean: false
371
372      - name: Install Linux dependencies
373        run: ./script/linux
374
375      - name: Determine version and release channel
376        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
377        run: |
378          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
379          script/determine-release-channel
380
381      - name: Create and upload Linux .tar.gz bundle
382        run: script/bundle-linux
383
384      - name: Upload Linux bundle to workflow run if main branch or specific label
385        uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
386        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
387        with:
388          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
389          path: target/release/zed-*.tar.gz
390
391      - name: Upload app bundle to release
392        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
393        with:
394          draft: true
395          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
396          files: |
397            target/zed-remote-server-linux-aarch64.gz
398            target/release/zed-linux-aarch64.tar.gz
399          body: ""
400        env:
401          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}