Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
extension_ci: Increase fetch depth for tests job (#49389)
Finn Evers9aa6b1481eff
diff --git a/.github/workflows/autofix_pr.yml b/.github/workflows/autofix_pr.ymlindex 87abbb86a03..60cc66294af 100644--- a/.github/workflows/autofix_pr.yml+++ b/.github/workflows/autofix_pr.yml@@ -98,7 +98,7 @@ jobs:with:app-id: ${{ secrets.ZED_ZIPPY_APP_ID }}private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }}- - name: steps::checkout_repo_with_token+ - name: steps::checkout_repouses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:clean: falsediff --git a/.github/workflows/bump_patch_version.yml b/.github/workflows/bump_patch_version.ymlindex 68bc37e5c75..480d8b0ada9 100644--- a/.github/workflows/bump_patch_version.yml+++ b/.github/workflows/bump_patch_version.yml@@ -19,7 +19,7 @@ jobs:with:app-id: ${{ secrets.ZED_ZIPPY_APP_ID }}private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }}- - name: steps::checkout_repo_with_token+ - name: steps::checkout_repouses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:clean: falsediff --git a/.github/workflows/extension_tests.yml b/.github/workflows/extension_tests.ymlindex 76bbc423f66..4393ca6e445 100644--- a/.github/workflows/extension_tests.yml+++ b/.github/workflows/extension_tests.yml@@ -86,6 +86,7 @@ jobs:uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:clean: false+ fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }}- id: cache-zed-extension-cliname: extension_tests::cache_zed_extension_cliuses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830diff --git a/.github/workflows/extension_workflow_rollout.yml b/.github/workflows/extension_workflow_rollout.ymlindex 29aa8f781ce..d8eae61c116 100644--- a/.github/workflows/extension_workflow_rollout.yml+++ b/.github/workflows/extension_workflow_rollout.yml@@ -56,15 +56,15 @@ jobs:uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:clean: false+ fetch-depth: 0path: zed- fetch-depth: '0'- - name: steps::checkout_repo_with_token+ - name: checkout_extension_repouses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:clean: falsetoken: ${{ steps.generate-token.outputs.token }}- repository: zed-extensions/${{ matrix.repo }}path: extension+ repository: zed-extensions/${{ matrix.repo }}- id: prev-tagname: extension_workflow_rollout::rollout_workflows_to_extension::get_previous_tag_commitrun: |@@ -167,12 +167,12 @@ jobs:app-id: ${{ secrets.ZED_ZIPPY_APP_ID }}private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }}permission-contents: write- - name: steps::checkout_repo_with_token+ - name: steps::checkout_repouses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:clean: false+ fetch-depth: 0token: ${{ steps.generate-token.outputs.token }}- fetch-depth: '0'- name: extension_workflow_rollout::create_rollout_tag::configure_gitrun: |git config user.name "zed-zippy[bot]"diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.ymlindex fb2e74aaedb..72693eb8939 100644--- a/.github/workflows/run_tests.yml+++ b/.github/workflows/run_tests.yml@@ -605,9 +605,8 @@ jobs:- name: steps::checkout_repouses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683with:+ clean: falsefetch-depth: 0- - name: run_tests::check_postgres_and_protobuf_migrations::remove_untracked_files- run: git clean -df- name: run_tests::check_postgres_and_protobuf_migrations::ensure_fresh_mergerun: |if [ -z "$GITHUB_BASE_REF" ];diff --git a/tooling/xtask/src/tasks/workflows/autofix_pr.rs b/tooling/xtask/src/tasks/workflows/autofix_pr.rsindex e1e93e45fc8..c2c89b7cd05 100644--- a/tooling/xtask/src/tasks/workflows/autofix_pr.rs+++ b/tooling/xtask/src/tasks/workflows/autofix_pr.rs@@ -169,7 +169,7 @@ fn commit_changes(pr_number: &WorkflowInput, autofix_job: &NamedJob) -> NamedJobautofix_job.name))).add_step(authenticate)- .add_step(steps::checkout_repo_with_token(&token))+ .add_step(steps::checkout_repo().with_token(&token)).add_step(checkout_pr(pr_number, &token)).add_step(download_patch_artifact()).add_step(apply_patch())diff --git a/tooling/xtask/src/tasks/workflows/bump_patch_version.rs b/tooling/xtask/src/tasks/workflows/bump_patch_version.rsindex cc6229587bf..5ef149be293 100644--- a/tooling/xtask/src/tasks/workflows/bump_patch_version.rs+++ b/tooling/xtask/src/tasks/workflows/bump_patch_version.rs@@ -2,7 +2,7 @@ use gh_workflow::*;use crate::tasks::workflows::{runners,- steps::{self, named},+ steps::{self, CheckoutStep, named},vars::{StepOutput, WorkflowInput},};@@ -22,8 +22,10 @@ pub fn bump_patch_version() -> Workflow {}fn run_bump_patch_version(branch: &WorkflowInput) -> steps::NamedJob {- fn checkout_branch(branch: &WorkflowInput, token: &StepOutput) -> Step<Use> {- steps::checkout_repo_with_token(token).add_with(("ref", branch.to_string()))+ fn checkout_branch(branch: &WorkflowInput, token: &StepOutput) -> CheckoutStep {+ steps::checkout_repo()+ .with_token(token)+ .with_ref(branch.to_string())}fn bump_patch_version(token: &StepOutput) -> Step<Run> {diff --git a/tooling/xtask/src/tasks/workflows/deploy_collab.rs b/tooling/xtask/src/tasks/workflows/deploy_collab.rsindex 17d48d93fca..58212118c7b 100644--- a/tooling/xtask/src/tasks/workflows/deploy_collab.rs+++ b/tooling/xtask/src/tasks/workflows/deploy_collab.rs@@ -28,7 +28,7 @@ fn style() -> NamedJob {.name("Check formatting and Clippy lints").with_repository_owner_guard().runs_on(runners::LINUX_XL)- .add_step(steps::checkout_repo().add_with(("fetch-depth", 0)))+ .add_step(steps::checkout_repo().with_full_history()).add_step(steps::setup_cargo_config(Platform::Linux)).add_step(steps::cache_rust_dependencies_namespace()).map(steps::install_linux_dependencies)@@ -58,7 +58,7 @@ fn tests(deps: &[&NamedJob]) -> NamedJob {--health-retries 10",),)- .add_step(steps::checkout_repo().add_with(("fetch-depth", 0)))+ .add_step(steps::checkout_repo().with_full_history()).add_step(steps::setup_cargo_config(Platform::Linux)).add_step(steps::cache_rust_dependencies_namespace()).map(steps::install_linux_dependencies)diff --git a/tooling/xtask/src/tasks/workflows/extension_bump.rs b/tooling/xtask/src/tasks/workflows/extension_bump.rsindex d19ae9bdedd..fcc73bce391 100644--- a/tooling/xtask/src/tasks/workflows/extension_bump.rs+++ b/tooling/xtask/src/tasks/workflows/extension_bump.rs@@ -95,7 +95,7 @@ fn check_version_changed() -> (NamedJob, StepOutput, StepOutput) {]).runs_on(runners::LINUX_SMALL).timeout_minutes(1u32)- .add_step(steps::checkout_repo().add_with(("fetch-depth", 0)))+ .add_step(steps::checkout_repo().with_full_history()).add_step(compare_versions);(named::job(job), version_changed, current_version)diff --git a/tooling/xtask/src/tasks/workflows/extension_tests.rs b/tooling/xtask/src/tasks/workflows/extension_tests.rsindex 02ed264682b..3d7f96157b5 100644--- a/tooling/xtask/src/tasks/workflows/extension_tests.rs+++ b/tooling/xtask/src/tasks/workflows/extension_tests.rs@@ -85,7 +85,7 @@ pub(crate) fn check_extension() -> NamedJob {.with_repository_owner_guard().runs_on(runners::LINUX_LARGE_RAM).timeout_minutes(4u32)- .add_step(steps::checkout_repo())+ .add_step(steps::checkout_repo().with_deep_history_on_non_main()).add_step(cache_download).add_step(download_zed_extension_cli(cache_hit)).add_step(check())diff --git a/tooling/xtask/src/tasks/workflows/extension_workflow_rollout.rs b/tooling/xtask/src/tasks/workflows/extension_workflow_rollout.rsindex a9fcd6d9467..bcee9be9a27 100644--- a/tooling/xtask/src/tasks/workflows/extension_workflow_rollout.rs+++ b/tooling/xtask/src/tasks/workflows/extension_workflow_rollout.rs@@ -5,6 +5,7 @@ use indoc::formatdoc;use indoc::indoc;use serde_json::json;+use crate::tasks::workflows::steps::CheckoutStep;use crate::tasks::workflows::{extension_bump::{RepositoryTarget, generate_token},runners,@@ -67,17 +68,19 @@ fn fetch_extension_repos() -> NamedJob {}fn rollout_workflows_to_extension(fetch_repos_job: &NamedJob) -> NamedJob {- fn checkout_zed_repo() -> Step<Use> {+ fn checkout_zed_repo() -> CheckoutStep {steps::checkout_repo()- .name("checkout_zed_repo")- .add_with(("path", "zed"))- .add_with(("fetch-depth", "0"))+ .with_full_history()+ .with_path("zed")+ .with_custom_name("checkout_zed_repo")}- fn checkout_extension_repo(token: &StepOutput) -> Step<Use> {- steps::checkout_repo_with_token(token)- .add_with(("repository", "zed-extensions/${{ matrix.repo }}"))- .add_with(("path", "extension"))+ fn checkout_extension_repo(token: &StepOutput) -> CheckoutStep {+ steps::checkout_repo()+ .with_custom_name("checkout_extension_repo")+ .with_token(token)+ .with_repository("zed-extensions/${{ matrix.repo }}")+ .with_path("extension")}fn get_previous_tag_commit() -> (Step<Run>, StepOutput) {@@ -253,8 +256,8 @@ fn rollout_workflows_to_extension(fetch_repos_job: &NamedJob) -> NamedJob {}fn create_rollout_tag(rollout_job: &NamedJob) -> NamedJob {- fn checkout_zed_repo(token: &StepOutput) -> Step<Use> {- steps::checkout_repo_with_token(token).add_with(("fetch-depth", "0"))+ fn checkout_zed_repo(token: &StepOutput) -> CheckoutStep {+ steps::checkout_repo().with_full_history().with_token(token)}fn update_rollout_tag() -> Step<Run> {diff --git a/tooling/xtask/src/tasks/workflows/release.rs b/tooling/xtask/src/tasks/workflows/release.rsindex 5ac21efbfc3..8241fc58f08 100644--- a/tooling/xtask/src/tasks/workflows/release.rs+++ b/tooling/xtask/src/tasks/workflows/release.rs@@ -254,9 +254,8 @@ fn create_draft_release() -> NamedJob {// 25 was chosen arbitrarily..add_step(steps::checkout_repo()- .add_with(("fetch-depth", 25))- .add_with(("clean", false))- .add_with(("ref", "${{ github.ref }}")),+ .with_custom_fetch_depth(25)+ .with_ref("${{ github.ref }}"),).add_step(steps::script("script/determine-release-channel")).add_step(steps::script("mkdir -p target/"))diff --git a/tooling/xtask/src/tasks/workflows/release_nightly.rs b/tooling/xtask/src/tasks/workflows/release_nightly.rsindex f814a153eb9..bcae94d08d1 100644--- a/tooling/xtask/src/tasks/workflows/release_nightly.rs+++ b/tooling/xtask/src/tasks/workflows/release_nightly.rs@@ -72,11 +72,7 @@ pub fn release_nightly() -> Workflow {fn check_style() -> NamedJob {let job = release_job(&[]).runs_on(runners::MAC_DEFAULT)- .add_step(- steps::checkout_repo()- .add_with(("clean", false))- .add_with(("fetch-depth", 0)),- )+ .add_step(steps::checkout_repo().with_full_history()).add_step(steps::cargo_fmt()).add_step(steps::script("./script/clippy"));@@ -112,7 +108,7 @@ fn update_nightly_tag_job(bundle: &ReleaseBundleJobs) -> NamedJob {name: "update_nightly_tag".to_owned(),job: steps::release_job(&bundle.jobs()).runs_on(runners::LINUX_MEDIUM)- .add_step(steps::checkout_repo().add_with(("fetch-depth", 0)))+ .add_step(steps::checkout_repo().with_full_history()).add_step(download_workflow_artifacts()).add_step(steps::script("ls -lR ./artifacts")).add_step(prep_release_artifacts())diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rsindex 393675e9830..f141c92e1f1 100644--- a/tooling/xtask/src/tasks/workflows/run_tests.rs+++ b/tooling/xtask/src/tasks/workflows/run_tests.rs@@ -219,10 +219,7 @@ fn orchestrate_impl(rules: &[&PathCondition], include_package_filter: bool) -> N.runs_on(runners::LINUX_SMALL).with_repository_owner_guard().outputs(outputs)- .add_step(steps::checkout_repo().add_with((- "fetch-depth",- "${{ github.ref == 'refs/heads/main' && 2 || 350 }}",- )))+ .add_step(steps::checkout_repo().with_deep_history_on_non_main()).add_step(Step::new(step_name.clone()).run(script).id(step_name));NamedJob { name, job }@@ -442,10 +439,6 @@ fn run_platform_tests_impl(platform: Platform, filter_packages: bool) -> NamedJo}pub(crate) fn check_postgres_and_protobuf_migrations() -> NamedJob {- fn remove_untracked_files() -> Step<Run> {- named::bash("git clean -df")- }-fn ensure_fresh_merge() -> Step<Run> {named::bash(indoc::indoc! {r#"if [ -z "$GITHUB_BASE_REF" ];@@ -477,8 +470,7 @@ pub(crate) fn check_postgres_and_protobuf_migrations() -> NamedJob {.add_env(("GIT_AUTHOR_EMAIL", "[email protected]")).add_env(("GIT_COMMITTER_NAME", "Protobuf Action")).add_env(("GIT_COMMITTER_EMAIL", "[email protected]"))- .add_step(steps::checkout_repo().with(("fetch-depth", 0))) // fetch full history- .add_step(remove_untracked_files())+ .add_step(steps::checkout_repo().with_full_history()).add_step(ensure_fresh_merge()).add_step(bufbuild_setup_action()).add_step(bufbuild_breaking_action()),diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rsindex 8fffd1b0f46..19aea15ddcf 100644--- a/tooling/xtask/src/tasks/workflows/steps.rs+++ b/tooling/xtask/src/tasks/workflows/steps.rs@@ -1,4 +1,5 @@use gh_workflow::*;+use serde_json::Value;use crate::tasks::workflows::{runners::Platform, vars, vars::StepOutput};@@ -49,25 +50,103 @@ impl From<Nextest> for Step<Run> {}}-pub fn checkout_repo() -> Step<Use> {- named::uses(- "actions",- "checkout",- "11bd71901bbe5b1630ceea73d27597364c9af683", // v4- )- // prevent checkout action from running `git clean -ffdx` which- // would delete the target directory- .add_with(("clean", false))+#[derive(Default)]+enum FetchDepth {+ #[default]+ Shallow,+ Full,+ Custom(serde_json::Value),}-pub fn checkout_repo_with_token(token: &StepOutput) -> Step<Use> {- named::uses(- "actions",- "checkout",- "11bd71901bbe5b1630ceea73d27597364c9af683", // v4- )- .add_with(("clean", false))- .add_with(("token", token.to_string()))+#[derive(Default)]+pub(crate) struct CheckoutStep {+ fetch_depth: FetchDepth,+ name: Option<String>,+ token: Option<String>,+ path: Option<String>,+ repository: Option<String>,+ ref_: Option<String>,+}++impl CheckoutStep {+ pub fn with_full_history(mut self) -> Self {+ self.fetch_depth = FetchDepth::Full;+ self+ }++ pub fn with_custom_name(mut self, name: &str) -> Self {+ self.name = Some(name.to_string());+ self+ }++ pub fn with_custom_fetch_depth(mut self, fetch_depth: impl Into<Value>) -> Self {+ self.fetch_depth = FetchDepth::Custom(fetch_depth.into());+ self+ }++ /// Sets `fetch-depth` to `2` on the main branch and `350` on all other branches.+ pub fn with_deep_history_on_non_main(self) -> Self {+ self.with_custom_fetch_depth("${{ github.ref == 'refs/heads/main' && 2 || 350 }}")+ }++ pub fn with_token(mut self, token: &StepOutput) -> Self {+ self.token = Some(token.to_string());+ self+ }++ pub fn with_path(mut self, path: &str) -> Self {+ self.path = Some(path.to_string());+ self+ }++ pub fn with_repository(mut self, repository: &str) -> Self {+ self.repository = Some(repository.to_string());+ self+ }++ pub fn with_ref(mut self, ref_: impl ToString) -> Self {+ self.ref_ = Some(ref_.to_string());+ self+ }+}++impl From<CheckoutStep> for Step<Use> {+ fn from(value: CheckoutStep) -> Self {+ Step::new(value.name.unwrap_or("steps::checkout_repo".to_string()))+ .uses(+ "actions",+ "checkout",+ "11bd71901bbe5b1630ceea73d27597364c9af683", // v4+ )+ // prevent checkout action from running `git clean -ffdx` which+ // would delete the target directory+ .add_with(("clean", false))+ .map(|step| match value.fetch_depth {+ FetchDepth::Shallow => step,+ FetchDepth::Full => step.add_with(("fetch-depth", 0)),+ FetchDepth::Custom(depth) => step.add_with(("fetch-depth", depth)),+ })+ .map(|step| match value.token {+ Some(token) => step.add_with(("token", token)),+ None => step,+ })+ .map(|step| match value.path {+ Some(path) => step.add_with(("path", path)),+ None => step,+ })+ .map(|step| match value.repository {+ Some(repository) => step.add_with(("repository", repository)),+ None => step,+ })+ .map(|step| match value.ref_ {+ Some(ref_) => step.add_with(("ref", ref_)),+ None => step,+ })+ }+}++pub fn checkout_repo() -> CheckoutStep {+ CheckoutStep::default()}pub fn setup_pnpm() -> Step<Use> {@@ -270,6 +349,7 @@ pub(crate) fn dependant_job(deps: &[&NamedJob]) -> Job {impl FluentBuilder for Job {}impl FluentBuilder for Workflow {}impl FluentBuilder for Input {}+impl<T> FluentBuilder for Step<T> {}/// A helper trait for building complex objects with imperative conditionals in a fluent style./// Copied from GPUI to avoid adding GPUI as dependency