Skip to content

Add package-distributed-system - distributed actors implementation #977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 4, 2025

Conversation

freef4ll
Copy link
Contributor

@freef4ll freef4ll commented Feb 12, 2025

Pull Request Description

Would like to add package-distributed-system; a package that uses distributed actors feature set.

Previous compiler crashes (swiftlang/swift#68517 and swiftlang/swift#79318) were identified - there should be value of validating new toolchain builds against this project.

Acceptance Criteria

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

  • be an Xcode or swift package manager project
  • support building on either Linux or macOS
  • target Linux, macOS, or iOS/tvOS/watchOS device
  • be contained in a publicly accessible git repository
  • maintain a project branch that builds against Swift 4.0 and passes any unit tests
  • have maintainers who will commit to resolve issues in a timely manner
  • be compatible with the latest GM/Beta versions of Xcode and swiftpm
  • add value not already included in the suite
  • 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
  • pass ./project_precommit_check script run

@freef4ll
Copy link
Contributor Author

freef4ll commented Feb 12, 2025

I'm having issues with python in order, stock macOS 15.3 built in python3:

/usr/bin/python3 project_precommit_check package-distributed-system --earliest-compatible-swift-version 5.10
ModuleNotFoundError: No module named 'pipes'

if changing the pipes to shelx https://docs.python.org/3.12/library/subprocess.html#module-subprocess:

common.py", line 122, in <listcomp>
    return ' '.join([pipes.quote(x) for x in command])

Then this leads to:

  File "swift-source-compat-suite/project.py", line 804, in included_element
    any(evaluate_predicate(element, ip)
    ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        for ip in include_predicates)))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "swift-source-compat-suite/project.py", line 804, in <genexpr>
    any(evaluate_predicate(element, ip)
        ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "swift-source-compat-suite/project.py", line 796, in evaluate_predicate
    return eval(predicate)

With these changes I'm able to build:

diff --git a/common.py b/common.py
index c684e3c..09b4808 100755
--- a/common.py
+++ b/common.py
@@ -16,7 +16,6 @@
 import multiprocessing
 import os
 import pathlib
-import pipes
 import platform
 import signal
 import subprocess
@@ -119,7 +118,7 @@ def shell_join(command):
     >>> shell_join(['echo', 'Hello, World!'])
     "echo 'Hello, World!'"
     """
-    return ' '.join([pipes.quote(x) for x in command])
+    return ' '.join([shlex.quote(x) for x in command])


 def debug_print(s, stderr=sys.stderr):
diff --git a/project.py b/project.py
index d5f94ab..6506fe0 100644
--- a/project.py
+++ b/project.py
@@ -790,10 +790,11 @@ def add_minimal_arguments(parser):
 def evaluate_predicate(element, predicate):
     """Evaluate predicate in context of index element fields."""
     # pylint: disable=I0011,W0122,W0123
-    for key in element:
+    local_vars = {}
+    for key,value in element.items():
         if isinstance(element[key], str):
-            exec(key + ' = """' + element[key] + '"""')
-    return eval(predicate)
+            local_vars[key] = value
+    return eval(predicate, {}, local_vars)


 def included_element(include_predicates, exclude_predicates, element):

@freef4ll
Copy link
Contributor Author

On Linux(Ubuntu 24.04):

$ ./project_precommit_check --earliest-compatible-swift-version 5.10 hummingbird
** CHECK **
--- Validating hummingbird Swift version 5.10 compatibility ---
--- Project configured to be compatible with Swift 5.10 ---
--- Checking hummingbird platform compatibility with Linux ---
--- Platform compatibility check succeeded ---
Traceback (most recent call last):
  File /tmp/swift-source-compat-suite/./project_precommit_check", line 258, in <module>
    sys.exit(main())
             ^^^^^^
  File "/tmp/swift-source-compat-suite/./project_precommit_check", line 253, in main
    config = supported_configs[platform.system()][args.earliest_compatible_swift_version]
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: '5.10'

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@justice-adams-apple
Copy link
Collaborator

@freef4ll Thanks for the PR! Yeah looks like that's from python 3.12, We will update those scripts once we update our CI machines to a new OS with a newer python.

As for the pre-commit check, that looks like its out of date on ubuntu, I'll open some PR's to update both the documentation and the pre-commit check 👍

@freef4ll
Copy link
Contributor Author

Thanks @justice-adams-apple!

I see the build failed according to the log:

error: failed downloading 'https://api.github.com/repos/ordo-one/mobile-dependencies-xcf/releases/assets/172962359-lz4-1.9.4.xcframework.zip' which is required by binary target 'lz4ios': downloadError("The request timed out.")

The environment proxy doesn't have access to api.github.com ?

@freef4ll
Copy link
Contributor Author

I fixed the lz4 failure. Lets try again, the build is in release mode currently and it might fail due to swiftlang/swift#79318, in which case will downgrade to a debug build for the time being.

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@freef4ll
Copy link
Contributor Author

Ok, failed again but this should be the last one. Removed package-benchmark which tried to pull in jemalloc.

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@ktoso
Copy link
Contributor

ktoso commented Feb 25, 2025

This package would be great to include, thanks a lot @freef4ll !

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@freef4ll
Copy link
Contributor Author

The latest build is failing due to swiftlang/swift#79318 when in release build, but for me it works locally which is using a debug build:

/usr/bin/python3 project_precommit_check --earliest-compatible-swift-version 5.10 --swiftc /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-02-25-a.xctoolchain/usr/bin/swiftc package-distributed-system
** CHECK **
--- Validating package-distributed-system Swift version 5.10 compatibility ---
--- Project configured to be compatible with Swift 5.10 ---
--- Checking package-distributed-system platform compatibility with Darwin ---
--- Platform compatibility check succeeded ---
--- Checking installed Swift version ---
$ /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2025-02-25-a.xctoolchain/usr/bin/swiftc --version
--- Version check failed ---
Expected version:
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: x86_64-apple-macosx14.0

Current version:
Apple Swift version 6.2-dev (LLVM a73e2519b8d610d, Swift 47a7867f88a5d80)
Target: arm64-apple-macosx15.0
Build config: +assertions

[...]
PASS: package-distributed-system, 5.10, 7b5a41, Swift Package
========================================
Action Summary:
     Passed: 1
     Failed: 0
    XFailed: 0
    UPassed: 0
      Total: 1
========================================
Repository Summary:
      Total: 1
========================================
Result: PASS
========================================
--- package-distributed-system checked successfully against Swift 5.10 ---

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@justice-adams-apple
Copy link
Collaborator

@freef4ll thank you for the PR 🙏 I will merge this and xfail it with the issue you linked above

@freef4ll
Copy link
Contributor Author

Hi @justice-adams-apple, I have added an xfail - can you please double check that my use of xfail is correct - expect to fail on main and release/6.1 toolchains?

@ktoso
Copy link
Contributor

ktoso commented Mar 18, 2025

@swift-ci test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really like to include this project in the test suite because it often catches critical regressions

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

projects.json Outdated
"compatibility": ["5.10"],
"branch": ["main", "release/6.1"],
"job": ["source-compat"],
"configuration": "debug"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@freef4ll small change: We just need to remove configuration": "debug" since technically this fails in the release config as well, then we can merge this guy 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justice-adams-apple - it should build now, I have removed the xfail.

These fixes have been merged 6.1 and main swiftlang/swift#80375 / swiftlang/swift#80373 !

@justice-adams-apple
Copy link
Collaborator

@swift-ci test

@justice-adams-apple justice-adams-apple merged commit 49e43ee into swiftlang:main Apr 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants