Feat-restructure as proper library with ci/cd quality gates#85
Conversation
- 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>
There was a problem hiding this comment.
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.rsas the public module root and stripssrc/main.rsdown 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.
|
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:
|
Summary
Restructure the
rustcloudcrate from a binary-only layout into a properlib.rs+main.rsdual-target crate and introduce a GitHub Actions CI pipeline with five parallel quality gates. This makesrustcloudconsumable asuse 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 insidemain.rs, which meant:cargo build --libdid not produce anything; external crates could notuse rustcloud::*.main.rssilently hid the realmod.rsfiles on disk, so any code added in filesystem modules was dead code.Cargo.tomlcontained an invalid[[language]]section (Helix editor config), a self-referencingdev-dependency, andmockallmisplaced in production dependencies.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:
Cargo.toml+ compilation errorsmod.rsdeclarations with filesystemlib.rsmain.rs-D warningsEach commit compiles independently, so reviewers can
git bisector 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-delegatedpub modstatements. Includes apub use errors::CloudErrorconvenience 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-linefn main()placeholder. The binary still compiles via Cargo's automaticlib.rslinkage.mod.rsfixes:aws/aws_apis/compute/mod.rs— removed phantomaws_paas(file does not exist)aws/aws_apis/database/mod.rs— removed phantomaws_nosqlindexedandaws_rbmdsaws/aws_apis/network/mod.rs— changedmodtopub modforaws_dnsandaws_loadbalancertraits/mod.rs— added missingpub mod token_providergcp/mod.rs— removed stale// pub mcomment fragmentPart B — CI/CD pipeline
.github/workflows/ci.yml(new): Runs onpushtomainand all PRs againstmain. Five parallel jobs:cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo build --lib+cargo build --bin rustcloudcargo test --no-run(compile-check; tests hit real cloud APIs)cargo doc --no-depsBug fixes included
gcp_storage.rs: Three occurrences whereresp.text().awaitconsumed the response beforeresp.status()was read. Fixed by capturinglet status = resp.status().as_u16();first.gcp_bigtable_operations.rs: Empty struct initializersTable {},InitialSplits {},ClusterStates {}replaced with required fields.aws_config::load_from_env()toaws_config::load_defaults(BehaviorVersion::latest()).needless_return/let_and_returnpatterns, replacedassert!(true), applied#[allow(dead_code)]to GCP types reserved for future use, usedstd::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 pipelinerustcloud/src/main.rs— stripped from 97 → 3 lines (CLI placeholder)rustcloud/Cargo.toml— removed[[language]], self-ref dev-dep; movedmockallto[dev-dependencies]mod.rsfiles — aligned declarations with actual filesystemgcp_storage.rs— fixed 3 borrow-after-move errorsTesting
All six acceptance criteria from the issue pass locally:
cargo fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo build --libcargo build --bin rustcloudcargo test --no-runcargo doc --no-depsHow to Test / Reproduce
Backward Compatibility & Risk Assessment
main.rsstill prints "Hello, world!"#![allow(...)]lints are explicitly documented and scoped. They suppress warnings for existing API patterns and can be removed incrementally in future refactoring issues.Performance and Security Considerations
Changelog Entry
Added
rustcloud/src/lib.rs— library entry point enablinguse rustcloud::*from external crates.github/workflows/ci.yml— CI pipeline with fmt, clippy, build, test, and doc quality gatesFixed
Cargo.toml— removed invalid[[language]]section, movedmockallto dev-dependenciesmod.rsfiles — aligned module declarations with actual filesystem structuregcp_storage.rs(3 occurrences)aws_config::load_from_env()calls migrated toload_defaults()Changed
main.rsstripped to CLI placeholder (module tree now lives inlib.rs)Review Guide
1.
rustcloud/src/lib.rs(Core of the PR)This is the new library entry point. Verify:
#![allow(...)]annotations are reasonable and documentedpub use errors::CloudErrorre-export is correct#[cfg(test)] mod testsis gated properly2.
rustcloud/src/main.rsConfirm:
pub mod { }declarations are removedlib.rsfn main()3.
.github/workflows/ci.ymlCheck:
working-directory: ./rustcloudis set on everyrun:steppush: [main]andpull_request: [main]dtolnay/rust-toolchain@stableis used consistently4.
rustcloud/Cargo.tomlVerify:
[[language]]block (Helix editor config) is removedrustcloud = { path = '.' }dev-dependency is removedmockallmoved from[dependencies]→[dev-dependencies]5. Five
mod.rsfixes (Small but critical)These are the files that were out of sync with the filesystem:
aws/aws_apis/compute/mod.rsaws_paasaws/aws_apis/database/mod.rsaws_nosqlindexed,aws_rbmdsaws/aws_apis/network/mod.rsmod→pub modfor visibilitytraits/mod.rspub mod token_providergcp/mod.rs// pub mcomment6. Bulk lint fixes (Commit 6 — mechanical changes)
These span ~30 files. Spot-check a few for:
let_and_returncleanup —let x = expr; x→exprload_from_env()→load_defaults(BehaviorVersion::latest())#[allow(dead_code)]on GCP structs — these are deserialization types reserved for future useContributor Checklist
cargo build --lib— library target compilescargo build --bin rustcloud— binary target compilescargo test --no-run— all tests compilecargo fmt --all -- --check— zero formatting diffscargo clippy --all-targets -- -D warnings— zero warningscargo doc --no-deps— generates successfullylib.rsincludes crate-level//!doc comments.github/workflows/ci.ymlwith 5 parallel jobs: fmt, clippy, build, test, docpushtomainand all PRs againstmainTL;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.