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