From dd0051d9fad52f02fad34ff8bf2cc0f45936a6ad Mon Sep 17 00:00:00 2001 From: Sandipsinh Dilipsinh Rathod <62684960+ssddOnTop@users.noreply.github.com> Date: Tue, 19 Nov 2024 01:09:49 -0500 Subject: [PATCH] chore: add ci (#3) --- .github/workflows/ci.yml | 49 +++++++++++++ Cargo.lock | 146 ++++++++++++++++++++++++++++++++++++--- Cargo.toml | 1 + tests/ci.rs | 51 ++++++++++++++ 4 files changed, 237 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 tests/ci.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7f9ad84 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +# ------------------------------------------------------------------- +# ------------------------------- WARNING --------------------------- +# ------------------------------------------------------------------- +# +# This file was automatically generated by gh-workflows using the +# gh-workflow-gen bin. You should add and commit this file to your +# git repository. **DO NOT EDIT THIS FILE BY HAND!** Any manual changes +# will be lost if the file is regenerated. +# +# To make modifications, update your `build.rs` configuration to adjust +# the workflow description as needed, then regenerate this file to apply +# those changes. +# +# ------------------------------------------------------------------- +# ----------------------------- END WARNING ------------------------- +# ------------------------------------------------------------------- + +name: Build and Test +env: + RUSTFLAGS: -Dwarnings +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + branches: + - main + push: + branches: + - main +jobs: + build: + name: Build and Test + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Setup Rust Toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable, nightly + components: clippy, rustfmt + - name: Cargo Test + run: cargo test --all-features --workspace + - name: Cargo Fmt + run: cargo +nightly fmt --check + - name: Cargo Clippy + run: cargo +nightly clippy --all-features --workspace -- -D warnings diff --git a/Cargo.lock b/Cargo.lock index 3b8f627..61eed77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ dependencies = [ "proc-macro2", "quote", "strum", - "syn", + "syn 2.0.87", "thiserror", ] @@ -127,7 +127,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -138,7 +138,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -223,7 +223,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.87", ] [[package]] @@ -234,7 +234,39 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "derive_setters" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -328,7 +360,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -376,6 +408,23 @@ dependencies = [ "version_check", ] +[[package]] +name = "gh-workflow" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ad3bcceabc26816ce586fece0653c5253300dcfa66c0a62efed1ccb5f745d" +dependencies = [ + "async-trait", + "derive_more", + "derive_setters", + "indexmap", + "merge", + "serde", + "serde_json", + "serde_yaml", + "strum_macros", +] + [[package]] name = "handlebars" version = "5.1.2" @@ -472,6 +521,28 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "merge" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10bbef93abb1da61525bbc45eeaff6473a41907d19f8f9aa5168d214e10693e9" +dependencies = [ + "merge_derive", + "num-traits", +] + +[[package]] +name = "merge_derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209d075476da2e63b4b29e72a2ef627b840589588e71400a25e3565c4f849d07" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "mime" version = "0.3.17" @@ -556,7 +627,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -601,6 +672,30 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.89" @@ -690,7 +785,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -727,6 +822,19 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sha2" version = "0.10.8" @@ -784,7 +892,18 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] @@ -805,6 +924,7 @@ dependencies = [ "anyhow", "async-graphql", "async-graphql-value", + "gh-workflow", "indexmap", "nom", "pretty_assertions", @@ -842,7 +962,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -880,6 +1000,12 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "version_check" version = "0.9.5" diff --git a/Cargo.toml b/Cargo.toml index 8a7a3f8..79b6114 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ anyhow = "1.0.93" [dev-dependencies] pretty_assertions = "1.4.1" +gh-workflow = "0.4.1" diff --git a/tests/ci.rs b/tests/ci.rs new file mode 100644 index 0000000..9e6c877 --- /dev/null +++ b/tests/ci.rs @@ -0,0 +1,51 @@ +use gh_workflow::toolchain::Toolchain; +use gh_workflow::*; + +#[test] +fn generate() { + let flags = RustFlags::deny("warnings"); + + let build = Job::new("Build and Test") + .add_step(Step::checkout()) + .add_step( + Toolchain::default() + .add_stable() + .add_nightly() + .add_clippy() + .add_fmt(), + ) + .add_step( + Cargo::new("test") + .args("--all-features --workspace") + .name("Cargo Test"), + ) + .add_step( + Cargo::new("fmt") + .nightly() + .args("--check") + .name("Cargo Fmt"), + ) + .add_step( + Cargo::new("clippy") + .nightly() + .args("--all-features --workspace -- -D warnings") + .name("Cargo Clippy"), + ); + + let event = Event::default() + .push(Push::default().add_branch("main")) + .pull_request_target( + PullRequestTarget::default() + .add_type(PullRequestType::Opened) + .add_type(PullRequestType::Synchronize) + .add_type(PullRequestType::Reopened) + .add_branch("main"), + ); + + Workflow::new("Build and Test") + .add_env(flags) + .on(event) + .add_job("build", build) + .generate() + .unwrap(); +}