-
Notifications
You must be signed in to change notification settings - Fork 13
Adding swift support and hello world example #61
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
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ce22fc5
Initial steps for swift support
anfelbar 74aa7b5
Updated to rules_swift 1.5.0
anfelbar 08b6319
Swift example as new workspace so to use bazel 6.0.0
anfelbar 313549c
Addeing swift worlflow
anfelbar 2ffe926
Merge remote-tracking branch 'origin/main' into andres-swift-example
anfelbar f95625d
Adding new lines and removinf stardoc
anfelbar 724d501
Cheking is CC=clang works out of the box
anfelbar 12defcb
Testing with dotnet toolchains
anfelbar 9a9c0f9
Adding swift envionment to runner
anfelbar 7d2bacd
Removing dotnet toolchains from swift
anfelbar 77f8f46
Conditionally using swift-actions/setup-swift@v1; only linux
anfelbar 8fb3ea8
Adding back remaining tests
anfelbar d970d56
Added config for clang in swift
anfelbar c6ef29f
Trying to run on CI to execute on macos
anfelbar 9ba54ae
Testing on linux and macos
anfelbar b04fae8
Testing again with visual aid
anfelbar 075a0ee
Testing new file organization
anfelbar ec35625
Adding env to build as presented in rules_swift example
anfelbar f42573f
Something missing in the CI machine? using swift for macos as well
anfelbar 8eb9286
Trying macos-12
anfelbar 3311737
Following example
anfelbar 938e72c
Again macos-11 and removing env from BUILD
anfelbar 2e70aaa
Adding back other tests
anfelbar fb10dea
Small changed from Ola's comments
anfelbar 531bcd4
Added new line to BUILD file
anfelbar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| build:clang --client_env=CC=clang |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 6.0.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| load("@build_bazel_rules_swift//swift:swift.bzl", "swift_test") | ||
|
|
||
| swift_test( | ||
| name = "tests", | ||
| srcs = [ | ||
| "example.swift", | ||
| "main.swift", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
|
||
| http_archive( | ||
| name = "build_bazel_rules_swift", | ||
| sha256 = "32f95dbe6a88eb298aaa790f05065434f32a662c65ec0a6aabdaf6881e4f169f", | ||
| url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.0/rules_swift.1.5.0.tar.gz", | ||
| ) | ||
|
|
||
| load( | ||
| "@build_bazel_rules_swift//swift:repositories.bzl", | ||
| "swift_rules_dependencies", | ||
| ) | ||
|
|
||
| swift_rules_dependencies() | ||
|
|
||
| load( | ||
| "@build_bazel_rules_swift//swift:extras.bzl", | ||
| "swift_rules_extra_dependencies", | ||
| ) | ||
|
|
||
| swift_rules_extra_dependencies() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import XCTest | ||
|
|
||
| class SwiftTests: XCTestCase { | ||
| func fizzbuzz(i: Int) -> String { | ||
| if (i % 3 == 0) { | ||
| if (i % 5 == 0) { | ||
| return "FizzBuzz"; | ||
| } | ||
| return "Fizz"; | ||
| } | ||
| if (i % 5 == 0) { | ||
| return "Buzz"; | ||
| } | ||
anfelbar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return String(i); | ||
| } | ||
|
|
||
| func test() { | ||
| XCTAssertEqual(fizzbuzz(i: 1), "1") | ||
| XCTAssertEqual(fizzbuzz(i: 2), "2") | ||
| XCTAssertEqual(fizzbuzz(i: 3), "Fizz") | ||
| XCTAssertEqual(fizzbuzz(i: 4), "4") | ||
| XCTAssertEqual(fizzbuzz(i: 5), "Buzz") | ||
| XCTAssertEqual(fizzbuzz(i: 15), "FizzBuzz") | ||
| } | ||
|
|
||
| static var allTests = [ | ||
| ("test", test), | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #if os(Linux) | ||
| import XCTest | ||
|
|
||
| XCTMain([ | ||
| testCase(SwiftTests.allTests), | ||
| ]) | ||
| #endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't it use the repo's main .bazelversion, which is pinned to 7.0.0-pre.20221207.2? It doesn't work with Bazel 7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we are not using versiob 7 but version 5.2.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, so what is https://github.com/EngFlow/engflow/blob/master/.bazelversion used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this PR is for another repository, not engflow. This is example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean, this will be used as an example, so you want it to be self-contained?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to make it work with different version than the repo itself. So I added a workspace and its own .bazelversion. The repository .bazelversion is this: https://github.com/EngFlow/example/blob/main/.bazelversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I all this time didn't realize that this PR is on the example repo :-)
Now I'm wondering why the example repo is pinned to an old Bazel version...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking on moving to version 6. WDYT?