Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/improve-makefile-experience'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Dec 10, 2023
2 parents 6dee941 + dd75375 commit 8ea19df
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-linter-swiftformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

jobs:
swift_format:
name: lint
name: swiftformat
runs-on: [self-hosted, iOS]

steps:
Expand All @@ -31,4 +31,4 @@ jobs:
swiftformat --version
swiftformat --lint .
swiftformat --lint --reporter github-actions-log .
2 changes: 1 addition & 1 deletion .github/workflows/ci-linter-swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

jobs:
swift_format:
name: lint
name: swiftlint
runs-on: [self-hosted, iOS]

steps:
Expand Down
63 changes: 62 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,69 @@
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

#
# MARK: - Options
#

GENERATE_MODULES_AS_FRAMEWORKS_FOR_DEBUG ?= TRUE
TURN_OFF_LINTERS ?= FALSE


#
# MARK: - Build targets
#

fetch:
@echo "Fetching dependencies..."
@tuist fetch

config:
@echo "Generating project..."
@TUIST_GENERATE_MODULES_AS_FRAMEWORKS_FOR_DEBUG=$(GENERATE_MODULES_AS_FRAMEWORKS_FOR_DEBUG) \
TUIST_TURN_OFF_LINTERS=$(TURN_OFF_LINTERS) \
tuist generate

build:
@echo "Building project..."
@TUIST_GENERATE_MODULES_AS_FRAMEWORKS_FOR_DEBUG=$(GENERATE_MODULES_AS_FRAMEWORKS_FOR_DEBUG) \
TUIST_TURN_OFF_LINTERS=$(TURN_OFF_LINTERS) \
tuist build

clean:
@echo "Cleaning project..."
@tuist clean
@rm -rf .build
@rm -rf ~/Library/Developer/Xcode/DerivedData
@gfind . -type d -name "*.xcodeproj" -exec rm -rf {} +


#
# MARK: - Tools targets
#

setup:
@echo "Setting up dev environment..."
@brew update && brew upgrade
@brew install swiftformat swiftlint fastlane
@brew install tuist --no-quarantine

sync_certificates:
@echo "Syncing certificates..."
@export FASTLANE_SKIP_UPDATE_CHECK=1
@fastlane sync_certificates

git_hooks:
@echo "Installing pre-commit hooks..."
@brew install pre-commit
@pre-commit install
@echo "Installing pre-commit hooks...✅"

format:
@echo "Formatting code..."
@swiftlint --quiet --fix
@swiftformat .

lint:
@echo "Linting code..."
@-swiftlint --quiet --fix && swiftlint --quiet --progress
@echo ""
@-swiftformat --lint .
18 changes: 1 addition & 17 deletions Scripts/SwiftLintRunScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,8 @@ if ! command -v swiftlint &> /dev/null; then
exit 1
fi

if ! command -v gxargs &> /dev/null; then
echo "error: gxargs not installed, download from https://www.gnu.org/software/findutils/"
echo "error: or install with brew install findutils"
exit 1
fi

SCRIPT_PATH=$(realpath "$0")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
ROOT_DIR=$(realpath "$SCRIPT_DIR/..")

echo "SCRIPT_PATH: $SCRIPT_PATH"
echo "ROOT_DIR: $ROOT_DIR"
echo "SCRIPT_DIR: $SCRIPT_DIR"

which swiftlint
which gxargs

git diff --name-status origin/main \
| grep -E "^A|^M" | sed "s/^[AM]\t//g" \
| grep -E "\.swift\$$" \
| gxargs -I '{}' -d '\n' --no-run-if-empty swiftlint --config $ROOT_DIR/.swiftlint.yml --reporter xcode $ROOT_DIR/{}
swiftlint --config $ROOT_DIR/.swiftlint.yml --reporter xcode
1 change: 1 addition & 0 deletions Tuist/.swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

--exclude Dependencies, Signing
--disable acronyms

0 comments on commit 8ea19df

Please sign in to comment.