Skip to content

Commit a7da95f

Browse files
authored
Add Ubuntu test runner (#49)
Added missing main.swift for Linux tests.
1 parent 273b302 commit a7da95f

File tree

8 files changed

+81
-19
lines changed

8 files changed

+81
-19
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and Test
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Execute Tests
7+
shell: bash
8+
run: |
9+
bazelisk test //...
10+
11+
- name: Build Anything Not Tested
12+
shell: bash
13+
run: |
14+
bazelisk build //...
15+
16+
- name: Ensure all packages have bzlformat checks
17+
shell: bash
18+
run: |
19+
bazelisk run //:bzlformat_missing_pkgs_test
20+
21+
- name: Execute Integration Tests
22+
shell: bash
23+
run: |
24+
bazelisk test //:all_integration_tests

.github/workflows/ci.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,42 @@ on:
66

77
jobs:
88
macos_build:
9-
109
runs-on: macos-11.0
11-
1210
steps:
1311
- uses: actions/checkout@v2
14-
1512
- uses: cgrindel/gha_set_up_bazel@v1
1613
with:
1714
repo_name: rules_swiftformat
15+
- uses: ./.github/actions/build_and_test
1816

19-
- name: Execute Tests
20-
shell: bash
21-
run: |
22-
bazelisk test //...
23-
24-
- name: Build Anything Not Tested
25-
shell: bash
26-
run: |
27-
bazelisk build //...
28-
29-
- name: Ensure all packages have bzlformat checks
17+
ubuntu_build:
18+
runs-on: ubuntu-20.04
19+
env:
20+
CC: clang
21+
steps:
22+
- uses: cgrindel/gha_install_swift_on_ubuntu@v1
23+
with:
24+
swift_release_tag: "swift-5.5.2-RELEASE"
25+
ubuntu_version: "20.04"
26+
- uses: actions/checkout@v2
27+
- uses: cgrindel/gha_set_up_bazel@v1
28+
with:
29+
repo_name: rules_swiftformat
30+
- name: Update local.bazelrc with Linux Flags
3031
shell: bash
3132
run: |
32-
bazelisk run //:bzlformat_missing_pkgs_test
33+
cat >> "local.bazelrc" <<EOF
34+
# Need to expose the PATH so that the Swift toolchain can be found
35+
build --action_env=PATH
36+
EOF
37+
- uses: ./.github/actions/build_and_test
38+
39+
all_ci_tests:
40+
runs-on: ubuntu-20.04
41+
needs: [macos_build, ubuntu_build]
42+
steps:
43+
- name: All is Well
44+
shell: bash
45+
run: |
46+
echo "All is well!"
3347
34-
- name: Execute Integration Tests
35-
shell: bash
36-
run: |
37-
bazelisk test //:all_integration_tests

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Ignore Bazel symlinks
22
bazel-*
33

4+
# The local.bazelrc is machine-specific.
5+
local.bazelrc

examples/exclude_files/Tests/FooTests/MessageTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ class MessageTests: XCTestCase {
77
let msg = Message(value: value)
88
XCTAssertEqual(msg.value, value)
99
}
10+
11+
static var allTests = [
12+
("test_init", test_init),
13+
]
1014
}

examples/exclude_files/Tests/FooTests/PoorlyFormattedTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ import XCTest
99
pfmt.name = value
1010
XCTAssertEqual(pfmt.name, value)
1111
}
12+
static var allTests = [
13+
("test_init", test_init),
14+
]
1215
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#if os(Linux)
2+
import XCTest
3+
4+
XCTMain([
5+
testCase(MessageTests.allTests),
6+
testCase(PoorlyFormattedTests.allTests),
7+
])
8+
#endif

examples/rules_swift_helpers/Tests/FooTests/MessageTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ class MessageTests: XCTestCase {
77
let msg = Message(value: value)
88
XCTAssertEqual(msg.value, value)
99
}
10+
11+
static var allTests = [
12+
("test_init", test_init),
13+
]
1014
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#if os(Linux)
2+
import XCTest
3+
4+
XCTMain([
5+
testCase(MessageTests.allTests),
6+
])
7+
#endif

0 commit comments

Comments
 (0)