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