diff --git a/.codecov.yml b/.codecov.yml index 2892798a..a752c245 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -23,3 +23,4 @@ comment: ignore: - Tests + - Checkouts diff --git a/.github/actions/checkout-swift-headers/action.yml b/.github/actions/checkout-swift-headers/action.yml index e0989f56..400728d4 100644 --- a/.github/actions/checkout-swift-headers/action.yml +++ b/.github/actions/checkout-swift-headers/action.yml @@ -6,17 +6,24 @@ description: | inputs: path: description: Relative path under $GITHUB_WORKSPACE to place the repository - required: true - swift-version-major: - description: The Swift toolchain major version. - required: true - swift-version-minor: - description: The Swift toolchain minor version. - required: true + required: false + default: '' + swift-version: + description: "Swift version as major.minor (e.g. 6.1). Detected from swift --version if not set." + required: false + default: '' runs: using: "composite" steps: - name: Checkout Swift headers - run: ./Scripts/clone-swift.sh --path "${{ inputs.path }}" --swift-version "${{ inputs.swift-version-major }}.${{ inputs.swift-version-minor }}" + run: | + ARGS="" + if [ -n "${{ inputs.path }}" ]; then + ARGS="$ARGS --path ${{ inputs.path }}" + fi + if [ -n "${{ inputs.swift-version }}" ]; then + ARGS="$ARGS --swift-version ${{ inputs.swift-version }}" + fi + ./Scripts/clone-swift.sh $ARGS shell: bash diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml index 1f3d6073..8611b8c6 100644 --- a/.github/workflows/compatibility_tests.yml +++ b/.github/workflows/compatibility_tests.yml @@ -33,20 +33,8 @@ jobs: - name: Set up build environment run: Scripts/CI/darwin_setup_build.sh shell: bash - - name: Swift version - id: swift-version - run: | - swift --version - SWIFT_VERSION=$(swift --version 2>/dev/null | grep -oE 'Swift version [0-9]+\.[0-9]+' | grep -oE '[0-9]+\.[0-9]+') - echo "major=$(echo $SWIFT_VERSION | cut -d. -f1)" >> $GITHUB_OUTPUT - echo "minor=$(echo $SWIFT_VERSION | cut -d. -f2)" >> $GITHUB_OUTPUT - shell: bash - name: Checkout Swift headers uses: ./.github/actions/checkout-swift-headers - with: - path: .build/checkouts/swift - swift-version-major: ${{ steps.swift-version.outputs.major }} - swift-version-minor: ${{ steps.swift-version.outputs.minor }} - name: Run tests against Apple's AttributeGraph on macOS via SwiftPM run: | swift test \ diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 55b3a113..2397b7e2 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -33,23 +33,11 @@ jobs: uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main with: xcode-version: ${{ matrix.xcode-version }} - - name: Swift version - id: swift-version - run: | - swift --version - SWIFT_VERSION=$(swift --version 2>/dev/null | grep -oE 'Swift version [0-9]+\.[0-9]+' | grep -oE '[0-9]+\.[0-9]+') - echo "major=$(echo $SWIFT_VERSION | cut -d. -f1)" >> $GITHUB_OUTPUT - echo "minor=$(echo $SWIFT_VERSION | cut -d. -f2)" >> $GITHUB_OUTPUT - shell: bash - name: Set up build environment run: Scripts/CI/darwin_setup_build.sh shell: bash - name: Checkout Swift headers uses: ./.github/actions/checkout-swift-headers - with: - path: .build/checkouts/swift - swift-version-major: ${{ steps.swift-version.outputs.major }} - swift-version-minor: ${{ steps.swift-version.outputs.minor }} - name: Build in debug mode on iOS run: | xcodebuild build \ diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index cf9f9432..415b00fa 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -32,20 +32,8 @@ jobs: - name: Set up build environment run: Scripts/CI/darwin_setup_build.sh shell: bash - - name: Swift version - id: swift-version - run: | - swift --version - SWIFT_VERSION=$(swift --version 2>/dev/null | grep -oE 'Swift version [0-9]+\.[0-9]+' | grep -oE '[0-9]+\.[0-9]+') - echo "major=$(echo $SWIFT_VERSION | cut -d. -f1)" >> $GITHUB_OUTPUT - echo "minor=$(echo $SWIFT_VERSION | cut -d. -f2)" >> $GITHUB_OUTPUT - shell: bash - name: Checkout Swift headers uses: ./.github/actions/checkout-swift-headers - with: - path: .build/checkouts/swift - swift-version-major: ${{ steps.swift-version.outputs.major }} - swift-version-minor: ${{ steps.swift-version.outputs.minor }} - name: Build and run tests in debug mode with coverage run: | swift test \ diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b1b88051..2dbfdea0 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -21,19 +21,8 @@ jobs: container: swift:${{ matrix.swift_version }}-jammy steps: - uses: actions/checkout@v4 - - name: Swift version - id: swift-version - run: | - which swift && swift --version - echo "major=$(echo ${{ matrix.swift_version }} | cut -d. -f1)" >> $GITHUB_OUTPUT - echo "minor=$(echo ${{ matrix.swift_version }} | cut -d. -f2)" >> $GITHUB_OUTPUT - shell: bash - name: Checkout Swift headers uses: ./.github/actions/checkout-swift-headers - with: - path: .build/checkouts/swift - swift-version-major: ${{ steps.swift-version.outputs.major }} - swift-version-minor: ${{ steps.swift-version.outputs.minor }} - name: Building and running tests in debug mode with coverage run: | swift test \ diff --git a/.gitignore b/.gitignore index 4b3e9a5a..b364717c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ DerivedData/ .netrc coverage.txt TODO.md +Checkouts/ .ag_template/ build/ .ag_repo/ diff --git a/LICENSE b/LICENSE index bb1944dd..9607bec2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023-2025 Kyle-Ye +Copyright (c) 2023-2026 Kyle-Ye Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Package.swift b/Package.swift index 95e3fbea..42eaf7ce 100644 --- a/Package.swift +++ b/Package.swift @@ -136,7 +136,7 @@ let isXcodeEnv = envStringValue("__CFBundleIdentifier", searchInDomain: false) = let development = envBoolValue("DEVELOPMENT", default: false) let warningsAsErrorsCondition = envBoolValue("WERROR", default: isXcodeEnv && development) -let swiftCheckoutPath = "\(Context.packageDirectory)/.build/checkouts/swift" +let swiftCheckoutPath = "\(Context.packageDirectory)/Checkouts/swift" let swiftCorelibsPath = envStringValue("LIB_SWIFT_PATH") ?? "\(Context.packageDirectory)/Sources/SwiftCorelibs/include" let releaseVersion = envIntValue("TARGET_RELEASE", default: 2024) diff --git a/Plugins/CloneSwiftPlugin/plugin.swift b/Plugins/CloneSwiftPlugin/plugin.swift index dc441792..b10a350a 100644 --- a/Plugins/CloneSwiftPlugin/plugin.swift +++ b/Plugins/CloneSwiftPlugin/plugin.swift @@ -5,7 +5,7 @@ import PackagePlugin struct CloneSwiftPlugin: BuildToolPlugin { func createBuildCommands(context: PluginContext, target: Target) throws -> [Command] { let packageDir = context.package.directoryURL - let checkoutPath = packageDir.appending(path: ".build/checkouts/swift") + let checkoutPath = packageDir.appending(path: "Checkouts/swift") let script = packageDir.appending(path: "Scripts/clone-swift.sh") let env = ProcessInfo.processInfo.environment diff --git a/Scripts/clone-swift.sh b/Scripts/clone-swift.sh index d3464b70..431d8edd 100755 --- a/Scripts/clone-swift.sh +++ b/Scripts/clone-swift.sh @@ -27,7 +27,7 @@ set -e # Default values -CHECKOUT_PATH=".build/checkouts/swift" +CHECKOUT_PATH="Checkouts/swift" SWIFT_VERSION="" # Parse arguments @@ -63,8 +63,8 @@ fi SWIFT_VERSION_MAJOR=$(echo "$SWIFT_VERSION" | cut -d. -f1) SWIFT_VERSION_MINOR=$(echo "$SWIFT_VERSION" | cut -d. -f2) -# Skip if checkout already exists with the expected header -if [ -f "$CHECKOUT_PATH/include/swift/Runtime/Metadata.h" ]; then +# Skip if checkout directory already exists and is not empty +if [ -d "$CHECKOUT_PATH" ] && [ -n "$(ls -A "$CHECKOUT_PATH")" ]; then echo "Swift headers already exist at $CHECKOUT_PATH, skipping clone." exit 0 fi