Skip to content

Commit

Permalink
ci: add ci (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
izik1 authored Apr 19, 2023
1 parent 2fe8046 commit 5818046
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 11 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/swift-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Swift CI
on:
pull_request:
push:
branches: ['main']

jobs:
format:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: Install swift-format
run: brew install swift-format
- name: Format
run: swift format lint --strict --configuration .swift-format.json --recursive --parallel Sources/ Tests/ Examples/ Package.swift

build:
strategy:
matrix:
swift: ["5.7"]
runs-on: macos-11
steps:
- uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}

- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: sdk/swift/.build
key: ${{ runner.os }}-${{ matrix.swift }}-spm-${{ github.job }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.swift }}-spm-
- name: Build
run: swift build

test:
strategy:
matrix:
swift: ["5.7"]
needs: [build]
runs-on: macos-11
steps:
- uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: sdk/swift/.build
key: ${{ runner.os }}-${{ matrix.swift }}-spm-${{ github.job }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.swift }}-spm-
- name: Test
run: swift test
6 changes: 0 additions & 6 deletions .swift-format

This file was deleted.

57 changes: 57 additions & 0 deletions .swift-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"fileScopedDeclarationPrivacy": {
"accessLevel": "private"
},
"indentation": {
"spaces": 4
},
"indentConditionalCompilationBlocks": true,
"indentSwitchCaseLabels": false,
"lineBreakAroundMultilineExpressionChainComponents": false,
"lineBreakBeforeControlFlowKeywords": false,
"lineBreakBeforeEachArgument": false,
"lineBreakBeforeEachGenericRequirement": false,
"lineLength": 120,
"maximumBlankLines": 1,
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoBlockComments": false,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoParensAroundConditions": true,
"NoVoidReturnOnFunctionSignature": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"UseEarlyExits": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": false
},
"tabWidth": 8,
"version": 1
}

24 changes: 19 additions & 5 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
included:
- Examples/
- Sources/
- Sources/Hedera/
- Tests/

excluded:
- .build/
- Sources/Hedera/Status.swift

disabled_rules:
# TODO: re-enable once the project is deemed complete
- todo
# swift-format disagrees, swift-format has its own style lints.
- opening_brace
- trailing_comma
# coverered by swift-format.
- line_length
# not a very useful lint honestly.
- cyclomatic_complexity

opt_in_rules:
- anyobject_protocol
# deprecated & will be removed
# - anyobject_protocol
- anonymous_argument_in_multiline_closure
- array_init
- attributes
- balanced_xctest_lifecycle
- capture_variable
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- conditional_returns_on_newline
# - conditional_returns_on_newline
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
Expand All @@ -38,6 +47,11 @@ opt_in_rules:
- expiring_todo
- explicit_acl
- explicit_top_level_acl
- extension_access_modifier
# this conflicts with `explicit_acl` by making the ACL redundant
# - extension_access_modifier
- fallthrough
- fatal_error_message

analyzer_rules:
- capture_variable

0 comments on commit 5818046

Please sign in to comment.