From 12b7a44a3bd4a5c9b82f7740bcfd10a5c93075bd Mon Sep 17 00:00:00 2001 From: Rauhul Varma Date: Thu, 6 Feb 2025 10:47:22 -0800 Subject: [PATCH 1/2] Add soundness workflows Adds CI to check for valid formatting and a variety of other checks. --- .editorconfig | 7 ++++ .github/workflows/lint.yml | 33 ++++++++++++++++++ .spi.yml | 1 - .swift-format | 69 +++++++++++++++++++++++++++++++++++++ .unacceptablelanguageignore | 2 ++ 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/lint.yml create mode 100644 .swift-format create mode 100644 .unacceptablelanguageignore diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..f3b46a422 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..00c81b984 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +name: Lint + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + validate_format_config: + name: Validate Format Config + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install apt dependencies + run: sudo apt-get -qq update && sudo apt-get -qq -y install curl + + - name: Compare against swift-mmio swift-format config + run: | + curl -sL https://raw.githubusercontent.com/apple/swift-mmio/refs/heads/main/.swift-format -o .swift-format-mmio + diff .swift-format .swift-format-mmio + + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + docs_check_enabled: false # bug: https://github.com/apple/swift-argument-parser/issues/704 + format_check_enabled: false # bug: https://github.com/apple/swift-argument-parser/issues/702 + license_header_check_enabled: false # feature: https://github.com/swiftlang/github-workflows/issues/78 + license_header_check_project_name: "Swift Argument Parser" # bug: https://github.com/swiftlang/github-workflows/issues/76 + shell_check_enabled: false # bug: https://github.com/apple/swift-argument-parser/issues/703 diff --git a/.spi.yml b/.spi.yml index d6794d77b..88e31ec33 100644 --- a/.spi.yml +++ b/.spi.yml @@ -2,4 +2,3 @@ version: 1 builder: configs: - documentation_targets: [ArgumentParser] - diff --git a/.swift-format b/.swift-format new file mode 100644 index 000000000..397b0eef2 --- /dev/null +++ b/.swift-format @@ -0,0 +1,69 @@ +{ + "fileScopedDeclarationPrivacy" : { + "accessLevel" : "private" + }, + "indentation" : { + "spaces" : 2 + }, + "indentConditionalCompilationBlocks" : false, + "indentSwitchCaseLabels" : false, + "lineBreakAroundMultilineExpressionChainComponents" : false, + "lineBreakBeforeControlFlowKeywords" : false, + "lineBreakBeforeEachArgument" : false, + "lineBreakBeforeEachGenericRequirement" : false, + "lineLength" : 80, + "maximumBlankLines" : 1, + "multiElementCollectionTrailingCommas" : true, + "noAssignmentInExpressions" : { + "allowedFunctions" : [ + "XCTAssertNoThrow" + ] + }, + "prioritizeKeepingFunctionOutputTogether" : false, + "respectsExistingLineBreaks" : true, + "rules" : { + "AllPublicDeclarationsHaveDocumentation" : false, + "AlwaysUseLowerCamelCase" : true, + "AmbiguousTrailingClosureOverload" : false, + "BeginDocumentationCommentWithOneLineSummary" : false, + "DoNotUseSemicolons" : true, + "DontRepeatTypeInStaticProperties" : true, + "FileScopedDeclarationPrivacy" : true, + "FullyIndirectEnum" : true, + "GroupNumericLiterals" : true, + "IdentifiersMustBeASCII" : true, + "NeverForceUnwrap" : true, + "NeverUseForceTry" : true, + "NeverUseImplicitlyUnwrappedOptionals" : true, + "NoAccessLevelOnExtensionDeclaration" : true, + "NoAssignmentInExpressions" : true, + "NoBlockComments" : false, + "NoCasesWithOnlyFallthrough" : true, + "NoEmptyTrailingClosureParentheses" : true, + "NoLabelsInCasePatterns" : true, + "NoLeadingUnderscores" : false, + "NoParensAroundConditions" : true, + "NoPlaygroundLiterals" : true, + "NoVoidReturnOnFunctionSignature" : true, + "OmitExplicitReturns" : true, + "OneCasePerLine" : true, + "OneVariableDeclarationPerLine" : true, + "OnlyOneTrailingClosureArgument" : true, + "OrderedImports" : true, + "ReplaceForEachWithForLoop" : true, + "ReturnVoidInsteadOfEmptyTuple" : true, + "TypeNamesShouldBeCapitalized" : true, + "UseEarlyExits" : true, + "UseLetInEveryBoundCaseVariable" : true, + "UseShorthandTypeNames" : true, + "UseSingleLinePropertyGetter" : true, + "UseSynthesizedInitializer" : true, + "UseTripleSlashForDocumentationComments" : true, + "UseWhereClausesInForLoops" : false, + "ValidateDocumentationComments" : true + }, + "spacesBeforeEndOfLineComments": 2, + "spacesAroundRangeFormationOperators" : false, + "tabWidth" : 2, + "version" : 1 +} diff --git a/.unacceptablelanguageignore b/.unacceptablelanguageignore new file mode 100644 index 000000000..3c4e6453e --- /dev/null +++ b/.unacceptablelanguageignore @@ -0,0 +1,2 @@ +# Ignore this file which references the "master" branch of another repo +Tools/generate-manual/MDoc/MDocMacro.swift From 67ed40557ceebd5bdfcb436b2e235e20e9a9de1f Mon Sep 17 00:00:00 2001 From: Rauhul Varma Date: Fri, 7 Feb 2025 11:20:14 -0800 Subject: [PATCH 2/2] remove format for now --- .github/workflows/lint.yml | 21 ++---------- .swift-format | 69 -------------------------------------- 2 files changed, 2 insertions(+), 88 deletions(-) delete mode 100644 .swift-format diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 00c81b984..182a7ce94 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,27 +1,10 @@ -name: Lint +name: Pull request on: - push: - branches: ["main"] pull_request: - branches: ["main"] + types: [opened, reopened, synchronize] jobs: - validate_format_config: - name: Validate Format Config - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Install apt dependencies - run: sudo apt-get -qq update && sudo apt-get -qq -y install curl - - - name: Compare against swift-mmio swift-format config - run: | - curl -sL https://raw.githubusercontent.com/apple/swift-mmio/refs/heads/main/.swift-format -o .swift-format-mmio - diff .swift-format .swift-format-mmio - soundness: name: Soundness uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main diff --git a/.swift-format b/.swift-format deleted file mode 100644 index 397b0eef2..000000000 --- a/.swift-format +++ /dev/null @@ -1,69 +0,0 @@ -{ - "fileScopedDeclarationPrivacy" : { - "accessLevel" : "private" - }, - "indentation" : { - "spaces" : 2 - }, - "indentConditionalCompilationBlocks" : false, - "indentSwitchCaseLabels" : false, - "lineBreakAroundMultilineExpressionChainComponents" : false, - "lineBreakBeforeControlFlowKeywords" : false, - "lineBreakBeforeEachArgument" : false, - "lineBreakBeforeEachGenericRequirement" : false, - "lineLength" : 80, - "maximumBlankLines" : 1, - "multiElementCollectionTrailingCommas" : true, - "noAssignmentInExpressions" : { - "allowedFunctions" : [ - "XCTAssertNoThrow" - ] - }, - "prioritizeKeepingFunctionOutputTogether" : false, - "respectsExistingLineBreaks" : true, - "rules" : { - "AllPublicDeclarationsHaveDocumentation" : false, - "AlwaysUseLowerCamelCase" : true, - "AmbiguousTrailingClosureOverload" : false, - "BeginDocumentationCommentWithOneLineSummary" : false, - "DoNotUseSemicolons" : true, - "DontRepeatTypeInStaticProperties" : true, - "FileScopedDeclarationPrivacy" : true, - "FullyIndirectEnum" : true, - "GroupNumericLiterals" : true, - "IdentifiersMustBeASCII" : true, - "NeverForceUnwrap" : true, - "NeverUseForceTry" : true, - "NeverUseImplicitlyUnwrappedOptionals" : true, - "NoAccessLevelOnExtensionDeclaration" : true, - "NoAssignmentInExpressions" : true, - "NoBlockComments" : false, - "NoCasesWithOnlyFallthrough" : true, - "NoEmptyTrailingClosureParentheses" : true, - "NoLabelsInCasePatterns" : true, - "NoLeadingUnderscores" : false, - "NoParensAroundConditions" : true, - "NoPlaygroundLiterals" : true, - "NoVoidReturnOnFunctionSignature" : true, - "OmitExplicitReturns" : true, - "OneCasePerLine" : true, - "OneVariableDeclarationPerLine" : true, - "OnlyOneTrailingClosureArgument" : true, - "OrderedImports" : true, - "ReplaceForEachWithForLoop" : true, - "ReturnVoidInsteadOfEmptyTuple" : true, - "TypeNamesShouldBeCapitalized" : true, - "UseEarlyExits" : true, - "UseLetInEveryBoundCaseVariable" : true, - "UseShorthandTypeNames" : true, - "UseSingleLinePropertyGetter" : true, - "UseSynthesizedInitializer" : true, - "UseTripleSlashForDocumentationComments" : true, - "UseWhereClausesInForLoops" : false, - "ValidateDocumentationComments" : true - }, - "spacesBeforeEndOfLineComments": 2, - "spacesAroundRangeFormationOperators" : false, - "tabWidth" : 2, - "version" : 1 -}