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  style:
 30    timeout-minutes: 60
 31    name: Check formatting and spelling
 32    runs-on:
 33      - self-hosted
 34      - test
 35    steps:
 36      - name: Checkout repo
 37        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
 38        with:
 39          clean: false
 40          fetch-depth: 0
 41
 42      - name: Remove untracked files
 43        run: git clean -df
 44
 45      - name: Check spelling
 46        run: script/check-spelling
 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@692973e3d937129bcbf40652eb9f2f61becf3332 # 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      - buildjet-16vcpu-ubuntu-2204
109    steps:
110      - name: Add Rust to the PATH
111        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
112
113      - name: Checkout repo
114        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
115        with:
116          clean: false
117
118      - name: Cache dependencies
119        uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
120        with:
121          save-if: ${{ github.ref == 'refs/heads/main' }}
122          cache-provider: "buildjet"
123
124      - name: Install Linux dependencies
125        run: ./script/linux
126
127      - name: cargo clippy
128        run: ./script/clippy
129
130      - name: Run tests
131        uses: ./.github/actions/run_tests
132
133      - name: Build Zed
134        run: cargo build -p zed
135
136  # todo(windows): Actually run the tests
137  windows_tests:
138    timeout-minutes: 60
139    name: (Windows) Run Clippy and tests
140    runs-on: hosted-windows-1
141    steps:
142      - name: Checkout repo
143        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
144        with:
145          clean: false
146
147      - name: Cache dependencies
148        uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
149        with:
150          save-if: ${{ github.ref == 'refs/heads/main' }}
151          cache-provider: "github"
152
153      - name: cargo clippy
154        # Windows can't run shell scripts, so we need to use `cargo xtask`.
155        run: cargo xtask clippy
156
157      - name: Build Zed
158        run: cargo build -p zed
159
160  bundle-mac:
161    timeout-minutes: 60
162    name: Create a macOS bundle
163    runs-on:
164      - self-hosted
165      - bundle
166    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
167    needs: [macos_tests]
168    env:
169      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
170      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
171      APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
172      APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
173      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
174      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
175      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
176      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
177    steps:
178      - name: Install Node
179        uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
180        with:
181          node-version: "18"
182
183      - name: Checkout repo
184        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
185        with:
186          # We need to fetch more than one commit so that `script/draft-release-notes`
187          # is able to diff between the current and previous tag.
188          #
189          # 25 was chosen arbitrarily.
190          fetch-depth: 25
191          clean: false
192
193      - name: Limit target directory size
194        run: script/clear-target-dir-if-larger-than 100
195
196      - name: Determine version and release channel
197        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
198        run: |
199          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
200          script/determine-release-channel
201
202      - name: Draft release notes
203        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
204        run: |
205          mkdir -p target/
206          # Ignore any errors that occur while drafting release notes to not fail the build.
207          script/draft-release-notes "$version" "$channel" > target/release-notes.md || true
208
209      - name: Generate license file
210        run: script/generate-licenses
211
212      - name: Create macOS app bundle
213        run: script/bundle-mac
214
215      - name: Rename single-architecture binaries
216        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
217        run: |
218          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
219          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
220
221      - name: Upload app bundle (universal) to workflow run if main branch or specific label
222        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
223        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
224        with:
225          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
226          path: target/release/Zed.dmg
227      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
228        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # 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 }}-aarch64.dmg
232          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
233
234      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
235        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
236        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
237        with:
238          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
239          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
240
241      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
242        name: Upload app bundle to release
243        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
244        with:
245          draft: true
246          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
247          files: |
248            target/zed-remote-server-macos-x86_64.gz
249            target/zed-remote-server-macos-aarch64.gz
250            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
251            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
252            target/release/Zed.dmg
253          body_path: target/release-notes.md
254        env:
255          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
256
257  bundle-linux:
258    timeout-minutes: 60
259    name: Create a Linux bundle
260    runs-on:
261      - buildjet-16vcpu-ubuntu-2004
262    if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
263    needs: [linux_tests]
264    env:
265      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
266      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
267    steps:
268      - name: Checkout repo
269        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
270        with:
271          clean: false
272
273      - name: Install Linux dependencies
274        run: ./script/linux && ./script/install-mold 2.34.0
275
276      - name: Determine version and release channel
277        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
278        run: |
279          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
280          script/determine-release-channel
281
282      - name: Create Linux .tar.gz bundle
283        run: script/bundle-linux
284
285      - name: Upload Linux bundle to workflow run if main branch or specific label
286        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # 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 }}-x86_64-unknown-linux-gnu.tar.gz
290          path: target/release/zed-*.tar.gz
291
292      - name: Upload app bundle to release
293        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
294        with:
295          draft: true
296          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
297          files: |
298            target/zed-remote-server-linux-x86_64.gz
299            target/release/zed-linux-x86_64.tar.gz
300          body: ""
301        env:
302          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
303
304  bundle-linux-aarch64: # this runs on ubuntu22.04
305    timeout-minutes: 60
306    name: Create arm64 Linux bundle
307    runs-on:
308      - buildjet-16vcpu-ubuntu-2204-arm
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
317        with:
318          clean: false
319
320      - name: Install Linux dependencies
321        run: ./script/linux
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 and upload 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@50769540e7f4bd5e21e526ee35c689e35e0d6874 # 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 }}-aarch64-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        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
342        with:
343          draft: true
344          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
345          files: |
346            target/zed-remote-server-linux-aarch64.gz
347            target/release/zed-linux-aarch64.tar.gz
348          body: ""
349        env:
350          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}