From 108a9cabf27974e368f93284afc15cfdbc91feb5 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Tue, 30 Dec 2025 11:35:21 +0400 Subject: [PATCH 1/2] chore: switch from Makefile to Mise --- .github/workflows/danger.yml | 16 ++++-- .gitignore | 1 + .../contents.xcworkspacedata | 7 --- Makefile | 19 ------- Mintfile | 2 - Package@swift-5.7.swift | 16 ------ Package@swift-5.8.swift | 16 ------ Package@swift-5.9.swift | 16 ------ hooks/pre-commit | 38 ------------- mise.toml | 10 ++++ mise/tasks/install.sh | 57 +++++++++++++++++++ mise/tasks/lint | 13 +++++ 12 files changed, 91 insertions(+), 120 deletions(-) delete mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata delete mode 100644 Makefile delete mode 100644 Mintfile delete mode 100644 Package@swift-5.7.swift delete mode 100644 Package@swift-5.8.swift delete mode 100644 Package@swift-5.9.swift delete mode 100755 hooks/pre-commit create mode 100644 mise.toml create mode 100755 mise/tasks/install.sh create mode 100755 mise/tasks/lint diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 55a4794..a22efbd 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -1,4 +1,4 @@ -name: Danger +name: danger on: pull_request: @@ -8,6 +8,10 @@ env: LC_CTYPE: en_US.UTF-8 LANG: en_US.UTF-8 +permissions: + contents: read + pull-requests: write + jobs: run-danger: runs-on: ubuntu-latest @@ -15,17 +19,17 @@ jobs: - name: ruby setup uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.4 + ruby-version: 4.0.0 bundler-cache: true - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup gems run: | gem install bundler - bundle install --clean --path vendor/bundle + bundle config set clean true + bundle config set path 'vendor/bundle' + bundle install - name: danger env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} - run: bundle exec danger --verbose \ No newline at end of file diff --git a/.gitignore b/.gitignore index 330d167..0649719 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,4 @@ fastlane/test_output # https://github.com/johnno1962/injectionforxcode iOSInjectionProject/ +.swiftpm/ \ No newline at end of file diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Makefile b/Makefile deleted file mode 100644 index de1897f..0000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -all: bootstrap - -bootstrap: hook - mint bootstrap - -hook: - ln -sf ../../hooks/pre-commit .git/hooks/pre-commit - chmod +x .git/hooks/pre-commit - -mint: - mint bootstrap - -lint: - mint run swiftlint - -fmt: - mint run swiftformat Sources Tests - -.PHONY: all bootstrap hook mint lint fmt diff --git a/Mintfile b/Mintfile deleted file mode 100644 index e2cdefa..0000000 --- a/Mintfile +++ /dev/null @@ -1,2 +0,0 @@ -nicklockwood/SwiftFormat@0.52.7 -realm/SwiftLint@0.53.0 \ No newline at end of file diff --git a/Package@swift-5.7.swift b/Package@swift-5.7.swift deleted file mode 100644 index 18686ab..0000000 --- a/Package@swift-5.7.swift +++ /dev/null @@ -1,16 +0,0 @@ -// swift-tools-version: 5.7 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "transitions", - platforms: [.iOS(.v12)], - products: [ - .library(name: "Transitions", targets: ["Transitions"]), - ], - targets: [ - .target(name: "Transitions"), - .testTarget(name: "TransitionsTests", dependencies: ["Transitions"]), - ] -) diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift deleted file mode 100644 index 0dcccb9..0000000 --- a/Package@swift-5.8.swift +++ /dev/null @@ -1,16 +0,0 @@ -// swift-tools-version: 5.8 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "transitions", - platforms: [.iOS(.v12)], - products: [ - .library(name: "Transitions", targets: ["Transitions"]), - ], - targets: [ - .target(name: "Transitions"), - .testTarget(name: "TransitionsTests", dependencies: ["Transitions"]), - ] -) diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift deleted file mode 100644 index a537060..0000000 --- a/Package@swift-5.9.swift +++ /dev/null @@ -1,16 +0,0 @@ -// swift-tools-version: 5.9 -// The swift-tools-version declares the minimum version of Swift required to build this package. - -import PackageDescription - -let package = Package( - name: "transitions", - platforms: [.iOS(.v12)], - products: [ - .library(name: "Transitions", targets: ["Transitions"]), - ], - targets: [ - .target(name: "Transitions"), - .testTarget(name: "TransitionsTests", dependencies: ["Transitions"]), - ] -) diff --git a/hooks/pre-commit b/hooks/pre-commit deleted file mode 100755 index 956fdcb..0000000 --- a/hooks/pre-commit +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -git diff --diff-filter=d --staged --name-only | grep -e '\.swift$' | while read line; do - if [[ $line == *"/Generated"* ]]; then - echo "IGNORING GENERATED FILE: " "$line"; - else - mint run swiftformat swiftformat "${line}"; - git add "$line"; - fi -done - -LINT=$(which mint) -if [[ -e "${LINT}" ]]; then - # Export files in SCRIPT_INPUT_FILE_$count to lint against later - count=0 - while IFS= read -r file_path; do - export SCRIPT_INPUT_FILE_$count="$file_path" - count=$((count + 1)) - done < <(git diff --name-only --cached --diff-filter=d | grep ".swift$") - export SCRIPT_INPUT_FILE_COUNT=$count - - if [ "$count" -eq 0 ]; then - echo "No files to lint!" - exit 0 - fi - - echo "Found $count lintable files! Linting now.." - mint run swiftlint --use-script-input-files --strict --config .swiftlint.yml - RESULT=$? # swiftline exit value is number of errors - - if [ $RESULT -eq 0 ]; then - echo "🎉 Well done. No violation." - fi - exit $RESULT -else - echo "⚠️ WARNING: SwiftLint not found" - echo "⚠️ You might want to edit .git/hooks/pre-commit to locate your swiftlint" - exit 0 -fi \ No newline at end of file diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..9e7282a --- /dev/null +++ b/mise.toml @@ -0,0 +1,10 @@ +[tools] +git-cliff = "2.9.1" +swiftlint = "0.62.2" +swiftformat = "0.58.7" + +[settings] +experimental = true + +[hooks] +postinstall = "mise run install" \ No newline at end of file diff --git a/mise/tasks/install.sh b/mise/tasks/install.sh new file mode 100755 index 0000000..aeba03b --- /dev/null +++ b/mise/tasks/install.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -e + +echo "🔧 Installing git hooks..." + +# Find git repository root +GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) + +if [ -z "$GIT_ROOT" ]; then + echo "❌ Error: Not a git repository" + exit 1 +fi + +echo "📁 Git root: $GIT_ROOT" + +# Create hooks directory if it doesn't exist +mkdir -p "$GIT_ROOT/.git/hooks" + +# Create pre-commit hook +cat > "$GIT_ROOT/.git/hooks/pre-commit" <<'HOOK_EOF' +#!/bin/bash + +echo "🔍 Running linters..." + +echo "📝 Formatting staged Swift files..." +git diff --diff-filter=d --staged --name-only | grep -e '\.swift$' | while read line; do + if [[ $line == *"/Generated"* ]]; then + echo "⏭️ Skipping generated file: $line" + else + echo "✨ Formatting: $line" + mise exec swiftformat -- swiftformat "${line}" + git add "$line" + fi +done + +if ! mise run lint; then + echo "❌ Lint failed. Please fix the issues before committing." + echo "💡 Tip: Run 'mise run format' to auto-fix some issues" + echo "⚠️ To skip this hook, use: git commit --no-verify" + exit 1 +fi + +echo "✅ All checks passed!" +exit 0 +HOOK_EOF + +chmod +x "$GIT_ROOT/.git/hooks/pre-commit" + +echo "✅ Git hooks installed successfully!" +echo "📍 Hook location: $GIT_ROOT/.git/hooks/pre-commit" +echo "" +echo "Pre-commit hook will:" +echo " 1. Format staged Swift files (except /Generated)" +echo " 2. Run mise lint" +echo "" +echo "To skip the hook, use: git commit --no-verify" \ No newline at end of file diff --git a/mise/tasks/lint b/mise/tasks/lint new file mode 100755 index 0000000..d0c3975 --- /dev/null +++ b/mise/tasks/lint @@ -0,0 +1,13 @@ +#!/bin/bash +#MISE description="Lint the transitions package using SwiftLint and SwiftFormat" +#MISE usage flag "-f --fix" help="Fix the fixable issues" + +set -eo pipefail + +if [ "$usage_fix" = "true" ]; then + swiftformat Sources Tests + swiftlint lint --fix --strict --config .swiftlint.yml Sources Tests +else + swiftformat Sources Tests --lint + swiftlint lint --strict --config .swiftlint.yml Sources Tests +fi \ No newline at end of file From f713c6bcadfaee502d6d5a2d45a4e5e77a062e62 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Tue, 30 Dec 2025 11:40:15 +0400 Subject: [PATCH 2/2] chore: update the ci workflow --- .github/workflows/ci.yml | 61 +++++++++++----------------------------- 1 file changed, 17 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49f5fb9..be6ca36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - dev pull_request: paths: - '.swiftlint.yml' @@ -13,18 +12,18 @@ on: - "Source/**" - "Tests/**" +permissions: + contents: read + +concurrency: + group: transitions-${{ github.head_ref }} + cancel-in-progress: true + +env: + SCHEME_NAME: "transitions" + jobs: - SwiftLint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: GitHub Action for SwiftLint - uses: norio-nomura/action-swiftlint@3.2.1 - with: - args: --strict - env: - DIFF_BASE: ${{ github.base_ref }} - iOS: + test-apple-platforms: name: ${{ matrix.name }} runs-on: ${{ matrix.runsOn }} env: @@ -34,37 +33,11 @@ jobs: fail-fast: false matrix: include: - - destination: "OS=18.1,name=iPhone 16 Pro" - name: "iOS 18.1" - xcode: "Xcode_16.1" - runsOn: macOS-14 - - destination: "OS=17.5,name=iPhone 15 Pro" - name: "iOS 17.5" - xcode: "Xcode_15.4" - runsOn: macOS-14 - - destination: "OS=17.0.1,name=iPhone 14 Pro" - name: "iOS 17.0.1" - xcode: "Xcode_15.0" - runsOn: macos-13 - - destination: "OS=16.4,name=iPhone 14 Pro" - name: "iOS 16.4" - xcode: "Xcode_14.3.1" - runsOn: macos-13 + # iOS + - { platform: iOS, name: "iOS 26.0, Xcode 26.0, Swift 6.2.0", xcode: "Xcode_26.0.1", runsOn: macOS-26, destination: "OS=26.0.1,name=iPhone 17 Pro" } + - { platform: iOS, name: "iOS 18.1", xcode: "Xcode_16.1", runsOn: macOS-14, destination: "OS=18.1,name=iPhone 16 Pro" } + - { platform: iOS, name: "iOS 17.4", xcode: "Xcode_15.3", runsOn: macOS-14, destination: "OS=17.4,name=iPhone 15 Pro" } steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: ${{ matrix.name }} - run: xcodebuild test -scheme "transitions" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 - - discover-typos: - name: Discover Typos - runs-on: macOS-13 - env: - DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer - steps: - - uses: actions/checkout@v4 - - name: Discover typos - run: | - export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.11/bin" - python3 -m pip install --upgrade pip - python3 -m pip install codespell - codespell --ignore-words-list="hart,inout,msdos,sur" --skip="./.build/*,./.git/*" + run: xcodebuild test -scheme "$SCHEME_NAME" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "test_output/${{ matrix.name }}.xcresult" || exit 1 \ No newline at end of file