Skip to content

Commit 15556d9

Browse files
rnroglbrntt
andauthored
Migrate CI to use swiftlang / SwiftNIO common GitHub Actions. (#9)
### Motivation: * Reduce duplication * Centralise boilerplate changes when new Swift versions are picked up. * Benefit from centralised work to add new linting / test infrastructure. ### Modifications: Changes of note: * Use soundness checks from swiftlang/github-workflows. * Retain bespoke license-checking code for .swift files as the gRPC header style is very different to most templates. ### Result: More test, linting, formatting coverage. More common CI with other Swift on Server projects. Co-authored-by: George Barnett <[email protected]>
1 parent f3b05ce commit 15556d9

22 files changed

+271
-146
lines changed

.github/release.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
changelog:
2+
categories:
3+
- title: SemVer Major
4+
labels:
5+
- ⚠️ semver/major
6+
- title: SemVer Minor
7+
labels:
8+
- semver/minor
9+
- title: SemVer Patch
10+
labels:
11+
- semver/patch
12+
- title: Other Changes
13+
labels:
14+
- semver/none

.github/workflows/ci.yaml

-39
This file was deleted.

.github/workflows/main.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
schedule:
7+
- cron: "0 8,20 * * *"
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit tests
12+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
13+
with:
14+
linux_5_9_enabled: false
15+
linux_5_10_enabled: false
16+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
17+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
18+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

.github/workflows/pull_request.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, reopened, synchronize]
7+
8+
jobs:
9+
soundness:
10+
name: Soundness
11+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
12+
with:
13+
license_header_check_project_name: "gRPC"
14+
15+
grpc-soundness:
16+
name: Soundness
17+
uses: ./.github/workflows/soundness.yml
18+
19+
unit-tests:
20+
name: Unit tests
21+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
22+
with:
23+
linux_5_9_enabled: false
24+
linux_5_10_enabled: false
25+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
26+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
27+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
28+
29+
cxx-interop:
30+
name: Cxx interop
31+
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
32+
with:
33+
linux_5_9_enabled: false
34+
linux_5_10_enabled: false
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, reopened, synchronize]
6+
7+
jobs:
8+
semver-label-check:
9+
name: Semantic version label check
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 1
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
- name: Check for Semantic Version label
18+
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main

.github/workflows/soundness.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Soundness
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
swift-license-check:
8+
name: Swift license headers check
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
with:
14+
persist-credentials: false
15+
- name: Mark the workspace as safe
16+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
17+
- name: Run license check
18+
run: |
19+
./dev/license-check.sh
20+
21+
check-generated-code:
22+
name: Check generated code
23+
runs-on: ubuntu-latest
24+
container:
25+
image: swift:latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
persist-credentials: false
31+
- name: Mark the workspace as safe
32+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
33+
- name: Install protoc
34+
run: apt update && apt install -y protobuf-compiler
35+
- name: Run soundness checks
36+
run: |
37+
./dev/check-generated-code.sh

.license_header_template

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@@ Copyright YEARS, gRPC Authors All rights reserved.
2+
@@
3+
@@ Licensed under the Apache License, Version 2.0 (the "License");
4+
@@ you may not use this file except in compliance with the License.
5+
@@ You may obtain a copy of the License at
6+
@@
7+
@@ http://www.apache.org/licenses/LICENSE-2.0
8+
@@
9+
@@ Unless required by applicable law or agreed to in writing, software
10+
@@ distributed under the License is distributed on an "AS IS" BASIS,
11+
@@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
@@ See the License for the specific language governing permissions and
13+
@@ limitations under the License.

.licenseignore

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.gitmodules
7+
.mailfilter
8+
.mailmap
9+
.spi.yml
10+
.swift-format
11+
.swiftformatignore
12+
.editorconfig
13+
.github/*
14+
*.md
15+
*.txt
16+
*.yml
17+
*.yaml
18+
*.json
19+
Package.swift
20+
**/Package.swift
21+
Package@-*.swift
22+
**/Package@-*.swift
23+
Package.resolved
24+
**/Package.resolved
25+
Makefile
26+
*.modulemap
27+
**/*.modulemap
28+
**/*.docc/*
29+
*.xcprivacy
30+
**/*.xcprivacy
31+
*.symlink
32+
**/*.symlink
33+
Dockerfile
34+
**/Dockerfile
35+
Snippets/*
36+
dev/git.commit.template
37+
dev/version-bump.commit.template
38+
.unacceptablelanguageignore
39+
LICENSE
40+
**/*.swift
41+
dev/protos/**/*.proto

.swiftformatignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.grpc.swift
2+
*.pb.swift

.unacceptablelanguageignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/*.pb.swift
2+
**/*.grpc.swift
3+
dev/protos/upstream/**/*.proto

Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ let dependencies: [Package.Dependency] = [
5454
let defaultSwiftSettings: [SwiftSetting] = [
5555
.swiftLanguageMode(.v6),
5656
.enableUpcomingFeature("ExistentialAny"),
57-
.enableUpcomingFeature("InternalImportsByDefault")
57+
.enableUpcomingFeature("InternalImportsByDefault"),
5858
]
5959

6060
let targets: [Target] = [
@@ -91,7 +91,7 @@ let targets: [Target] = [
9191
dependencies: [
9292
.target(name: "GRPCInterceptors"),
9393
.product(name: "GRPCCore", package: "grpc-swift"),
94-
.product(name: "Tracing", package: "swift-distributed-tracing")
94+
.product(name: "Tracing", package: "swift-distributed-tracing"),
9595
],
9696
swiftSettings: defaultSwiftSettings
9797
),
@@ -114,7 +114,7 @@ let targets: [Target] = [
114114
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
115115
],
116116
swiftSettings: defaultSwiftSettings
117-
)
117+
),
118118
]
119119

120120
let package = Package(

Sources/GRPCHealthService/Health.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public import GRPCCore
1818

1919
/// ``Health`` is gRPC’s mechanism for checking whether a server is able to handle RPCs. Its semantics are documented in
20-
/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md.
20+
/// https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/health-checking.md.
2121
///
2222
/// `Health` initializes a new ``Health/Service-swift.struct`` and ``Health/Provider-swift.struct``.
2323
/// - `Health.Service` implements the Health service from the `grpc.health.v1` package and can be registered with a server

Sources/GRPCInteropTests/InteroperabilityTestCase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public protocol InteroperabilityTest {
2727
}
2828

2929
/// Test cases as listed by the [gRPC interoperability test description specification]
30-
/// (https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md).
30+
/// (https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/interop-test-descriptions.md).
3131
///
3232
/// This is not a complete list, the following tests have not been implemented:
3333
/// - cacheable_unary (caching not supported)

Sources/GRPCInteropTests/TestService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public struct TestService: Grpc_Testing_TestService.ServiceProtocol {
218218

219219
/// This is not implemented as it is not described in the specification.
220220
///
221-
/// See: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md
221+
/// See: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/interop-test-descriptions.md
222222
public func halfDuplexCall(
223223
request: StreamingServerRequest<Grpc_Testing_StreamingOutputCallRequest>,
224224
context: ServerContext

Sources/GRPCReflectionService/Documentation.docc/ReflectionServiceTutorial.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Note that when specifying a service, a method or a symbol, we have to use the fu
216216

217217
[grpcurl-setup]: https://github.com/fullstorydev/grpcurl#grpcurl
218218
[grpcurl]: https://github.com/fullstorydev/grpcurl
219-
[grpc-cli]: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md
219+
[grpc-cli]: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/command_line_tool.md
220220
[v1]: ../v1/reflection-v1.proto
221221
[v1alpha]: ../v1Alpha/reflection-v1alpha.proto
222222
[reflection-server]: ../../Examples/v1/ReflectionService/ReflectionServer.swift

Sources/GRPCReflectionService/Server/ReflectionService.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ extension ReflectionService {
326326
var wrapped: Wrapped
327327
private init(_ wrapped: Wrapped) { self.wrapped = wrapped }
328328

329-
/// The v1 version of reflection service: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1/reflection.proto.
329+
/// The v1 version of reflection service: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/src/proto/grpc/reflection/v1/reflection.proto.
330330
public static var v1: Self { Self(.v1) }
331-
/// The v1alpha version of reflection service: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
331+
/// The v1alpha version of reflection service: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/src/proto/grpc/reflection/v1alpha/reflection.proto.
332332
public static var v1Alpha: Self { Self(.v1Alpha) }
333333
}
334334

dev/check-generated-code.sh

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
#!/bin/bash
2-
3-
# Copyright 2024, gRPC Authors All rights reserved.
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
2+
## Copyright 2024, gRPC Authors All rights reserved.
3+
##
4+
## Licensed under the Apache License, Version 2.0 (the "License");
5+
## you may not use this file except in compliance with the License.
6+
## You may obtain a copy of the License at
7+
##
8+
## http://www.apache.org/licenses/LICENSE-2.0
9+
##
10+
## Unless required by applicable law or agreed to in writing, software
11+
## distributed under the License is distributed on an "AS IS" BASIS,
12+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
## See the License for the specific language governing permissions and
14+
## limitations under the License.
1615

1716
set -euo pipefail
1817

dev/format.sh

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
#!/bin/bash
2-
3-
# Copyright 2020, gRPC Authors All rights reserved.
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
2+
## Copyright 2020, gRPC Authors All rights reserved.
3+
##
4+
## Licensed under the Apache License, Version 2.0 (the "License");
5+
## you may not use this file except in compliance with the License.
6+
## You may obtain a copy of the License at
7+
##
8+
## http://www.apache.org/licenses/LICENSE-2.0
9+
##
10+
## Unless required by applicable law or agreed to in writing, software
11+
## distributed under the License is distributed on an "AS IS" BASIS,
12+
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
## See the License for the specific language governing permissions and
14+
## limitations under the License.
1615

1716
set -eu
1817

@@ -68,8 +67,7 @@ if "$lint"; then
6867
To fix, run the following command:
6968
7069
% $THIS_SCRIPT -f
71-
"
72-
exit "${SWIFT_FORMAT_RC}"
70+
" "${SWIFT_FORMAT_RC}"
7371
fi
7472

7573
log "Ran swift format lint with no errors."

0 commit comments

Comments
 (0)