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