Skip to content

Commit 4589723

Browse files
Merge pull request #43 from FabrizioBrancati/features/pre-commit-makefile-formatter
Add Pre-Commit, Makefile, and Formatter
2 parents e969c51 + e7cb636 commit 4589723

File tree

5 files changed

+170
-0
lines changed

5 files changed

+170
-0
lines changed

.github/CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ If you find a typo or you think that something is not well explained, please ope
3838

3939
New API should follow the rules documented in Swift's [API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/). Comment every public methods, properties, classes. Make commits as atomic as possible with understandable comment. If you are developing feature or fixing a bug, please mention the issue number (e.g. #1) in commit text.
4040

41+
## Commit Messages
42+
43+
Please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
44+
45+
To make it easier, you can use `pre-commit` and configure it with the following command:
46+
47+
```bash
48+
make pre-commit-install
49+
```
50+
51+
This will install the `pre-commit` hooks that will check your commit messages.
52+
4153
## Changelog
4254

4355
Once your changes are ready, please add an entry to the [CHANGELOG.md](https://github.com/FabrizioBrancati/Queuer/blob/main/CHANGELOG.md) file.

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: check-symlinks
8+
- id: fix-byte-order-marker
9+
- id: check-toml
10+
- id: check-yaml
11+
args: [--allow-multiple-documents]
12+
- id: end-of-file-fixer
13+
- id: mixed-line-ending
14+
# - id: no-commit-to-branch
15+
# args: [--branch, main]
16+
- id: trailing-whitespace
17+
- repo: https://github.com/crate-ci/typos
18+
rev: v1.30.0
19+
hooks:
20+
- id: typos
21+
22+
- repo: https://github.com/compilerla/conventional-pre-commit
23+
rev: v4.0.0
24+
hooks:
25+
- id: conventional-pre-commit
26+
stages: [commit-msg]
27+
args: [build, chore, ci, docs, feat, fix, perf, refactor, revert, test]

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
- Added CIHelper to run test on Linux but not on CI - [#33](https://github.com/FabrizioBrancati/Queuer/pull/33)
2929
- Added `onPause`, `onResume`, and `onCancel` closures to `ConcurrentOperation` class - [#37](https://github.com/FabrizioBrancati/Queuer/pull/37)
30+
- Added `pre-commit` hook [#43](https://github.com/FabrizioBrancati/Queuer/pull/43)
31+
- Added Makefile [#43](https://github.com/FabrizioBrancati/Queuer/pull/43)
32+
- Added swift-format support [#43](https://github.com/FabrizioBrancati/Queuer/pull/43)
3033

3134
### Improved
3235

Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Variables
2+
SRC_NAME=Queuer
3+
4+
# Default target
5+
.DEFAULT_GOAL := help
6+
7+
.PHONY: help
8+
help:
9+
@echo "Available targets:"
10+
@awk 'BEGIN {FS = ":.*#"} /^[a-zA-Z_-]+:.*?#/ { printf " %-20s - %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
11+
12+
.PHONY: dependencies
13+
dependencies: # Install packages using SwiftPM
14+
@echo "Installing $(SRC_NAME) dependencies..."
15+
@swift package resolve
16+
17+
.PHONY: clean
18+
clean: # Clean up generated files
19+
@echo "Cleaning up build files..."
20+
@rm -rf .build
21+
22+
.PHONY: open
23+
open: # Open the project in Xcode
24+
@echo "Opening $(SRC_NAME) project..."
25+
@open Package.swift
26+
27+
.PHONY: lint
28+
lint: # Lint the project using swift-format
29+
@echo "Linting $(SRC_NAME) project..."
30+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-format lint ./$(SRC_NAME) --recursive --configuration swift-format-config.json
31+
32+
.PHONY: format
33+
format: # Format the project using swift-format
34+
@echo "Formatting $(SRC_NAME) project..."
35+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-format format ./$(SRC_NAME) --recursive --configuration swift-format-config.json --in-place
36+
37+
.PHONY: pre-commit-install
38+
pre-commit-install: # Install pre-commit hooks
39+
@echo "Installing pre-commit hooks..."
40+
@pip install pre-commit
41+
@pre-commit install --hook-type commit-msg
42+
43+
.PHONY: setup
44+
setup: # Setup the project
45+
@echo "Setting up $(SRC_NAME) project..."
46+
@make clean
47+
@make pre-commit-install
48+
@make dependencies
49+
50+
.PHONY: test
51+
test: # Run tests
52+
@echo "Running tests..."
53+
@swift test
54+
55+
.PHONY: build
56+
build: # Build the project
57+
@echo "Building and uploading beta version..."
58+
@swift build

swift-format-config.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentConditionalCompilationBlocks" : true,
6+
"indentSwitchCaseLabels" : true,
7+
"indentation" : {
8+
"spaces" : 2
9+
},
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : false,
13+
"lineBreakBeforeEachGenericRequirement" : false,
14+
"lineLength" : 180,
15+
"maximumBlankLines" : 1,
16+
"multiElementCollectionTrailingCommas" : false,
17+
"noAssignmentInExpressions" : {
18+
"allowedFunctions" : [
19+
"XCTAssertNoThrow"
20+
]
21+
},
22+
"prioritizeKeepingFunctionOutputTogether" : false,
23+
"respectsExistingLineBreaks" : true,
24+
"rules" : {
25+
"AllPublicDeclarationsHaveDocumentation" : false,
26+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
27+
"AlwaysUseLowerCamelCase" : true,
28+
"AmbiguousTrailingClosureOverload" : true,
29+
"BeginDocumentationCommentWithOneLineSummary" : false,
30+
"DoNotUseSemicolons" : true,
31+
"DontRepeatTypeInStaticProperties" : true,
32+
"FileScopedDeclarationPrivacy" : true,
33+
"FullyIndirectEnum" : true,
34+
"GroupNumericLiterals" : true,
35+
"IdentifiersMustBeASCII" : true,
36+
"NeverForceUnwrap" : false,
37+
"NeverUseForceTry" : false,
38+
"NeverUseImplicitlyUnwrappedOptionals" : false,
39+
"NoAccessLevelOnExtensionDeclaration" : true,
40+
"NoAssignmentInExpressions" : true,
41+
"NoBlockComments" : true,
42+
"NoCasesWithOnlyFallthrough" : true,
43+
"NoEmptyTrailingClosureParentheses" : true,
44+
"NoLabelsInCasePatterns" : true,
45+
"NoLeadingUnderscores" : false,
46+
"NoParensAroundConditions" : true,
47+
"NoPlaygroundLiterals" : true,
48+
"NoVoidReturnOnFunctionSignature" : true,
49+
"OmitExplicitReturns" : false,
50+
"OneCasePerLine" : true,
51+
"OneVariableDeclarationPerLine" : true,
52+
"OnlyOneTrailingClosureArgument" : true,
53+
"OrderedImports" : true,
54+
"ReplaceForEachWithForLoop" : true,
55+
"ReturnVoidInsteadOfEmptyTuple" : true,
56+
"TypeNamesShouldBeCapitalized" : true,
57+
"UseEarlyExits" : false,
58+
"UseExplicitNilCheckInConditions" : true,
59+
"UseLetInEveryBoundCaseVariable" : true,
60+
"UseShorthandTypeNames" : true,
61+
"UseSingleLinePropertyGetter" : true,
62+
"UseSynthesizedInitializer" : true,
63+
"UseTripleSlashForDocumentationComments" : true,
64+
"UseWhereClausesInForLoops" : false,
65+
"ValidateDocumentationComments" : false
66+
},
67+
"spacesAroundRangeFormationOperators" : false,
68+
"tabWidth" : 2,
69+
"version" : 1
70+
}

0 commit comments

Comments
 (0)