From 4db3ad1b61570a444835e2ddf75602489bb0e771 Mon Sep 17 00:00:00 2001 From: Mehul Date: Tue, 3 Dec 2024 22:11:00 -0500 Subject: [PATCH] feat: migrate to gh-workflow-tailcall --- .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++-- Cargo.lock | 28 ++++++++++++++++++--- Cargo.toml | 2 +- tests/ci.rs | 54 +++++----------------------------------- 4 files changed, 77 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f78dc28..3464d56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,8 @@ jobs: build: name: Build and Test runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout Code uses: actions/checkout@v4 @@ -43,9 +45,50 @@ jobs: components: clippy, rustfmt - name: Cargo Test run: cargo test --all-features --workspace - - name: Cargo Bench - run: cargo bench - name: Cargo Fmt run: cargo +nightly fmt --check - name: Cargo Clippy run: cargo +nightly clippy --all-features --workspace -- -D warnings + release: + needs: + - build + if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} + name: Release + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Release Plz + uses: release-plz/action@v0.5 + with: + command: release + release-pr: + needs: + - build + if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} + name: Release PR + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Release Plz + uses: release-plz/action@v0.5 + with: + command: release-pr + concurrency: + group: release-${{github.ref}} + cancel-in-progress: false diff --git a/Cargo.lock b/Cargo.lock index edea211..2b40070 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -580,13 +580,14 @@ dependencies = [ [[package]] name = "gh-workflow" -version = "0.4.1" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ad3bcceabc26816ce586fece0653c5253300dcfa66c0a62efed1ccb5f745d" +checksum = "65c9f1a4f712e5dadf26e2ad8d186e365d32f8c49db502bc11d7fed25205a722" dependencies = [ "async-trait", "derive_more", "derive_setters", + "gh-workflow-macros", "indexmap", "merge", "serde", @@ -595,6 +596,27 @@ dependencies = [ "strum_macros", ] +[[package]] +name = "gh-workflow-macros" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a11ebc296ed5b20738f66eb9b64dc2d1f4906517b1662c7b416612c66a1cbc" +dependencies = [ + "heck", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "gh-workflow-tailcall" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23e573ef49cbda082c7f0440cefe569a054b2f447529168668f9da6c52edc43" +dependencies = [ + "derive_setters", + "gh-workflow", +] + [[package]] name = "half" version = "2.4.1" @@ -749,7 +771,7 @@ name = "jq" version = "0.1.0" dependencies = [ "criterion", - "gh-workflow", + "gh-workflow-tailcall", "jaq-core", "jaq-json", "jaq-std", diff --git a/Cargo.toml b/Cargo.toml index dc16900..7874087 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ jaq-std = { workspace = true } jaq-json = { workspace = true } [dev-dependencies] -gh-workflow = "0.4.1" +gh-workflow-tailcall = "0.1.3" pest = "2.7.14" pest_derive = {version = "2.7.14"} criterion = "0.5.1" diff --git a/tests/ci.rs b/tests/ci.rs index abcc146..1141095 100644 --- a/tests/ci.rs +++ b/tests/ci.rs @@ -1,52 +1,10 @@ -use gh_workflow::toolchain::Toolchain; -use gh_workflow::*; +use gh_workflow_tailcall::*; #[test] -fn generate() { - let flags = RustFlags::deny("warnings"); +fn generate_ci_workflow() { + let workflow = Workflow::default() + .auto_release(true) + .name("Build and Test".into()); - 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("bench").name("Cargo Bench")) - .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( - PullRequest::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(); + workflow.generate().unwrap(); }