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