Skip to content

Commit 7a3c1aa

Browse files
committed
fix: move CI generation logic to tests
1 parent f0f629e commit 7a3c1aa

File tree

3 files changed

+73
-69
lines changed

3 files changed

+73
-69
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ documentation = "https://docs.rs/tailcall-chunk"
99

1010
[dependencies]
1111

12-
[build-dependencies]
12+
[dev-dependencies]
1313
gh-workflow = "0.4"

build.rs

Lines changed: 0 additions & 68 deletions
This file was deleted.

tests/ci.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#[cfg(test)]
2+
mod ci {
3+
use gh_workflow::*;
4+
use release_plz::Release;
5+
use toolchain::Toolchain;
6+
7+
#[test]
8+
fn ci() {
9+
let flags = RustFlags::deny("warnings");
10+
11+
let build = Job::new("Build and Test")
12+
.add_step(Step::checkout())
13+
.add_step(
14+
Toolchain::default()
15+
.add_stable()
16+
.add_nightly()
17+
.add_clippy()
18+
.add_fmt(),
19+
)
20+
.add_step(
21+
Cargo::new("test")
22+
.args("--all-features --workspace")
23+
.name("Cargo Test"),
24+
)
25+
.add_step(
26+
Cargo::new("fmt")
27+
.nightly()
28+
.args("--check")
29+
.name("Cargo Fmt"),
30+
)
31+
.add_step(
32+
Cargo::new("clippy")
33+
.nightly()
34+
.args("--all-features --workspace -- -D warnings")
35+
.name("Cargo Clippy"),
36+
);
37+
38+
let event = Event::default()
39+
.push(Push::default().add_branch("main"))
40+
.pull_request_target(
41+
PullRequestTarget::default()
42+
.add_type(PullRequestType::Opened)
43+
.add_type(PullRequestType::Synchronize)
44+
.add_type(PullRequestType::Reopened)
45+
.add_branch("main"),
46+
);
47+
48+
let permissions = Permissions::default()
49+
.pull_requests(Level::Write)
50+
.packages(Level::Write)
51+
.contents(Level::Write);
52+
53+
let release = Job::new("Release")
54+
.needs("build")
55+
.add_env(Env::github())
56+
.add_env(Env::new(
57+
"CARGO_REGISTRY_TOKEN",
58+
"${{ secrets.CARGO_REGISTRY_TOKEN }}",
59+
))
60+
.permissions(permissions)
61+
.add_step(Step::checkout())
62+
.add_step(Release::default());
63+
64+
Workflow::new("Build and Test")
65+
.add_env(flags)
66+
.on(event)
67+
.add_job("build", build)
68+
.add_job("release", release)
69+
.generate()
70+
.unwrap();
71+
}
72+
}

0 commit comments

Comments
 (0)