Skip to content

Feat-restructure as proper library with ci/cd quality gates#85

Open
Priyanshu-rgbb wants to merge 6 commits intoc2siorg:mainfrom
Priyanshu-rgbb:feat-Restructure-as-proper-library-with-CI/CD-quality-gates
Open

Feat-restructure as proper library with ci/cd quality gates#85
Priyanshu-rgbb wants to merge 6 commits intoc2siorg:mainfrom
Priyanshu-rgbb:feat-Restructure-as-proper-library-with-CI/CD-quality-gates

Conversation

@Priyanshu-rgbb
Copy link

Summary

Restructure the rustcloud crate from a binary-only layout into a proper lib.rs + main.rs dual-target crate and introduce a GitHub Actions CI pipeline with five parallel quality gates. This makes rustcloud consumable as use rustcloud::aws::... by downstream crates for the first time.

Problem / Motivation

The crate could not be used as a library dependency. All module declarations lived as inline pub mod { } blocks inside main.rs, which meant:

  1. No library targetcargo build --lib did not produce anything; external crates could not use rustcloud::*.
  2. Shadowed filesystem modules — inline blocks in main.rs silently hid the real mod.rs files on disk, so any code added in filesystem modules was dead code.
  3. No CI pipeline — formatting, linting, build, test-compilation, and doc-generation were never verified automatically.
  4. Manifest pollutionCargo.toml contained an invalid [[language]] section (Helix editor config), a self-referencing dev-dependency, and mockall misplaced in production dependencies.
  5. Pre-existing compilation errors — borrow-after-move in gcp_storage.rs, phantom module declarations for files that don't exist, private module visibility, and missing module declarations.

Closes #84

Solution Overview

The work is split into six atomic, bisectable commits following a dependency-ordered sequence:

# Scope Rationale
1 Fix Cargo.toml + compilation errors Establish a compiling baseline before restructuring
2 Align mod.rs declarations with filesystem Remove phantom modules, fix visibility, add missing declarations
3 Create lib.rs Single source of truth for the public module tree
4 Strip main.rs Remove all inline module declarations; binary becomes a thin CLI placeholder
5 Add CI workflow Five parallel GitHub Actions jobs enforce quality on every PR
6 Fix formatting + clippy Bring the entire codebase to zero warnings under -D warnings

Each commit compiles independently, so reviewers can git bisect or cherry-pick safely.

Implementation Details

Part A — Library restructuring

  • rustcloud/src/lib.rs (new): Declares the full public module tree (aws, azure, gcp, digiocean, errors, traits, types) using filesystem-delegated pub mod statements. Includes a pub use errors::CloudError convenience re-export and crate-level #![allow(...)] annotations for five design-level lints that are baked into the existing API surface (result_large_err, too_many_arguments, new_without_default, non_snake_case, deprecated).
  • rustcloud/src/main.rs: Stripped from 97 lines of inline module declarations down to a 3-line fn main() placeholder. The binary still compiles via Cargo's automatic lib.rs linkage.
  • Five mod.rs fixes:
    • aws/aws_apis/compute/mod.rs — removed phantom aws_paas (file does not exist)
    • aws/aws_apis/database/mod.rs — removed phantom aws_nosqlindexed and aws_rbmds
    • aws/aws_apis/network/mod.rs — changed mod to pub mod for aws_dns and aws_loadbalancer
    • traits/mod.rs — added missing pub mod token_provider
    • gcp/mod.rs — removed stale // pub m comment fragment

Part B — CI/CD pipeline

  • .github/workflows/ci.yml (new): Runs on push to main and all PRs against main. Five parallel jobs:
    • fmtcargo fmt --all -- --check
    • clippycargo clippy --all-targets -- -D warnings
    • buildcargo build --lib + cargo build --bin rustcloud
    • testcargo test --no-run (compile-check; tests hit real cloud APIs)
    • doccargo doc --no-deps

Bug fixes included

  • Borrow-after-move in gcp_storage.rs: Three occurrences where resp.text().await consumed the response before resp.status() was read. Fixed by capturing let status = resp.status().as_u16(); first.
  • Missing struct fields in gcp_bigtable_operations.rs: Empty struct initializers Table {}, InitialSplits {}, ClusterStates {} replaced with required fields.
  • Deprecated AWS SDK call: All test files migrated from aws_config::load_from_env() to aws_config::load_defaults(BehaviorVersion::latest()).
  • Clippy compliance across 30+ files: Removed unused imports, eliminated needless_return / let_and_return patterns, replaced assert!(true), applied #[allow(dead_code)] to GCP types reserved for future use, used std::io::Error::other().

Key Changes

  • + rustcloud/src/lib.rs — library entry point with full module tree and crate-level lint allows
  • + .github/workflows/ci.yml — 5-job parallel CI pipeline
  • ~ rustcloud/src/main.rs — stripped from 97 → 3 lines (CLI placeholder)
  • ~ rustcloud/Cargo.toml — removed [[language]], self-ref dev-dep; moved mockall to [dev-dependencies]
  • ~ 5 mod.rs files — aligned declarations with actual filesystem
  • ~ gcp_storage.rs — fixed 3 borrow-after-move errors
  • ~ 12 AWS test files — deprecated API migration, lint fixes
  • ~ 8 GCP test files — unused import removal, lint fixes
  • ~ 58 files touched total, 295 insertions, 328 deletions

Testing

All six acceptance criteria from the issue pass locally:

Gate Command Status
Format cargo fmt --all -- --check Pass
Lint cargo clippy --all-targets -- -D warnings Pass (0 warnings)
Lib build cargo build --lib Pass
Bin build cargo build --bin rustcloud Pass
Test compile cargo test --no-run Pass
Documentation cargo doc --no-deps Pass

Note: cargo test (execution) is not included as a gate because the existing test suite calls real cloud provider APIs and requires live credentials.

How to Test / Reproduce

# 1. Check out the branch
git fetch origin
git checkout feat-Restructure-as-proper-library-with-CI/CD-quality-gates

# 2. Run all quality gates
cd rustcloud
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo build --lib
cargo build --bin rustcloud
cargo test --no-run
cargo doc --no-deps

# 3. Verify library is importable (quick smoke test)
# In any Rust project, add to Cargo.toml:
#   rustcloud = { path = "../RustCloud/rustcloud" }
# Then: use rustcloud::aws::aws_apis::compute::aws_ec2;

# 4. Verify binary still runs
cargo run --bin rustcloud
# Expected output: "Hello, world!"

Backward Compatibility & Risk Assessment

Aspect Assessment
Breaking change? No. The crate had no external consumers; the public API surface is strictly additive.
Binary behavior Unchanged — main.rs still prints "Hello, world!"
Existing tests All tests compile. No test logic was altered (only imports and lint compliance).
Crate-level allows Five #![allow(...)] lints are explicitly documented and scoped. They suppress warnings for existing API patterns and can be removed incrementally in future refactoring issues.
Risk Low. Every commit compiles independently and the CI pipeline will catch regressions going forward.

Performance and Security Considerations

  • No runtime performance impact. Changes are purely structural (module layout, manifest, CI). No algorithms, data structures, or hot paths were modified.
  • Security improvement: mockall moved from production [dependencies] to [dev-dependencies], removing it from the production dependency tree and reducing supply-chain surface area.
  • CI enforcement: The -D warnings clippy flag and cargo fmt --check gate prevent future regressions from being merged.

Changelog Entry

Added

  • rustcloud/src/lib.rs — library entry point enabling use rustcloud::* from external crates
  • .github/workflows/ci.yml — CI pipeline with fmt, clippy, build, test, and doc quality gates

Fixed

  • Cargo.toml — removed invalid [[language]] section, moved mockall to dev-dependencies
  • 5 mod.rs files — aligned module declarations with actual filesystem structure
  • Borrow-after-move in gcp_storage.rs (3 occurrences)
  • Deprecated aws_config::load_from_env() calls migrated to load_defaults()
  • All clippy warnings resolved across 30+ files

Changed

  • main.rs stripped to CLI placeholder (module tree now lives in lib.rs)

Review Guide

Recommended review order — follow the commits sequentially; each builds on the last.

1. rustcloud/src/lib.rs (Core of the PR)

This is the new library entry point. Verify:

  • The module tree matches the actual filesystem layout
  • The five crate-level #![allow(...)] annotations are reasonable and documented
  • pub use errors::CloudError re-export is correct
  • #[cfg(test)] mod tests is gated properly

2. rustcloud/src/main.rs

Confirm:

  • All 94 lines of inline pub mod { } declarations are removed
  • No business logic was lost — only module wiring moved to lib.rs
  • The binary still compiles with just fn main()

3. .github/workflows/ci.yml

Check:

  • Five parallel jobs match the acceptance criteria: fmt, clippy, build, test, doc
  • working-directory: ./rustcloud is set on every run: step
  • Triggers are scoped to push: [main] and pull_request: [main]
  • dtolnay/rust-toolchain@stable is used consistently

4. rustcloud/Cargo.toml

Verify:

  • [[language]] block (Helix editor config) is removed
  • Self-referencing rustcloud = { path = '.' } dev-dependency is removed
  • mockall moved from [dependencies][dev-dependencies]
  • No legitimate dependencies were accidentally removed

5. Five mod.rs fixes (Small but critical)

These are the files that were out of sync with the filesystem:

File What changed
aws/aws_apis/compute/mod.rs Removed phantom aws_paas
aws/aws_apis/database/mod.rs Removed phantom aws_nosqlindexed, aws_rbmds
aws/aws_apis/network/mod.rs modpub mod for visibility
traits/mod.rs Added missing pub mod token_provider
gcp/mod.rs Removed stale // pub m comment

Key check: Ensure no legitimate module declarations were removed — only phantoms (files that don't exist on disk).

6. Bulk lint fixes (Commit 6 — mechanical changes)

These span ~30 files. Spot-check a few for:

  • Unused import removal — no needed imports accidentally deleted
  • let_and_return cleanup — let x = expr; xexpr
  • Deprecated API migrationload_from_env()load_defaults(BehaviorVersion::latest())
  • #[allow(dead_code)] on GCP structs — these are deserialization types reserved for future use

Contributor Checklist

  • Code builds successfully
    • cargo build --lib — library target compiles
    • cargo build --bin rustcloud — binary target compiles
  • Tests added or updated and passing
    • cargo test --no-run — all tests compile
    • Existing test logic unchanged; only imports and lint compliance updated
  • Formatting applied
    • cargo fmt --all -- --check — zero formatting diffs
  • Lint checks clean
    • cargo clippy --all-targets -- -D warnings — zero warnings
  • Documentation updated
    • cargo doc --no-deps — generates successfully
    • lib.rs includes crate-level //! doc comments
  • CI pipeline added and configured
    • .github/workflows/ci.yml with 5 parallel jobs: fmt, clippy, build, test, doc
    • Triggers on push to main and all PRs against main
  • No breaking changes
    • Strictly additive public API surface
    • Binary behavior unchanged
    • No test logic modified
  • Commits are atomic and bisectable

TL;DR

Converts rustcloud from a binary-only crate into a proper library + binary layout by creating lib.rs, stripping main.rs, fixing pre-existing compilation errors, and adding a 5-job GitHub Actions CI pipeline — making the crate importable by external projects and enforcing quality gates on every PR.

Priyanshu-rgbb and others added 6 commits March 15, 2026 04:03
- Remove invalid [[language]] section (Helix editor config) from Cargo.toml
- Move mockall from dependencies to dev-dependencies
- Remove self-referencing dev-dependency (redundant once lib.rs exists)
- Fix borrow-after-move errors in gcp_storage.rs by capturing status
  before consuming response body

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove phantom pub mod aws_paas from compute/mod.rs (file doesn't exist)
- Remove phantom pub mod aws_nosqlindexed, aws_rbmds from database/mod.rs
- Change private mod to pub mod for aws_dns and aws_loadbalancer in network/mod.rs
- Add missing pub mod token_provider to traits/mod.rs
- Remove stale comment from gcp/mod.rs

These fixes ensure mod.rs files match the module tree currently
declared inline in main.rs, preparing for the lib.rs migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add rustcloud/src/lib.rs that exports all public modules (errors,
types, traits, aws, azure, gcp, digiocean) and re-exports CloudError
for convenience. Module resolution delegates to the filesystem mod.rs
files fixed in the previous commit. Tests are gated behind #[cfg(test)].

This enables the crate to be used as a library dependency via
`use rustcloud::aws::aws_apis::compute::aws_ec2;` etc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove all 94 lines of inline module declarations from main.rs,
  keeping only the fn main() placeholder. All modules now live
  exclusively in lib.rs.
- Fix missing struct fields in gcp_bigtable_operations test that
  prevented cargo test --no-run from succeeding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…c gates

Add .github/workflows/ci.yml that runs on push to main and on PRs.
Five parallel jobs: format check, clippy lint, library+binary build,
test compilation, and documentation generation. All jobs use
dtolnay/rust-toolchain@stable with working-directory: ./rustcloud.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Run cargo fmt across all source files
- Remove unused imports in source and test files
- Remove bare `use chrono;` imports (single_component_path_imports)
- Remove unused constants (UNIX_DATE, RFC3339) in gcp_dns and gcp_loadbalancer
- Fix unnecessary mut in azure_auth.rs
- Fix borrow-after-move already addressed in gcp_storage.rs
- Add #[allow(non_camel_case_types)] for GCP notification enum variants
- Add #[allow(dead_code)] for GCP struct fields and kubernetes types
- Replace deprecated aws_config::load_from_env with load_defaults
- Replace std::io::Error::new(Other, msg) with Error::other(msg)
- Fix needless_return and let_and_return in test helpers
- Remove assert!(true) in azure blob test
- Add crate-level allows for result_large_err, too_many_arguments,
  new_without_default, non_snake_case, and deprecated in lib.rs

All CI gates now pass:
  cargo fmt --check, cargo clippy -- -D warnings,
  cargo build --lib, cargo build --bin, cargo test --no-run,
  cargo doc --no-deps

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 15, 2026 06:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the rustcloud crate into a proper library + binary layout (enabling downstream use rustcloud::...) and adds a GitHub Actions CI workflow to enforce formatting/lint/build/doc/test-compilation quality gates.

Changes:

  • Introduces src/lib.rs as the public module root and strips src/main.rs down to a thin placeholder binary.
  • Aligns module declarations (mod.rs) and test modules with the filesystem; removes phantom/mis-scoped modules and fixes compile issues/lints.
  • Adds a 5-job GitHub Actions CI pipeline (fmt, clippy, build, test compile, doc).

Reviewed changes

Copilot reviewed 45 out of 58 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rustcloud/src/lib.rs New library entry point exporting the crate’s public module tree and re-exporting CloudError.
rustcloud/src/main.rs Removes inline module tree; keeps a minimal binary entrypoint.
rustcloud/Cargo.toml Cleans manifest: moves mockall to dev-deps and removes invalid sections/self-dev-dep.
.github/workflows/ci.yml Adds parallel CI quality gates for fmt/clippy/build/test-compile/doc.
rustcloud/src/traits/mod.rs Exposes token_provider module from the traits tree.
rustcloud/src/tests/mod.rs Adjusts unit test module declarations ordering/wiring.
rustcloud/src/tests/azure_blob_operations.rs Cleans up test formatting / removes no-op assertions.
rustcloud/src/tests/gcp_automl_operations.rs Removes unused imports in GCP AutoML tests.
rustcloud/src/tests/gcp_bigquery_operations.rs Formatting/cleanup of BigQuery tests and teardown calls.
rustcloud/src/tests/gcp_bigtable_operations.rs Fixes Bigtable test struct initializations and removes unused imports.
rustcloud/src/tests/gcp_compute_operations.rs Removes unused imports in GCP compute tests.
rustcloud/src/tests/gcp_dns_operations.rs Removes unused imports in GCP DNS tests.
rustcloud/src/tests/gcp_loadbalancer_operations.rs Removes unused imports in GCP load balancer tests.
rustcloud/src/tests/gcp_notification_operations.rs Removes unused imports in GCP notification tests.
rustcloud/src/tests/gcp_storage_operations.rs Removes unused imports in GCP storage tests.
rustcloud/src/tests/aws_archival_operations.rs Updates AWS config loading pattern in archival tests.
rustcloud/src/tests/aws_block_operations.rs Updates AWS config loading pattern in block storage tests.
rustcloud/src/tests/aws_bucket_operations.rs Updates AWS config loading pattern and reformats S3 tests.
rustcloud/src/tests/aws_dns_operations.rs Updates AWS config loading pattern and cleans imports in Route53 tests.
rustcloud/src/tests/aws_dynamodb_operations.rs Updates AWS config loading pattern and reformats DynamoDB tests.
rustcloud/src/tests/aws_ec2_operations.rs Updates AWS config loading pattern and minor formatting.
rustcloud/src/tests/aws_ecs_operations.rs Updates AWS config loading pattern and cleans imports for ECS tests.
rustcloud/src/tests/aws_eks_operations.rs Updates AWS config loading pattern and cleans imports for EKS tests.
rustcloud/src/tests/aws_iam_operations.rs Updates AWS config loading pattern and cleans imports for IAM tests.
rustcloud/src/tests/aws_kms_operations.rs Updates AWS config loading pattern and cleans imports for KMS tests.
rustcloud/src/tests/aws_loadbalancer_operations.rs Updates AWS config loading pattern and cleans imports for ELB tests.
rustcloud/src/tests/aws_monitoring_operations.rs Updates AWS config loading pattern and simplifies client creation.
rustcloud/src/aws/aws_apis/mod.rs Fixes module declaration formatting/ordering for AWS API tree.
rustcloud/src/aws/aws_apis/compute/mod.rs Removes phantom aws_paas module declaration.
rustcloud/src/aws/aws_apis/database/mod.rs Removes phantom database module declarations.
rustcloud/src/aws/aws_apis/management/mod.rs Fixes module declaration formatting for management APIs.
rustcloud/src/aws/aws_apis/network/mod.rs Makes network submodules public for library consumers.
rustcloud/src/aws/aws_apis/security/mod.rs Fixes module declaration formatting for security APIs.
rustcloud/src/aws/aws_apis/storage/mod.rs Fixes module declaration formatting for storage APIs.
rustcloud/src/aws/aws_apis/compute/aws_ec2.rs Improves error creation and formatting in EC2 helper.
rustcloud/src/aws/aws_apis/compute/aws_eks.rs Removes unused imports in EKS implementation.
rustcloud/src/azure/mod.rs Fixes module declaration formatting for Azure tree.
rustcloud/src/azure/azure_apis/mod.rs Fixes module declaration formatting/ordering for Azure APIs.
rustcloud/src/azure/azure_apis/auth/mod.rs Fixes module declaration formatting for Azure auth.
rustcloud/src/azure/azure_apis/auth/azure_auth.rs Cleans up whitespace and minor variable usage in auth header generation.
rustcloud/src/azure/azure_apis/storage/mod.rs Fixes module declaration formatting for Azure storage.
rustcloud/src/azure/azure_apis/storage/azure_blob.rs Cleans whitespace/formatting in Azure Blob client implementation.
rustcloud/src/gcp/mod.rs Removes stale comment and ensures GCP types module is declared.
rustcloud/src/gcp/gcp_apis/mod.rs Reorders/fixes GCP API submodule declarations.
rustcloud/src/gcp/gcp_apis/auth/mod.rs Fixes module declaration formatting for GCP auth.
rustcloud/src/gcp/gcp_apis/artificial_intelligence/mod.rs Fixes module declaration formatting for GCP AI APIs.
rustcloud/src/gcp/gcp_apis/compute/mod.rs Fixes module declaration formatting for GCP compute APIs.
rustcloud/src/gcp/gcp_apis/database/mod.rs Fixes module declaration ordering for GCP database APIs.
rustcloud/src/gcp/gcp_apis/database/gcp_bigquery.rs Minor signature formatting cleanup.
rustcloud/src/gcp/gcp_apis/database/gcp_bigtable.rs Suppresses dead-code warning for project_id field.
rustcloud/src/gcp/gcp_apis/network/mod.rs Fixes module declaration formatting for GCP network APIs.
rustcloud/src/gcp/gcp_apis/network/gcp_dns.rs Removes unused constants/import and keeps fully-qualified chrono usage.
rustcloud/src/gcp/gcp_apis/network/gcp_loadbalancer.rs Removes unused constants and suppresses dead-code warning for project field.
rustcloud/src/gcp/gcp_apis/storage/mod.rs Fixes module declaration formatting for GCP storage APIs.
rustcloud/src/gcp/gcp_apis/storage/gcp_storage.rs Fixes borrow-after-move by capturing HTTP status before consuming response body.
rustcloud/src/gcp/types/database/mod.rs Ensures both BigQuery and Bigtable types modules are declared.
rustcloud/src/gcp/types/app_services/gcp_notification_types.rs Adds lint allow for non-CamelCase enum variants.
rustcloud/src/gcp/types/compute/gcp_kubernetes_types.rs Adds dead_code allowances for unused deserialization response structs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@Priyanshu-rgbb
Copy link
Author

Priyanshu-rgbb commented Mar 15, 2026

I’ve restructured the rustcloud crate to follow a standard library + binary layout. This makes it easier for others to use rustcloud as a dependency while keeping the CLI functionality intact.

Key updates:

  • Moved the core logic to src/lib.rs and kept src/main.rs as a thin wrapper.

  • Cleaned up the module structure and fixed several linting issues.

  • Added a GitHub Actions CI pipeline to automate testing and code quality checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Restructure as proper library with CI/CD quality gates

2 participants