Skip to content

Commit a1ac5de

Browse files
committed
chore: generate rust-sdk github action with build.rs
1 parent 9d491dc commit a1ac5de

File tree

3 files changed

+91
-21
lines changed

3 files changed

+91
-21
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,47 @@
1-
name: Test
1+
# -------------------------------------------------------------------
2+
# ------------------------------- WARNING ---------------------------
3+
# -------------------------------------------------------------------
4+
#
5+
# This file was automatically generated by gh-workflows using the
6+
# gh-workflow-gen bin. You should add and commit this file to your
7+
# git repository. **DO NOT EDIT THIS FILE BY HAND!** Any manual changes
8+
# will be lost if the file is regenerated.
9+
#
10+
# To make modifications, update your `build.rs` configuration to adjust
11+
# the workflow description as needed, then regenerate this file to apply
12+
# those changes.
13+
#
14+
# -------------------------------------------------------------------
15+
# ----------------------------- END WARNING -------------------------
16+
# -------------------------------------------------------------------
217

18+
name: Build and Test
319
on:
420
push:
521
branches:
6-
- main
7-
pull_request:
8-
9-
env:
10-
CARGO_TERM_COLOR: always
11-
22+
- main
23+
pull_request_target:
24+
types:
25+
- opened
26+
- synchronize
27+
- reopened
28+
branches:
29+
- main
1230
jobs:
13-
cargo_build_and_test:
14-
name: Cargo Build & Test
31+
build:
32+
name: Build and Test Rust SDK
1533
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
toolchain:
19-
- stable
2034
steps:
21-
- uses: actions/checkout@v4
22-
with:
23-
submodules: true
24-
- run: npm ci
25-
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
26-
- run: cargo build --verbose --all-targets
27-
- run: cargo test --verbose
28-
- run: cargo doc --verbose
35+
- name: Checkout Code
36+
uses: actions/checkout@v4
37+
- name: Setup Rust Toolchain
38+
uses: actions-rust-lang/setup-rust-toolchain@v1
39+
with:
40+
toolchain: stable, nightly
41+
components: clippy, rustfmt
42+
- name: Cargo Test
43+
run: cargo test --all-features --workspace
44+
- name: Cargo Fmt
45+
run: cargo +nightly fmt --check
46+
- name: Cargo Clippy
47+
run: cargo +nightly clippy --all-features --workspace -- -D warnings

rust-sdk/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ name = "simple"
2121
[dev-dependencies]
2222
chrono = "0.4.38"
2323
env_logger = { version = "0.11.3", features = ["unstable-kv"] }
24+
25+
[build-dependencies]
26+
gh-workflow = "0.3.0"
27+
serde_yaml = "0.9"

rust-sdk/build.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use gh_workflow::*;
2+
use toolchain::Toolchain;
3+
4+
fn main() {
5+
let build = Job::new("Build and Test Rust SDK")
6+
.add_step(Step::checkout())
7+
.add_step(
8+
Toolchain::default()
9+
.add_stable()
10+
.add_nightly()
11+
.add_clippy()
12+
.add_fmt(),
13+
)
14+
.add_step(
15+
Cargo::new("test")
16+
.args("--all-features --workspace")
17+
.name("Cargo Test"),
18+
)
19+
.add_step(
20+
Cargo::new("fmt")
21+
.nightly()
22+
.args("--check")
23+
.name("Cargo Fmt"),
24+
)
25+
.add_step(
26+
Cargo::new("clippy")
27+
.nightly()
28+
.args("--all-features --workspace -- -D warnings")
29+
.name("Cargo Clippy"),
30+
);
31+
32+
let event = Event::default()
33+
.push(Push::default().add_branch("main"))
34+
.pull_request_target(
35+
PullRequestTarget::default()
36+
.open()
37+
.synchronize()
38+
.reopen()
39+
.add_branch("main"),
40+
);
41+
42+
Workflow::new("Build and Test")
43+
.on(event)
44+
.add_job("build", build)
45+
.generate()
46+
.unwrap();
47+
}

0 commit comments

Comments
 (0)