refactor(compile): reduce complexity of build_safeoutputs_job in agentic_pipeline.rs - #2267
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…tic_pipeline.rs Extract seven well-named helper functions from build_safeoutputs_job (previously 162 lines, flagged by clippy::too_many_lines at 100/100): - push_safeoutputs_multi_checkout_steps - push_safeoutputs_compiler_bootstrap_steps - push_safeoutputs_prepare_pr_base_steps - safeoutputs_github_actor_required - push_safeoutputs_github_app_token_step - push_safeoutputs_github_app_token_revoke_step No behavior change: same steps are emitted in the same order and same conditions. build_safeoutputs_job is no longer reported by clippy::too_many_lines. All 3406 tests and clippy pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was complex
build_safeoutputs_jobinsrc/compile/agentic_pipeline.rswas flagged byclippy::too_many_linesat 162/100 lines. It was a single monolithic function assembling all steps of the SafeOutputs job (checkout, write-token acquisition, compiler bootstrap,create-pull-requestprepare steps, GitHub App token mint/revoke, executor invocation, log copy, artifact publish, and job condition wiring) inline, making it hard to read and test each concern in isolation.What changed
Extracted seven well-named helper functions, each owning one logically distinct concern, with their original doc comments preserved and attached to the new function:
push_safeoutputs_multi_checkout_steps— replicates the Agent job's multi-checkout layout forcreate-pull-request.push_safeoutputs_compiler_bootstrap_steps— downloads analyzed outputs, the compiler, adds it to PATH, prepares the output directory.push_safeoutputs_prepare_pr_base_steps— stages the ado-script bundle and emitsprepare-pr-basesteps for local/cross-org repos.safeoutputs_github_actor_required— whether the GitHub App actor login is needed forcomment-on-github-issue.push_safeoutputs_github_app_token_step— mints the GitHub App installation token.push_safeoutputs_github_app_token_revoke_step— revokes it after the executor runs.build_safeoutputs_jobnow reads as a short, linear sequence of calls to these helpers plus the job/pool/condition assembly.No behavior change: the same steps are emitted in the same order under the same conditions — this is a pure extraction, not a logic change.
Before/after complexity
clippy::too_many_linesreportedbuild_safeoutputs_jobat 162/100 lines.build_safeoutputs_jobno longer appears in theclippy::too_many_linesviolation list for this file (confirmed viacargo clippy --all-targets --all-features --message-format=json -- -W clippy::too_many_lines).Verification
cargo build --bin ado-aw— succeeds.cargo test --bin ado-aw— all 3406 tests pass (0 failed), including the 79 tests incompile::agentic_pipeline.cargo clippy --all-targets --all-features— clean, no warnings.src/compile/agentic_pipeline.rsis touched; an incidentalcargo fmt --allpass over unrelated files was reverted to keep this PR surgical.Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.