Skip to content

Commit

Permalink
chore: pipelines, name, linting, formatting (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa authored Dec 8, 2021
1 parent ab50934 commit 6914020
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 140
trim_trailing_whitespace = true

[Makefile]
indent_style = tab

[*.swift]
indent_size = 2
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
86 changes: 86 additions & 0 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Merge Main



on:
push:
branches:
- main



jobs:
prepare:
name: Calculate Version and Build number
runs-on: ubuntu-20.04

outputs:
build_number: ${{ steps.short_sha.outputs.value }}
new_release: ${{ steps.semantic.outputs.new_release_published }}
release: ${{ steps.semantic.outputs.new_release_version }}
release_notes: ${{ steps.semantic.outputs.new_release_notes }}

steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.ACCESS_TOKEN }}

- uses: cycjimmy/semantic-release-action@v2
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
dry_run: true

- name: Git Short sha
id: short_sha
run: echo "::set-output name=value::$(git rev-parse --short HEAD)"


dev-release:
if: needs.prepare.outputs.new_release == 'true'

name: Dev Release
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- name: Create Pre Release
uses: actions/create-release@v1
env:
BUILD: ${{ needs.prepare.outputs.build_number }}
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
VERSION: ${{ needs.prepare.outputs.release }}
with:
tag_name: ${{ env.VERSION }}.${{ env.BUILD }}
release_name: ${{ env.VERSION }}.${{ env.BUILD }}
body: ${{ github.event.head_commit.message }}
prerelease: true


draft-release:
if: needs.prepare.outputs.new_release == 'true'

name: Draft Release
runs-on: ubuntu-20.04

needs:
- prepare

steps:
- name: Delete Previous drafts
uses: hugo19941994/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

- name: Create Draft Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
tag_name: ${{ needs.prepare.outputs.release }}
release_name: ${{ needs.prepare.outputs.release }}
body: ${{ needs.prepare.outputs.release_notes }}
draft: true
32 changes: 32 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pull Request



on:
pull_request:
branches:
- main



jobs:
validate:
name: Validate
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
id: cache
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}-${{ github.workspace }}-tmp
restore-keys: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}-${{ github.workspace }}-tmp

- name: Package Resolve
if: steps.cache.outputs.cache-hit != 'true'
run: make resolve

- name: Build for test
run: make build
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
15 changes: 15 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"branches": ["main"],
"tagFormat": "${version}",
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"type": "chore", "release": "patch"}
]
}],
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
54 changes: 54 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentation" : {
"spaces" : 2
},
"indentConditionalCompilationBlocks" : true,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : false,
"lineBreakBeforeEachGenericRequirement" : false,
"lineLength" : 140,
"maximumBlankLines" : 1,
"prioritizeKeepingFunctionOutputTogether" : true,
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLowerCamelCase" : true,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : true,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : false,
"OneCasePerLine" : false,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseLetInEveryBoundCaseVariable" : true,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"ValidateDocumentationComments" : false
},
"tabWidth" : 2,
"version" : 1
}
106 changes: 106 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
excluded:
- .build
- .swiftpm
- Tests

disabled_rules:
- discarded_notification_center_observer
- notification_center_detachment
- orphaned_doc_comment
- todo
- unused_capture_list

opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- colon # promote to error
- convenience_type
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- fatal_error_message
- first_where
- force_unwrapping
- implicitly_unwrapped_optional
- indentation_width
- last_where
- legacy_random
- literal_expression_end_indentation
- multiline_arguments
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- operator_usage_whitespace
- overridden_super_call
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- redundant_nil_coalescing
- redundant_type_annotation
- strict_fileprivate
- toggle_bool
- trailing_closure
- unneeded_parentheses_in_closure_argument
- unused_import
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- yoda_condition


custom_rules:
array_constructor:
name: "Array/Dictionary initializer"
regex: '[let,var] .+ = (\[.+\]\(\))'
capture_group: 1
message: "Use explicit type annotation when initializing empty arrays and dictionaries"
severity: warning


attributes:
always_on_same_line:
- "@IBSegueAction"
- "@IBAction"
- "@NSManaged"
- "@objc"

force_cast: warning
force_try: warning
function_body_length:
warning: 60

legacy_hashing: error

identifier_name:
excluded:
- i
- id
- x
- y
- z

indentation_width:
indentation_width: 2

line_length:
ignores_urls: true
ignores_function_declarations: true
ignores_comments: true

multiline_arguments:
first_argument_location: next_line
only_enforce_after_first_closure_on_first_line: true

private_over_fileprivate:
validate_extensions: true

trailing_whitespace:
ignores_empty_lines: false
ignores_comments: true

vertical_whitespace:
max_empty_lines: 2
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
K=kubectl

.PHONY: help clean update build build-dev docker-build docker-run start-proxies stop-proxies

help: # The following lines will print the available commands when entering just 'make'
ifeq ($(UNAME), Linux)
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
else
@awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \
$(MAKEFILE_LIST) | grep -v '@awk' | sort
endif

clean: ### Removes the tracking of using packages
rm -rf .build
rm -rf Package.resolved

resolve: ### Fetch packages
swift package resolve

update: ### Updates the project dependencies
swift package update

build: resolve ### Compiles the code with release flags
swift build -c release

build: resolve ### Compiles the code in debug mode
swift build
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "YData",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "YData",
targets: ["YData"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "YData",
dependencies: []),
.testTarget(
name: "Tests",
dependencies: ["YData"])
]
)
Loading

0 comments on commit 6914020

Please sign in to comment.