-
Notifications
You must be signed in to change notification settings - Fork 439
Add a command to dev utils that run all other necessary scripts to submit a PR #2334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
58 changes: 58 additions & 0 deletions
58
SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/LocalPrPrecheck.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import ArgumentParser | ||
import Foundation | ||
|
||
struct LocalPrPrecheck: ParsableCommand { | ||
static let configuration = CommandConfiguration( | ||
abstract: """ | ||
Ensure changes are fully tested, formatted, and validated before pull request submission. | ||
""" | ||
) | ||
|
||
@OptionGroup | ||
var arguments: SourceCodeGeneratorArguments | ||
|
||
func run() throws { | ||
let executor = LocalPrPrecheckExecutor( | ||
toolchain: try arguments.toolchain, | ||
verbose: arguments.verbose | ||
) | ||
try executor.run() | ||
} | ||
} | ||
|
||
struct LocalPrPrecheckExecutor { | ||
private let formatExecutor: FormatExecutor | ||
private let generateSourceCodeExecutor: GenerateSourceCodeExecutor | ||
private let buildExecutor: BuildExecutor | ||
private let testExecutor: TestExecutor | ||
|
||
/// Creates an executor | ||
/// - Parameters: | ||
/// - toolchain: The path to the toolchain that shall be used to build SwiftSyntax. | ||
/// - verbose: Enable verbose logging. | ||
init(toolchain: URL, verbose: Bool = false) { | ||
self.formatExecutor = FormatExecutor(update: false, verbose: verbose) | ||
self.generateSourceCodeExecutor = GenerateSourceCodeExecutor(toolchain: toolchain, verbose: verbose) | ||
self.buildExecutor = BuildExecutor(swiftPMBuilder: SwiftPMBuilder(toolchain: toolchain, useLocalDeps: false, verbose: verbose)) | ||
self.testExecutor = TestExecutor(swiftPMBuilder: SwiftPMBuilder(toolchain: toolchain, useLocalDeps: false, verbose: verbose)) | ||
} | ||
|
||
func run() throws { | ||
try formatExecutor.run() | ||
try generateSourceCodeExecutor.run(sourceDir: Paths.sourcesDir) | ||
try buildExecutor.run() | ||
try testExecutor.run() | ||
} | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahoppen I've used this arguments group because it has all the needed arguments for this command but the name doesn't fit anymore, should I change it or stop using it and create local arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have any good new name ideas for
SourceCodeGeneratorArguments
. If you have any, I think renaming would be nice but otherwise, I think it’s OK as-is as well.