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: Set up default .cargo/config.toml
39 run: cp ./.cargo/ci-config.toml ~/.cargo/config.toml
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: Ensure fresh merge
52 shell: bash -euxo pipefail {0}
53 run: |
54 if [ -z "$GITHUB_BASE_REF" ];
55 then
56 echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> $GITHUB_ENV
57 else
58 git checkout -B temp
59 git merge -q origin/$GITHUB_BASE_REF -m "merge main into temp"
60 echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> $GITHUB_ENV
61 fi
62
63 - uses: bufbuild/buf-setup-action@v1
64 - uses: bufbuild/buf-breaking-action@v1
65 with:
66 input: "crates/rpc/proto/"
67 against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/rpc/proto/"
68
69 macos_tests:
70 name: (macOS) Run Clippy and tests
71 runs-on:
72 - self-hosted
73 - test
74 steps:
75 - name: Checkout repo
76 uses: actions/checkout@v4
77 with:
78 clean: false
79 submodules: "recursive"
80
81 - name: cargo clippy
82 shell: bash -euxo pipefail {0}
83 run: script/clippy
84
85 - name: Run tests
86 uses: ./.github/actions/run_tests
87
88 - name: Build collab
89 run: cargo build -p collab
90
91 - name: Build other binaries
92 run: cargo build --workspace --bins --all-features
93
94 # todo!(linux): Actually run the tests
95 linux_tests:
96 name: (Linux) Run Clippy and tests
97 runs-on: ubuntu-latest
98 steps:
99 - name: Checkout repo
100 uses: actions/checkout@v4
101 with:
102 clean: false
103 submodules: "recursive"
104
105 - name: Restore from cache
106 uses: actions/cache@v3
107 with:
108 path: |
109 ~/.cargo/bin/
110 ~/.cargo/registry/index/
111 ~/.cargo/registry/cache/
112 ~/.cargo/git/db/
113 target/
114 key: ${{ runner.os }}-cargo-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
115 restore-keys: ${{ runner.os }}-cargo-${{ hashFiles('**/rust-toolchain.toml') }}-
116
117 - name: configure linux
118 shell: bash -euxo pipefail {0}
119 run: script/linux
120
121 - name: cargo clippy
122 shell: bash -euxo pipefail {0}
123 run: script/clippy
124
125 - name: Build Zed
126 run: cargo build -p zed
127 bundle:
128 name: Bundle app
129 runs-on:
130 - self-hosted
131 - bundle
132 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
133 needs: [macos_tests, linux_tests]
134 env:
135 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
136 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
137 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
138 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
139 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
140 steps:
141 - name: Install Node
142 uses: actions/setup-node@v4
143 with:
144 node-version: "18"
145
146 - name: Checkout repo
147 uses: actions/checkout@v4
148 with:
149 clean: false
150 submodules: "recursive"
151
152 - name: Limit target directory size
153 run: script/clear-target-dir-if-larger-than 100
154
155 - name: Determine version and release channel
156 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
157 run: |
158 set -eu
159
160 version=$(script/get-crate-version zed)
161 channel=$(cat crates/zed/RELEASE_CHANNEL)
162 echo "Publishing version: ${version} on release channel ${channel}"
163 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
164
165 expected_tag_name=""
166 case ${channel} in
167 stable)
168 expected_tag_name="v${version}";;
169 preview)
170 expected_tag_name="v${version}-pre";;
171 nightly)
172 expected_tag_name="v${version}-nightly";;
173 *)
174 echo "can't publish a release on channel ${channel}"
175 exit 1;;
176 esac
177 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
178 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
179 exit 1
180 fi
181
182 - name: Generate license file
183 run: script/generate-licenses
184
185 - name: Create app bundle
186 run: script/bundle
187
188 - name: Upload app bundle to workflow run if main branch or specific label
189 uses: actions/upload-artifact@v3
190 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }}
191 with:
192 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
193 path: target/release/Zed.dmg
194
195 - uses: softprops/action-gh-release@v1
196 name: Upload app bundle to release
197 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
198 with:
199 draft: true
200 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
201 files: target/release/Zed.dmg
202 body: ""
203 env:
204 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}