Git Product home page Git Product logo

swift-source-compat-suite's Introduction

Swift Source Compatibility Suite

Source compatibility is a strong goal for future Swift releases. To aid in this goal, a community owned source compatibility test suite serves to regression test changes to the compiler against a (gradually increasing) corpus of Swift source code. Projects added to this test suite are periodically built against the latest development versions of Swift as part of Swift's continuous integration system, allowing Swift compiler developers to understand the compatibility impact their changes have on real-world Swift projects.

Python Support

The Source compatibility suite currently supports Python 3.8+. You may experience performance issues if you attempt to execute any of the associated files with a lesser version of Python 3.

Current List of Projects

The current list of projects can be viewed on Swift.org.

Adding Projects

The Swift source compatibility test suite is community driven, meaning that open source Swift project owners are encouraged to submit their projects that meet the acceptance criteria for inclusion in the test suite. Projects added to the suite serve as general source compatibility tests and are afforded greater protection against unintentional source breakage in future Swift releases.

Acceptance Criteria

To be accepted into the Swift source compatibility test suite, a project must:

  1. Target Linux, macOS, or iOS/tvOS/watchOS device
  2. Be an Xcode or Swift Package Manager project (Carthage and CocoaPods are currently unsupported but are being explored to be supported in the future)
  3. Support building on either Linux or macOS
  4. Be contained in a publicly accessible git repository
  5. Maintain a project branch that builds against Swift 4.2 compatibility mode and passes any unit tests
  6. Have maintainers who will commit to resolve issues in a timely manner
  7. Be compatible with the latest GM/Beta versions of Xcode and swiftpm
  8. Add value not already included in the suite
  9. Be licensed with one of the following permissive licenses:
    • BSD
    • MIT
    • Apache License, version 2.0
    • Eclipse Public License
    • Mozilla Public License (MPL) 1.1
    • MPL 2.0
    • CDDL

Note: Linux compatibility testing in continuous integration is not available yet, but Linux projects are being accepted now.

Adding a Project

To add a project meeting the acceptance criteria to the suite, perform the following steps:

  1. Ensure the project builds successfully at a chosen commit against Swift 4.2 GM
  2. Create a pull request against the source compatibility suite repository, modifying projects.json to include a reference to the project being added to the test suite.

The project index is a JSON file that contains a list of repositories containing Xcode and/or Swift Package Manager target actions.

To add a new Swift Package Manager project, use the following template:

{
  "repository": "Git",
  "url": "https://github.com/example/project.git",
  "path": "project",
  "branch": "master",
  "maintainer": "[email protected]",
  "compatibility": [
    {
      "version": "4.2",
      "commit": "195cd8cde2bb717242b3081f9c367ccd0a2f0121"
    }
  ],
  "platforms": [
    "Darwin"
  ],
  "actions": [
    {
      "action": "BuildSwiftPackage",
      "configuration": "release"
    },
    {
      "action": "TestSwiftPackage"
    }
  ]
}

The compatibility field contains a list of version dictionaries, each containing a Swift version and a commit. Commits are checked out before building a project in the associated Swift version compatibility mode. The Swift version is the earliest version of Swift known to compile the project at the given commit. The goal is to have multiple commits at different points in a project's history that are compatible with all supported Swift version compatibility modes.

The platforms field specifies the platforms that can be used to build the project. Linux and Darwin can currently be specified.

If tests aren't supported, remove the test action entry.

To add a new Swift Xcode workspace, use the following template:

{
  "repository": "Git",
  "url": "https://github.com/example/project.git",
  "path": "project",
  "branch": "master",
  "maintainer": "[email protected]",
  "compatibility": [
    {
      "version": "4.2",
      "commit": "195cd8cde2bb717242b3081f9c367ccd0a2f0121"
    }
  ],
  "platforms": [
    "Darwin"
  ],
  "actions": [
    {
      "action": "BuildXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project OSX",
      "destination": "platform=macOS",
      "configuration": "Release"
    },
    {
      "action": "BuildXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project iOS",
      "destination": "generic/platform=iOS",
      "configuration": "Release"
    },
    {
      "action": "BuildXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project tvOS",
      "destination": "generic/platform=tvOS",
      "configuration": "Release"
    },
    {
      "action": "BuildXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project watchOS",
      "destination": "generic/platform=watchOS",
      "configuration": "Release"
    },
    {
      "action": "TestXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project OSX",
      "destination": "platform=macOS"
    },
    {
      "action": "TestXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project iOS",
      "destination": "platform=iOS Simulator,name=iPhone 7"
    },
    {
      "action": "TestXcodeWorkspaceScheme",
      "workspace": "project.xcworkspace",
      "scheme": "project tvOS",
      "destination": "platform=tvOS Simulator,name=Apple TV 1080p"
    }
  ]
}

To add a new Swift Xcode project, use the following template:

{
  "repository": "Git",
  "url": "https://github.com/example/project.git",
  "path": "project",
  "branch": "master",
  "maintainer": "[email protected]",
  "compatibility": [
    {
      "version": "4.2",
      "commit": "195cd8cde2bb717242b3081f9c367ccd0a2f0121"
    }
  ],
  "platforms": [
    "Darwin"
  ],
  "actions": [
    {
      "action": "BuildXcodeProjectTarget",
      "project": "project.xcodeproj",
      "target": "project",
      "destination": "generic/platform=iOS",
      "configuration": "Release"
    }
  ]
}

After adding a new project to the index, ensure it builds successfully at the pinned commits against the specified versions of Swift. In the examples, the commits are specified as being compatible with Swift 4.2, which is included in Xcode 10.

# Select Xcode 10 GM
sudo xcode-select -s /Applications/Xcode.app
# Build project at pinned commit against selected Xcode
./project_precommit_check project-path-field --earliest-compatible-swift-version 4.2

On Linux, you can build against the Swift 4.2 release toolchain:

curl -O https://swift.org/builds/swift-4.2-release/ubuntu1604/swift-4.2-RELEASE/swift-4.2-RELEASE-ubuntu16.04.tar.gz
tar xzvf swift-4.2-RELEASE-ubuntu16.04.tar.gz
./project_precommit_check project-path-field --earliest-compatible-swift-version 4.2 --swiftc swift-4.2-RELEASE-ubuntu15.10/usr/bin/swiftc

Maintaining Projects

In the event that Swift introduces a change that breaks source compatibility with a project (e.g., a compiler bug fix that fixes wrong behavior in the compiler), project maintainers are expected to update their projects and submit a new pull request with the updated commit hash within two weeks of being notified. Otherwise, unmaintained projects may be removed from the project index.

Contributing

Welcome to the Swift community!

Contributions to /swift-source-compat-suite are welcomed and encouraged! Please see the Contributing to Swift guide and check out the structure of the community.

To be a truly great community, Swift needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.

To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct.

Pull Request Testing

Pull request testing against the Swift source compatibility suite can be executed by commenting with @swift-ci Please test source compatibility in a Swift pull request.

Building Projects

To build all projects against a specified Swift compiler locally, use the runner.py utility as shown below.

./runner.py --swift-branch main --projects projects.json --include-actions 'action.startswith("Build")' --swiftc path/to/swiftc

Use the --include-repos flag to build a specific project.

./runner.py --swift-branch main --projects projects.json --include-actions 'action.startswith("Build")' --include-repos 'path == "Alamofire"' --swiftc path/to/swiftc

By default, build output is redirected to per-action .log files in the current working directory. To change this behavior to output build results to standard out, use the --verbose flag.

Marking actions as expected failures

When an action is expected to fail for an extended period of time, it's important to mark the action as an expected failure to make new failures more visible.

To mark an action as an expected failure, add an xfail entry for the correct Swift version and branch to the failing actions, associating each with a link to a JIRA issue reporting the relevant failure. The following is an example of an action that's XFAIL'd when building against Swift main branch in 4.2 compatibility mode.

{
  "repository": "Git",
  "url": "https://github.com/example/project.git",
  "path": "project",
  "branch": "master",
  "maintainer": "[email protected]",
  "compatibility": [
    {
      "version": "4.2",
      "commit": "195cd8cde2bb717242b3081f9c367ccd0a2f0121"
    }
  ],
  "platforms": [
    "Darwin"
  ],
  "actions": [
    {
      "action": "BuildXcodeProjectTarget",
      "project": "project.xcodeproj",
      "target": "project",
      "destination": "generic/platform=iOS",
      "configuration": "Release",
      "xfail": {
        "issue": "https://github.com/apple/swift/issues/9999",
        "compatibility": "4.2",
        "branch": "main"
      }
    }
  ]
}

Additional Swift branches and versions can be added to XFAIL different configurations. The currently supported fields for XFAIL entries are:

  • "compatibility": the Swift version(s) it fails with, e.g. "4.0"
  • "branch": the branch(es) of the swift compiler it fails with, e.g. "swift-5.1-branch"
  • "platform": the platform(s) it fails on, e.g. "Darwin" or "Linux"
  • "configuration": the build configuration(s) if fails with, i.e. "release" or "debug")
  • "job": Allows XFailing the project for only the source compatibility build or the SourceKit Stress Tester. Use "source-compat" to only XFail the Source Compatibility Suite CI job and "stress-test" to only stress test the SourceKit Stress Tester CI job.

Values can either be a single string literal or a list of alternative string literals to match against. For example the below action is expected to fail on both main and swift-5.1-branch in both 4.0 and 5.1 compatibility modes:

...
{
  "action": "BuildXcodeProjectTarget",
  "project": "project.xcodeproj",
  "target": "project",
  "destination": "generic/platform=iOS",
  "configuration": "Release",
  "xfail": {
    "issue": "https://github.com/apple/swift/issues/9999",
    "compatibility": ["4.0", "5.1"],
    "branch": ["main", "swift-5.1-branch"]
  }
}
...

If an action is failing for different reasons in different configurations, the value of the action's "xfail" entry can also become a list rather than a single entry. In this case the "issue" of the first item that matches will be reported. In the below example any failure on Linux would be reported as SR-7777, while a failure on other platforms would be reported as SR-8888 using a toolchain built from the master branch and SR-9999 using a toolchain built from swift-5.1-branch. If the entries were in the reverse order, SR-7777 would only be reported for Linux failures with toolchains built from a branch other than main or swift-5.1-branch.

...
{
  "action": "BuildXcodeProjectTarget",
  "project": "project.xcodeproj",
  "target": "project",
  "destination": "generic/platform=iOS",
  "configuration": "Release",
  "xfail": [
    {
      "issue": "https://github.com/apple/swift/issues/7777",
      "platform": "Linux"
    },
    {
      "issue": "https://github.com/apple/swift/issues/8888",
      "branch": "main"
    },
    {
      "issue": "https://github.com/apple/swift/issues/9999",
      "branch": "swift-5.1-branch"
    }
  ]
}
...

swift-source-compat-suite's People

Contributors

ahoppen avatar artsabintsev avatar aschwaighofer avatar atrick avatar beccadax avatar benlangmuir avatar bouke avatar clackary avatar douggregor avatar eeckstein avatar gottesmm avatar graydon avatar hamishknight avatar hborla avatar jpsim avatar justice-adams-apple avatar justinswart avatar ktoso avatar lplarson avatar maxdesiatov avatar moiseev avatar nate-chandler avatar rudkx avatar shahmishal avatar stephencelis avatar susandoggie avatar tkremenek avatar xedin avatar xymus avatar yim-lee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift-source-compat-suite's Issues

Is TestSwiftPackage being used in production?

At the time of filing this issue, the package path passed to swift test is preceded with -C which I believe has been removed and replaced with --package-path since Swift 5.8.

https://github.com/apple/swift-source-compat-suite/blob/d8ff76a97fcfd178b54d473cbf5c053b70379c56/project.py#L370

Does this mean that Apple team is not actually running these test actions (at least for a while)? If I made some modification in the compiler, is it safe to test the changes against the listed test actions?

Support specification of compatibility with `--static-swift-stdlib`

As mentioned in issues such as swiftlang/swift#68671 and swiftlang/swift#65097, sometimes a Swift change is incompatible with --static-swift-stdlib (as in swift build -c release --static-swift-stdlib) but the problem is only discovered later on, after a Swift release.
This is despite the fact that using --static-swift-stdlib is very common in Server-Side Swift apps, and reference files such as Vapor's template Dockerfile have been using this flag for a long time.
All these while SE-0342 proposed --static-swift-stdlib to become the default behavior on platforms like Linux, which has yet to take effect.

So, the question is: should this repository support a JSON field to specify compatibility with --static-swift-stdlib (e.g. build_static_stdlib?
That way, it might be easier for the Swift team to keep track of compatibility of Swift releases with projects that use the --static-swift-stdlib flag.
Penny can be the first project to specify compatibility with that flag in the projects.json.

[Source compatibility suite] swift-power-assert failing to build - Undefined symbols

The swift-power-assert fails to build in the source-combat-suite against main: https://ci.swift.org/job/swift-main-source-compat-suite-debug/487/

The error is on missing symbols, a lot of missing symbols:

/Users/ec2-user/jenkins/workspace-private/swift-main-source-compat-suite-debug/build/compat_macos/install/toolchain/usr/bin/clang /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug/PowerAssertPlugin.build/PowerAssertMacro.swift.o /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug/PowerAssertPlugin.build/PowerAssertPlugin.swift.o /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug/PowerAssertPlugin.build/PowerAssertRewriter.swift.o /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug/PowerAssertPlugin.build/SingleLineFormatter.swift.o -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk --target=x86_64-apple-macosx13.0 /Users/ec2-user/jenkins/workspace-private/swift-main-source-compat-suite-debug/build/compat_macos/install/toolchain/usr/lib/swift/macosx/libswiftCompatibilityPacks.a -L /Users/ec2-user/jenkins/workspace-private/swift-main-source-compat-suite-debug/build/compat_macos/install/toolchain/usr/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/swift -L /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -L /Users/ec2-user/jenkins/workspace-private/swift-main-source-compat-suite-debug/build/compat_macos/install/toolchain/usr/lib -Xlinker -alias -Xlinker _PowerAssertPlugin_main -Xlinker _main -Xlinker -rpath -Xlinker @loader_path -Xlinker -add_ast_path -Xlinker /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug/PowerAssertPlugin.swiftmodule -o /Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/swift-power-assert/.build/x86_64-apple-macosx/debug/PowerAssertPlugin
error: link command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture x86_64:
  "_$s11StringWidth06stringB0ySiSSF", referenced from:
      _$s17PowerAssertPlugin0aB8RewriterC14graphemeColumn33_B676B0649EA1307B1860CA0ABF455ABBLLySi11SwiftSyntax0O8Protocol_pF in PowerAssertRewriter.swift.o
  "_$s11SwiftParser15SyntaxParseableP0aC7BuilderE19stringInterpolationxAD0c6StringG0V_tcfC", referenced from:
      _$s17PowerAssertPlugin0aB8RewriterC5visity11SwiftSyntax04ExprG0VAE010IdentifierhG0VF in PowerAssertRewriter.swift.o
      _$s17PowerAssertPlugin0aB8RewriterC5visity11SwiftSyntax04ExprG0VAE012MemberAccesshG0VF in PowerAssertRewriter.swift.o
      _$s17PowerAssertPlugin0aB8RewriterC5visity11SwiftSyntax04ExprG0VAE08SuperRefhG0VF in PowerAssertRewriter.swift.o
...

FAIL_swift-power-assert_5.0_BuildSwiftPackage.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.