name: build on: push: branches: - main - develop pull_request: jobs: check-for-changes: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.changed_files > 0 steps: - run: echo "PR has changes, proceeding with build jobs" macos: needs: check-for-changes strategy: fail-fast: false matrix: macos: - 15 xcode: - 16.3 runs-on: macos-${{ matrix.macos }} steps: - name: Select Xcode version uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode }} - name: Checkout uses: actions/checkout@v5 - name: Build and Test run: | # Set up a git user for the git tests git config user.name "test user" git config user.email "test.user@noreply.com" xcodebuild -project SwiftFormat.xcodeproj -scheme "SwiftFormat (Framework)" -sdk macosx clean build test -enableCodeCoverage YES -derivedDataPath Build/ cd Build/Build/ProfileData cd $(ls -d */|head -n 1) directory=${PWD##*/} pathCoverage=Build/Build/ProfileData/${directory}/Coverage.profdata cd ../../../../ xcrun llvm-cov export -format="lcov" -instr-profile $pathCoverage Build/Build/Products/Debug/SwiftFormat.framework/SwiftFormat > info.lcov - name: Codecov uses: codecov/codecov-action@v7 with: # the token is optional for a public repo, but including it anyway token: a47579fa-9a2a-4c48-b557-aa725c6b5f92 env_vars: MD_APPLE_SDK_ROOT,RUNNER_OS,RUNNER_ARCH linux: needs: check-for-changes strategy: fail-fast: false matrix: swiftver: - swift:5.7 - swift:6.0 swiftos: - focal runs-on: ubuntu-latest container: image: ${{ format('{0}-{1}', matrix.swiftver, matrix.swiftos) }} options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --security-opt apparmor=unconfined steps: - name: Checkout uses: actions/checkout@v5 - name: Build and Test run: | # Set up a git user for the git tests git config --global user.name "test user" git config --global user.email "test.user@noreply.com" # Needed to be allowed to run git commands in the tests # https://github.com/actions/runner-images/issues/6775 git config --global --add safe.directory /__w/SwiftFormat/SwiftFormat swift test --enable-test-discovery windows: needs: check-for-changes strategy: fail-fast: false matrix: hosts: [x86_64-unknown-windows-msvc, aarch64-unknown-windows-msvc] swift: - version: development # Version used by the release workflow (includes static linking support) build: DEVELOPMENT-SNAPSHOT-2025-08-27-a runs-on: windows-latest name: windows (${{ matrix.swift.build }}) steps: - uses: compnerd/gha-setup-swift@main with: swift-version: ${{ matrix.swift.version }} swift-build: ${{ matrix.swift.build }} - uses: actions/checkout@v5 - run: swift test command-line-tool: needs: check-for-changes strategy: fail-fast: false matrix: macos: - 15 xcode: - 16.3 runs-on: macos-${{ matrix.macos }} steps: - name: Select Xcode version uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode }} - name: Checkout uses: actions/checkout@v5 - name: Build Command Line Tool run: xcodebuild -project SwiftFormat.xcodeproj -scheme "SwiftFormat (Command Line Tool)" -sdk macosx clean build swiftformat-for-xcode: needs: check-for-changes strategy: fail-fast: false matrix: macos: - 15 xcode: - 16.3 runs-on: macos-${{ matrix.macos }} steps: - name: Select Xcode version uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode }} - name: Checkout uses: actions/checkout@v5 - name: Build Swift Format for Xcode app run: xcodebuild -project SwiftFormat.xcodeproj -scheme "SwiftFormat for Xcode" -sdk macosx clean build editor-extension: needs: check-for-changes strategy: fail-fast: false matrix: macos: - 15 xcode: - 16.3 runs-on: macos-${{ matrix.macos }} steps: - name: Select Xcode version uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode }} - name: Checkout uses: actions/checkout@v5 - name: Build Editor Extension run: xcodebuild -project SwiftFormat.xcodeproj -scheme "SwiftFormat (Editor Extension)" -sdk macosx clean build regression-tests: needs: check-for-changes strategy: fail-fast: false matrix: macos: - 15 xcode: - 16.3 runs-on: macos-${{ matrix.macos }} steps: - name: Select Xcode version uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode }} - name: Checkout uses: actions/checkout@v5 - name: Run Regression Tests run: xcodebuild -project SwiftFormat.xcodeproj -scheme "Regression Tests" test performance-tests: needs: check-for-changes strategy: fail-fast: false matrix: macos: - 15 xcode: - 16.3 runs-on: macos-${{ matrix.macos }} steps: - name: Select Xcode version uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: ${{ matrix.xcode }} - name: Checkout uses: actions/checkout@v5 - name: Build Target run: xcodebuild -project SwiftFormat.xcodeproj -scheme "Performance Tests" build