Skip to content
Merged
Show file tree
Hide file tree
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 Nov 28, 2022
74aa7b5
Updated to rules_swift 1.5.0
anfelbar Dec 23, 2022
08b6319
Swift example as new workspace so to use bazel 6.0.0
anfelbar Dec 23, 2022
313549c
Addeing swift worlflow
anfelbar Dec 23, 2022
2ffe926
Merge remote-tracking branch 'origin/main' into andres-swift-example
anfelbar Dec 23, 2022
f95625d
Adding new lines and removinf stardoc
anfelbar Dec 23, 2022
724d501
Cheking is CC=clang works out of the box
anfelbar Dec 23, 2022
12defcb
Testing with dotnet toolchains
anfelbar Dec 23, 2022
9a9c0f9
Adding swift envionment to runner
anfelbar Dec 23, 2022
7d2bacd
Removing dotnet toolchains from swift
anfelbar Dec 23, 2022
77f8f46
Conditionally using swift-actions/setup-swift@v1; only linux
anfelbar Dec 23, 2022
8fb3ea8
Adding back remaining tests
anfelbar Dec 23, 2022
d970d56
Added config for clang in swift
anfelbar Dec 23, 2022
c6ef29f
Trying to run on CI to execute on macos
anfelbar Dec 23, 2022
9ba54ae
Testing on linux and macos
anfelbar Dec 26, 2022
b04fae8
Testing again with visual aid
anfelbar Dec 26, 2022
075a0ee
Testing new file organization
anfelbar Dec 26, 2022
ec35625
Adding env to build as presented in rules_swift example
anfelbar Dec 26, 2022
f42573f
Something missing in the CI machine? using swift for macos as well
anfelbar Dec 26, 2022
8eb9286
Trying macos-12
anfelbar Dec 26, 2022
3311737
Following example
anfelbar Dec 26, 2022
938e72c
Again macos-11 and removing env from BUILD
anfelbar Dec 26, 2022
2e70aaa
Adding back other tests
anfelbar Dec 26, 2022
fb10dea
Small changed from Ola's comments
anfelbar Dec 27, 2022
531bcd4
Added new line to BUILD file
anfelbar Dec 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ jobs:

- name: Building //python directory
run: bazel build //python/...

- uses: swift-actions/setup-swift@v1
if: matrix.os == 'ubuntu-20.04'

- name: Building //swift directory
run: |
cd swift
bazel test --config=clang //...
1 change: 0 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ workspace(name = "example")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

# Some file dependencies
http_file(
Expand Down
1 change: 1 addition & 0 deletions swift/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build:clang --client_env=CC=clang
1 change: 1 addition & 0 deletions swift/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.0.0
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

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.

Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

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...

Copy link
Collaborator Author

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?

9 changes: 9 additions & 0 deletions swift/BUILD
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",
],
)
21 changes: 21 additions & 0 deletions swift/WORKSPACE
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()
29 changes: 29 additions & 0 deletions swift/example.swift
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";
}
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),
]
}
7 changes: 7 additions & 0 deletions swift/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#if os(Linux)
import XCTest

XCTMain([
testCase(SwiftTests.allTests),
])
#endif