Files
zed/tooling/xtask/src/tasks/workflows/danger.rs
T
Ben KunkleandConrad 4adff4aa8a Use gh workflow for tests (#41384)
Follow up for: #41304

Splits CI tests (cherry-picks and PRs only for now) into separate
workflows using `gh-workflow`. Includes a couple restructures to
- run more things in parallel
- remove our previous shell script based checking to filter tests based
on files changed, instead using the builtin `paths:` workflow filters


Splitting the docs/style/rust tests & checks into separate workflows
means we lose the complete summary showing all the tests in one view,
but it's possible to re-add in the future if we go back to checking what
files changed ourselves or always run everything.

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Conrad <conrad@zed.dev>
2025-10-28 23:31:38 +00:00

54 lines
1.8 KiB
Rust

use gh_workflow::*;
use crate::tasks::workflows::steps::named;
use super::{runners, steps};
/// Generates the danger.yml workflow
pub fn danger() -> Workflow {
named::workflow()
.on(
Event::default().pull_request(PullRequest::default().add_branch("main").types([
PullRequestType::Opened,
PullRequestType::Synchronize,
PullRequestType::Reopened,
PullRequestType::Edited,
])),
)
.add_job(
"danger",
Job::default()
.cond(Expression::new(
"github.repository_owner == 'zed-industries'",
))
.runs_on(runners::LINUX_SMALL)
.add_step(steps::checkout_repo())
.add_step(steps::setup_pnpm())
.add_step(
steps::setup_node()
.add_with(("cache", "pnpm"))
.add_with(("cache-dependency-path", "script/danger/pnpm-lock.yaml")),
)
.add_step(install_deps())
.add_step(run()),
)
}
pub fn install_deps() -> Step<Run> {
named::bash("pnpm install --dir script/danger")
}
pub fn run() -> Step<Run> {
named::bash("pnpm run --dir script/danger danger ci")
// This GitHub token is not used, but the value needs to be here to prevent
// Danger from throwing an error.
.add_env(("GITHUB_TOKEN", "not_a_real_token"))
// All requests are instead proxied through an instance of
// https://github.com/maxdeviant/danger-proxy that allows Danger to securely
// authenticate with GitHub while still being able to run on PRs from forks.
.add_env((
"DANGER_GITHUB_API_BASE_URL",
"https://danger-proxy.fly.dev/github",
))
}