Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Check remote server on each commit (#64283)

Kirill Bulatov70a74b8725fa
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index 2f1b2956499..09726ed3ed7 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -842,6 +842,112 @@ jobs:
min-severity: high
version: latest
timeout-minutes: 60
+ check_remote_server_linux_x86_64:
+ needs:
+ - orchestrate
+ if: needs.orchestrate.outputs.run_tests == 'true'
+ runs-on: namespace-profile-8x16-ubuntu-2204
+ env:
+ CC: clang
+ CXX: clang++
+ CC_x86_64_unknown_linux_musl: musl-gcc
+ CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+crt-static
+ steps:
+ - name: steps::harden_runner
+ uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411
+ with:
+ egress-policy: audit
+ - name: steps::checkout_repo
+ uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
+ with:
+ clean: false
+ - name: steps::cache_rust_dependencies_namespace
+ uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
+ with:
+ cache: rust
+ path: ~/.rustup
+ - name: steps::setup_linux
+ run: ./script/linux
+ - name: run_tests::check_remote_server
+ run: rustup target add x86_64-unknown-linux-musl
+ - name: steps::setup_sccache
+ run: ./script/setup-sccache
+ env:
+ R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
+ R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
+ R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
+ SCCACHE_BUCKET: sccache-zed
+ - name: run_tests::check_remote_server
+ run: cargo --config .cargo/ci-config.toml check --locked --release --package remote_server --target x86_64-unknown-linux-musl
+ - name: steps::show_sccache_stats
+ run: sccache --show-stats || true
+ timeout-minutes: 60
+ check_remote_server_mac_aarch64:
+ needs:
+ - orchestrate
+ if: needs.orchestrate.outputs.run_tests == 'true'
+ runs-on: namespace-profile-mac-large
+ steps:
+ - name: steps::checkout_repo
+ uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
+ with:
+ clean: false
+ - name: steps::cache_rust_dependencies_namespace
+ uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
+ with:
+ cache: rust
+ path: ~/.rustup
+ - name: run_tests::check_remote_server
+ run: rustup target add aarch64-apple-darwin
+ - name: steps::setup_sccache
+ run: ./script/setup-sccache
+ env:
+ R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
+ R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
+ R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
+ SCCACHE_BUCKET: sccache-zed
+ - name: run_tests::check_remote_server
+ run: cargo --config .cargo/ci-config.toml check --locked --release --package remote_server --target aarch64-apple-darwin
+ - name: steps::show_sccache_stats
+ run: sccache --show-stats || true
+ timeout-minutes: 60
+ check_remote_server_windows_x86_64:
+ needs:
+ - orchestrate
+ if: needs.orchestrate.outputs.run_tests == 'true'
+ runs-on: self-32vcpu-windows-2022
+ steps:
+ - name: steps::checkout_repo
+ uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
+ with:
+ clean: false
+ - name: run_tests::check_remote_server
+ run: rustup target add x86_64-pc-windows-msvc
+ shell: pwsh
+ - name: steps::setup_sccache
+ run: ./script/setup-sccache.ps1
+ shell: pwsh
+ env:
+ R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
+ R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
+ R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
+ SCCACHE_BUCKET: sccache-zed
+ - name: run_tests::check_remote_server
+ run: |
+ $hostArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
+ "X64" { "amd64" }
+ "Arm64" { "arm64" }
+ default { throw "Unsupported architecture" }
+ }
+ Push-Location
+ & "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch $hostArchitecture
+ Pop-Location
+ cargo --config .cargo/ci-config.toml check --locked --release --package remote_server --target x86_64-pc-windows-msvc
+ shell: pwsh
+ - name: steps::show_sccache_stats
+ run: if ($env:RUSTC_WRAPPER) { & $env:RUSTC_WRAPPER --show-stats }; exit 0
+ shell: pwsh
+ timeout-minutes: 60
check_postgres_and_protobuf_migrations:
needs:
- orchestrate
@@ -921,6 +1027,9 @@ jobs:
- check_docs
- check_licenses
- check_scripts
+ - check_remote_server_linux_x86_64
+ - check_remote_server_mac_aarch64
+ - check_remote_server_windows_x86_64
- extension_tests
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions') && always()
runs-on: namespace-profile-2x4-ubuntu-2404
@@ -953,6 +1062,9 @@ jobs:
check_result "check_docs" "$RESULT_CHECK_DOCS"
check_result "check_licenses" "$RESULT_CHECK_LICENSES"
check_result "check_scripts" "$RESULT_CHECK_SCRIPTS"
+ check_result "check_remote_server_linux_x86_64" "$RESULT_CHECK_REMOTE_SERVER_LINUX_X86_64"
+ check_result "check_remote_server_mac_aarch64" "$RESULT_CHECK_REMOTE_SERVER_MAC_AARCH64"
+ check_result "check_remote_server_windows_x86_64" "$RESULT_CHECK_REMOTE_SERVER_WINDOWS_X86_64"
check_result "extension_tests" "$RESULT_EXTENSION_TESTS"
exit $EXIT_CODE
@@ -975,6 +1087,9 @@ jobs:
RESULT_CHECK_DOCS: ${{ needs.check_docs.result }}
RESULT_CHECK_LICENSES: ${{ needs.check_licenses.result }}
RESULT_CHECK_SCRIPTS: ${{ needs.check_scripts.result }}
+ RESULT_CHECK_REMOTE_SERVER_LINUX_X86_64: ${{ needs.check_remote_server_linux_x86_64.result }}
+ RESULT_CHECK_REMOTE_SERVER_MAC_AARCH64: ${{ needs.check_remote_server_mac_aarch64.result }}
+ RESULT_CHECK_REMOTE_SERVER_WINDOWS_X86_64: ${{ needs.check_remote_server_windows_x86_64.result }}
RESULT_EXTENSION_TESTS: ${{ needs.extension_tests.result }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
diff --git a/tooling/xtask/src/tasks/workflows/run_bundling.rs b/tooling/xtask/src/tasks/workflows/run_bundling.rs
index 2bba6c215f8..6fc34c9d775 100644
--- a/tooling/xtask/src/tasks/workflows/run_bundling.rs
+++ b/tooling/xtask/src/tasks/workflows/run_bundling.rs
@@ -77,9 +77,11 @@ pub(crate) fn bundle_mac(
}
pub fn bundle_mac(arch: Arch) -> Step<Run> {
- named::bash(&format!("./script/bundle-mac {arch}-apple-darwin"))
+ let target = Platform::Mac.target_triple(arch);
+ named::bash(&format!("./script/bundle-mac {target}"))
}
let platform = Platform::Mac;
+ let target = platform.target_triple(arch);
let artifact_name = match arch {
Arch::X86_64 => assets::MAC_X86_64,
Arch::AARCH64 => assets::MAC_AARCH64,
@@ -104,7 +106,7 @@ pub(crate) fn bundle_mac(
.add_step(print_macos_toolchain())
.add_step(bundle_mac(arch))
.add_step(upload_artifact(&format!(
- "target/{arch}-apple-darwin/release/{artifact_name}"
+ "target/{target}/release/{artifact_name}"
)))
.add_step(upload_artifact(&format!(
"target/{remote_server_artifact_name}"
diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs
index d5b633b6e20..2dd40c45e4c 100644
--- a/tooling/xtask/src/tasks/workflows/run_tests.rs
+++ b/tooling/xtask/src/tasks/workflows/run_tests.rs
@@ -92,6 +92,17 @@ pub(crate) fn run_tests() -> Workflow {
.then(check_licenses()),
should_check_scripts.and_always().then(check_scripts(true)),
];
+ for (platform, arch) in [
+ (Platform::Linux, Arch::X86_64),
+ (Platform::Mac, Arch::AARCH64),
+ (Platform::Windows, Arch::X86_64),
+ ] {
+ jobs.push(
+ should_run_tests
+ .and_always()
+ .then(check_remote_server(platform, arch)),
+ );
+ }
let ext_tests = extension_tests();
let tests_pass = tests_pass(&jobs, &[&ext_tests.name]);
@@ -522,6 +533,67 @@ fn check_wasm() -> NamedJob {
)
}
+fn check_remote_server(platform: Platform, arch: Arch) -> NamedJob {
+ let target = platform.target_triple(arch);
+ let runner = match (platform, arch) {
+ (Platform::Linux, Arch::X86_64) => runners::LINUX_LARGE,
+ (Platform::Linux, Arch::AARCH64) => runners::LINUX_ARM_BUNDLER,
+ (Platform::Mac, _) => runners::MAC_DEFAULT,
+ (Platform::Windows, _) => runners::WINDOWS_DEFAULT,
+ };
+ let command = format!(
+ "cargo --config .cargo/ci-config.toml check --locked --release --package remote_server --target {target}"
+ );
+ let check = match platform {
+ Platform::Windows => {
+ let architecture = match arch {
+ Arch::X86_64 => "amd64",
+ Arch::AARCH64 => "arm64",
+ };
+ named::pwsh(&formatdoc! {r#"
+ $hostArchitecture = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {{
+ "X64" {{ "amd64" }}
+ "Arm64" {{ "arm64" }}
+ default {{ throw "Unsupported architecture" }}
+ }}
+ Push-Location
+ & "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" -Arch {architecture} -HostArch $hostArchitecture
+ Pop-Location
+ {command}
+ "#})
+ }
+ Platform::Linux | Platform::Mac => named::bash(command),
+ };
+ NamedJob {
+ name: format!("check_remote_server_{platform}_{arch}"),
+ job: release_job(&[])
+ .runs_on(runner)
+ .when(platform == Platform::Linux, |job| {
+ use_clang(job)
+ .add_env((format!("CC_{}", target.replace('-', "_")), "musl-gcc"))
+ .add_env((
+ format!(
+ "CARGO_TARGET_{}_RUSTFLAGS",
+ target.replace('-', "_").to_uppercase(),
+ ),
+ "-C target-feature=+crt-static",
+ ))
+ .add_step(steps::harden_runner())
+ })
+ .add_step(steps::checkout_repo())
+ .when(platform != Platform::Windows, |job| {
+ job.add_step(steps::cache_rust_dependencies_namespace())
+ })
+ .when(platform == Platform::Linux, |job| {
+ job.add_step(steps::setup_linux())
+ })
+ .add_step(named::run(platform, &format!("rustup target add {target}")))
+ .add_step(steps::setup_sccache(platform))
+ .add_step(check)
+ .add_step(steps::show_sccache_stats(platform)),
+ }
+}
+
fn check_workspace_binaries() -> NamedJob {
named::job(use_clang(
release_job(&[])
@@ -540,9 +612,8 @@ fn check_workspace_binaries() -> NamedJob {
}
pub(crate) fn clippy(platform: Platform, arch: Option<Arch>, harden: bool) -> NamedJob {
- let target = arch.map(|arch| match (platform, arch) {
- (Platform::Mac, Arch::X86_64) => "x86_64-apple-darwin",
- (Platform::Mac, Arch::AARCH64) => "aarch64-apple-darwin",
+ let target = arch.map(|arch| match platform {
+ Platform::Mac => platform.target_triple(arch),
_ => unimplemented!("cross-arch clippy not supported for {platform}/{arch}"),
});
let runner = match platform {
diff --git a/tooling/xtask/src/tasks/workflows/runners.rs b/tooling/xtask/src/tasks/workflows/runners.rs
index bc4b17aaf69..82dbbe7a7ac 100644
--- a/tooling/xtask/src/tasks/workflows/runners.rs
+++ b/tooling/xtask/src/tasks/workflows/runners.rs
@@ -53,6 +53,19 @@ pub enum Platform {
Mac,
}
+impl Platform {
+ pub fn target_triple(self, arch: Arch) -> &'static str {
+ match (self, arch) {
+ (Self::Linux, Arch::X86_64) => "x86_64-unknown-linux-musl",
+ (Self::Linux, Arch::AARCH64) => "aarch64-unknown-linux-musl",
+ (Self::Mac, Arch::X86_64) => "x86_64-apple-darwin",
+ (Self::Mac, Arch::AARCH64) => "aarch64-apple-darwin",
+ (Self::Windows, Arch::X86_64) => "x86_64-pc-windows-msvc",
+ (Self::Windows, Arch::AARCH64) => "aarch64-pc-windows-msvc",
+ }
+ }
+}
+
impl std::fmt::Display for Platform {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {