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