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 name: Check formatting and spelling
27 runs-on:
28 - self-hosted
29 - test
30 steps:
31 - name: Checkout repo
32 uses: actions/checkout@v4
33 with:
34 clean: false
35 submodules: "recursive"
36 fetch-depth: 0
37
38 - name: Remove untracked files
39 run: git clean -df
40
41 - name: Set up default .cargo/config.toml
42 run: cp ./.cargo/ci-config.toml ~/.cargo/config.toml
43
44 - name: Check spelling
45 run: |
46 if ! which typos > /dev/null; then
47 cargo install typos-cli
48 fi
49 typos
50
51 - name: Run style checks
52 uses: ./.github/actions/check_style
53
54 - name: Check unused dependencies
55 uses: bnjbvr/cargo-machete@main
56
57 - name: Ensure fresh merge
58 shell: bash -euxo pipefail {0}
59 run: |
60 if [ -z "$GITHUB_BASE_REF" ];
61 then
62 echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> $GITHUB_ENV
63 else
64 git checkout -B temp
65 git merge -q origin/$GITHUB_BASE_REF -m "merge main into temp"
66 echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> $GITHUB_ENV
67 fi
68
69 - uses: bufbuild/buf-setup-action@v1
70 with:
71 version: v1.29.0
72 - uses: bufbuild/buf-breaking-action@v1
73 with:
74 input: "crates/rpc/proto/"
75 against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/rpc/proto/"
76
77 macos_tests:
78 name: (macOS) Run Clippy and tests
79 runs-on:
80 - self-hosted
81 - test
82 steps:
83 - name: Checkout repo
84 uses: actions/checkout@v4
85 with:
86 clean: false
87 submodules: "recursive"
88
89 - name: Install cargo-component
90 run: |
91 if ! which cargo-component > /dev/null; then
92 cargo install cargo-component
93 fi
94
95 - name: cargo clippy
96 run: cargo xtask clippy
97
98 - name: Run tests
99 uses: ./.github/actions/run_tests
100
101 - name: Build collab
102 run: cargo build -p collab
103
104 - name: Build other binaries and features
105 run: cargo build --workspace --bins --all-features; cargo check -p gpui --features "macos-blade"
106
107 # todo(linux): Actually run the tests
108 linux_tests:
109 name: (Linux) Run Clippy and tests
110 runs-on: ubuntu-latest
111 steps:
112 - name: Checkout repo
113 uses: actions/checkout@v4
114 with:
115 clean: false
116 submodules: "recursive"
117
118 - name: Cache dependencies
119 uses: swatinem/rust-cache@v2
120 with:
121 save-if: ${{ github.ref == 'refs/heads/main' }}
122
123 - name: configure linux
124 shell: bash -euxo pipefail {0}
125 run: script/linux
126
127 - name: cargo clippy
128 run: cargo xtask clippy
129
130 - name: Build Zed
131 run: cargo build -p zed
132
133 # todo(windows): Actually run the tests
134 windows_tests:
135 name: (Windows) Run Clippy and tests
136 runs-on: windows-latest
137 steps:
138 - name: Checkout repo
139 uses: actions/checkout@v4
140 with:
141 clean: false
142 submodules: "recursive"
143
144 - name: Cache dependencies
145 uses: swatinem/rust-cache@v2
146 with:
147 save-if: ${{ github.ref == 'refs/heads/main' }}
148
149 - name: cargo clippy
150 run: cargo xtask clippy
151
152 - name: Build Zed
153 run: cargo build -p zed
154
155 bundle:
156 name: Bundle macOS app
157 runs-on:
158 - self-hosted
159 - bundle
160 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
161 needs: [macos_tests]
162 env:
163 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
164 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
165 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
166 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
167 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
168 DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
169 DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
170 steps:
171 - name: Install Node
172 uses: actions/setup-node@v4
173 with:
174 node-version: "18"
175
176 - name: Checkout repo
177 uses: actions/checkout@v4
178 with:
179 clean: false
180 submodules: "recursive"
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
212 - name: Generate license file
213 run: script/generate-licenses
214
215 - name: Create app bundle
216 run: script/bundle
217
218 - name: Upload app bundle to workflow run if main branch or specific label
219 uses: actions/upload-artifact@v3
220 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
221 with:
222 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
223 path: target/release/Zed.dmg
224
225 - uses: softprops/action-gh-release@v1
226 name: Upload app bundle to release
227 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
228 with:
229 draft: true
230 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
231 files: target/release/Zed.dmg
232 body: ""
233 env:
234 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}