From 098b45d74ae5f595347ba9bb0f44325dc9a877f3 Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Thu, 7 Nov 2024 10:17:37 +0530 Subject: [PATCH] chore: remove timeout --- .github/workflows/ci.yml | 30 ++++++--------------- Cargo.lock | 16 ----------- workspace/gh-workflow-gen/src/main.rs | 11 +++----- workspace/gh-workflow/Cargo.toml | 1 - workspace/gh-workflow/src/toolchain.rs | 27 ++++++++++--------- workspace/gh-workflow/src/workflow.rs | 37 +++++++------------------- 6 files changed, 34 insertions(+), 88 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e94456..aa28e5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI env: - RUSTFLAGS: -AWarnings + RUSTFLAGS: -D Warnings on: push: branches: @@ -15,29 +15,15 @@ on: permissions: contents: read jobs: - stable: - name: Build + 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 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: stable - - name: Run Test - run: cargo test --all-features --workspace - nightly: - name: Nightly - 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: nightly - - name: Run Fmt - run: cargo nightly fmt --all-features --workspace -- check - - name: Run Clippy - run: 'cargo +nightly clippy --all-features --workspace -- -D warnings ' + toolchain: stable,nightly + - run: cargo test --all-features --workspace + - run: cargo +nightly fmt --check + - run: cargo +nightly clippy --all-features --workspace diff --git a/Cargo.lock b/Cargo.lock index 5e80b3d..c0e7fb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,15 +25,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "darling" version = "0.20.10" @@ -130,7 +121,6 @@ name = "gh-workflow" version = "0.1.0" dependencies = [ "async-trait", - "convert_case", "derive_more", "derive_setters", "indexmap", @@ -324,12 +314,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" -[[package]] -name = "unicode-segmentation" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" - [[package]] name = "unsafe-libyaml" version = "0.2.11" diff --git a/workspace/gh-workflow-gen/src/main.rs b/workspace/gh-workflow-gen/src/main.rs index bdf709d..59a4201 100644 --- a/workspace/gh-workflow-gen/src/main.rs +++ b/workspace/gh-workflow-gen/src/main.rs @@ -1,25 +1,20 @@ -use std::time::Duration; - use gh_workflow::{Job, Permissions, RustFlags, Step, Toolchain, Workflow}; fn main() { let rust_flags = RustFlags::deny("Warnings"); - let build = Job::new("build") + let build = Job::new("Build and Test") .add_step(Step::checkout()) .add_step( Step::setup_rust() .add_toolchain(Toolchain::Stable) .add_toolchain(Toolchain::Nightly), ) - .add_step( - Step::cargo("test", vec!["--all-features", "--workspace"]) - .timeout(Duration::from_secs(10)), - ) + .add_step(Step::cargo("test", vec!["--all-features", "--workspace"])) .add_step(Step::cargo_nightly("fmt", vec!["--check"])) .add_step(Step::cargo_nightly( "clippy", - vec!["--all-features", "--workspace", "-D", "warnings"], + vec!["--all-features", "--workspace"], )); Workflow::new("CI") diff --git a/workspace/gh-workflow/Cargo.toml b/workspace/gh-workflow/Cargo.toml index d020384..4b7f73c 100644 --- a/workspace/gh-workflow/Cargo.toml +++ b/workspace/gh-workflow/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" [dependencies] async-trait = "0.1.83" -convert_case = "0.6.0" derive_more = { version = "1.0.0", features = ["from"] } derive_setters = "0.1.6" indexmap = {version = "2.6.0", features = ["serde"]} diff --git a/workspace/gh-workflow/src/toolchain.rs b/workspace/gh-workflow/src/toolchain.rs index a6af83d..c030a50 100644 --- a/workspace/gh-workflow/src/toolchain.rs +++ b/workspace/gh-workflow/src/toolchain.rs @@ -76,7 +76,8 @@ pub struct Target { /// A Rust representation for the inputs of the setup-rust action. /// More information can be found [here](https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml). -/// NOTE: The public API should be close to the original action as much as possible. +/// NOTE: The public API should be close to the original action as much as +/// possible. #[derive(Default, Clone, Setters)] #[setters(strip_option)] pub struct ToolchainStep { @@ -104,19 +105,19 @@ impl AddStep for ToolchainStep { fn apply(self, job: Job) -> Job { let mut step = Step::uses("actions-rust-lang", "setup-rust-toolchain", 1); - if !self.toolchain.is_empty() { - let toolchain = self - .toolchain - .iter() - .map(|t| match t { - Toolchain::Stable => "stable".to_string(), - Toolchain::Nightly => "nightly".to_string(), - Toolchain::Custom((major, minor, patch)) => { - format!("{}.{}.{}", major, minor, patch) - } - }) - .fold("".to_string(), |acc, a| format!("{},{}", acc, a)); + let toolchain = self + .toolchain + .iter() + .map(|t| match t { + Toolchain::Stable => "stable".to_string(), + Toolchain::Nightly => "nightly".to_string(), + Toolchain::Custom((major, minor, patch)) => { + format!("{}.{}.{}", major, minor, patch) + } + }) + .reduce(|acc, a| format!("{},{}", acc, a)); + if let Some(toolchain) = toolchain { step = step.with(("toolchain", toolchain)); } diff --git a/workspace/gh-workflow/src/workflow.rs b/workspace/gh-workflow/src/workflow.rs index 919f953..6a09185 100644 --- a/workspace/gh-workflow/src/workflow.rs +++ b/workspace/gh-workflow/src/workflow.rs @@ -1,14 +1,13 @@ -use convert_case::{Case, Casing}; +use std::fmt::Display; +use std::path::Path; + use derive_setters::Setters; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use serde_json::Value; -use std::{fmt::Display, path::Path, time::Duration}; -use crate::{ - error::{Error, Result}, - ToolchainStep, -}; +use crate::error::{Error, Result}; +use crate::ToolchainStep; #[derive(Default, Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] #[serde(rename_all = "kebab-case")] @@ -128,11 +127,6 @@ impl Workflow { a.apply(self) } - pub fn timeout(mut self, duration: Duration) -> Self { - self.timeout_minutes = Some(duration.as_secs() as u32 / 60); - self - } - pub fn env>(self, env: T) -> Self { env.apply(self) } @@ -266,7 +260,7 @@ pub struct Job { impl Job { pub fn new(name: T) -> Self { Self { - name: Some(name.to_string().to_case(Case::Title)), + name: Some(name.to_string()), runs_on: Some(OneOrManyOrObject::Single("ubuntu-latest".to_string())), ..Default::default() } @@ -280,11 +274,6 @@ impl Job { a.apply(self) } - pub fn timeout(mut self, duration: Duration) -> Self { - self.timeout_minutes = Some(duration.as_secs() as u32 / 60); - self - } - pub fn env>(self, env: T) -> Self { env.apply(self) } @@ -379,18 +368,13 @@ pub struct Step { impl Step { pub fn name(mut self, name: S) -> Self { - self.name = Some(name.to_string().to_case(Case::Title)); + self.name = Some(name.to_string()); self } pub fn env>(self, env: R) -> Self { env.apply(self) } - - pub fn timeout(mut self, duration: Duration) -> Self { - self.timeout_minutes = Some(duration.as_secs() as u32 / 60); - self - } } impl AddStep for Step @@ -418,12 +402,9 @@ impl Step { params .iter() .map(|a| a.to_string()) - .fold("".to_string(), |mut a, b| { - a.push_str(&b); - a - }) + .reduce(|a, b| { format!("{} {}", a, b) }) + .unwrap_or_default() )) - .name(format!("Cargo {}", cmd.to_string()).to_case(Case::Title)) } pub fn cargo_nightly(cmd: T, params: Vec

) -> Self {