diff --git a/.github/workflows/ci-linter-swiftformat.yml b/.github/workflows/ci-linter-swiftformat.yml index 2c07669fa3..b2c84f81d7 100644 --- a/.github/workflows/ci-linter-swiftformat.yml +++ b/.github/workflows/ci-linter-swiftformat.yml @@ -14,7 +14,7 @@ concurrency: jobs: swift_format: - name: lint + name: swiftformat runs-on: [self-hosted, iOS] steps: @@ -31,4 +31,4 @@ jobs: swiftformat --version - swiftformat --lint . + swiftformat --lint --reporter github-actions-log . diff --git a/.github/workflows/ci-linter-swiftlint.yml b/.github/workflows/ci-linter-swiftlint.yml index 19fa85baf6..61ac603f3e 100644 --- a/.github/workflows/ci-linter-swiftlint.yml +++ b/.github/workflows/ci-linter-swiftlint.yml @@ -14,7 +14,7 @@ concurrency: jobs: swift_format: - name: lint + name: swiftlint runs-on: [self-hosted, iOS] steps: diff --git a/Makefile b/Makefile index 7b37b6fe80..9bc0802767 100644 --- a/Makefile +++ b/Makefile @@ -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 . diff --git a/Scripts/SwiftLintRunScript.sh b/Scripts/SwiftLintRunScript.sh index 318025ccf3..c3b717c954 100755 --- a/Scripts/SwiftLintRunScript.sh +++ b/Scripts/SwiftLintRunScript.sh @@ -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 diff --git a/Tuist/.swiftformat b/Tuist/.swiftformat index b2d3acdb60..f99bb59c99 100644 --- a/Tuist/.swiftformat +++ b/Tuist/.swiftformat @@ -2,4 +2,5 @@ # Copyright 2023 APF France handicap # SPDX-License-Identifier: Apache-2.0 +--exclude Dependencies, Signing --disable acronyms