ci.yml

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