diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f96b514 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,14 @@ +changelog: + categories: + - title: SemVer Major + labels: + - ⚠️ semver/major + - title: SemVer Minor + labels: + - semver/minor + - title: SemVer Patch + labels: + - semver/patch + - title: Other Changes + labels: + - semver/none diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 61b78d8..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: CI -on: - pull_request: - branches: [main] -jobs: - preflight: - name: License Header and Formatting Checks - runs-on: ubuntu-latest - container: - image: swift:6.0-jammy - steps: - - name: "Checkout repository" - uses: actions/checkout@v4 - - name: Mark the workspace as safe - run: git config --global --add safe.directory ${GITHUB_WORKSPACE} - - name: "Install protoc" - run: apt update && apt install -y protobuf-compiler - - name: "Formatting, License Headers, and Generated Code check" - run: | - ./dev/sanity.sh - unit-tests: - strategy: - fail-fast: false - matrix: - include: - - image: swiftlang/swift:nightly-jammy - - image: swift:6.0-jammy - name: Build and Test on ${{ matrix.image }} - runs-on: ubuntu-latest - container: - image: ${{ matrix.image }} - steps: - - uses: actions/checkout@v4 - - name: 🔧 Build - run: swift build ${{ matrix.swift-build-flags }} - timeout-minutes: 20 - - name: 🧪 Test - run: swift test ${{ matrix.swift-test-flags }} - timeout-minutes: 20 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f26b60d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,18 @@ +name: Main + +on: + push: + branches: [main] + schedule: + - cron: "0 8,20 * * *" + +jobs: + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_9_enabled: false + linux_5_10_enabled: false + linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..a60a4c0 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,34 @@ +name: PR + +on: + pull_request: + branches: [main] + types: [opened, reopened, synchronize] + +jobs: + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + license_header_check_project_name: "gRPC" + + grpc-soundness: + name: Soundness + uses: ./.github/workflows/soundness.yml + + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_9_enabled: false + linux_5_10_enabled: false + linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + + cxx-interop: + name: Cxx interop + uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main + with: + linux_5_9_enabled: false + linux_5_10_enabled: false diff --git a/.github/workflows/pull_request_label.yml b/.github/workflows/pull_request_label.yml new file mode 100644 index 0000000..d83c599 --- /dev/null +++ b/.github/workflows/pull_request_label.yml @@ -0,0 +1,18 @@ +name: PR + +on: + pull_request: + types: [labeled, unlabeled, opened, reopened, synchronize] + +jobs: + semver-label-check: + name: Semantic version label check + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Check for Semantic Version label + uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml new file mode 100644 index 0000000..35a50d7 --- /dev/null +++ b/.github/workflows/soundness.yml @@ -0,0 +1,37 @@ +name: Soundness + +on: + workflow_call: + +jobs: + swift-license-check: + name: Swift license headers check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Mark the workspace as safe + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Run license check + run: | + ./dev/license-check.sh + + check-generated-code: + name: Check generated code + runs-on: ubuntu-latest + container: + image: swift:latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Mark the workspace as safe + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Install protoc + run: apt update && apt install -y protobuf-compiler + - name: Run soundness checks + run: | + ./dev/check-generated-code.sh diff --git a/.license_header_template b/.license_header_template new file mode 100644 index 0000000..a07a9ad --- /dev/null +++ b/.license_header_template @@ -0,0 +1,13 @@ +@@ Copyright YEARS, gRPC Authors All rights reserved. +@@ +@@ Licensed under the Apache License, Version 2.0 (the "License"); +@@ you may not use this file except in compliance with the License. +@@ You may obtain a copy of the License at +@@ +@@ http://www.apache.org/licenses/LICENSE-2.0 +@@ +@@ Unless required by applicable law or agreed to in writing, software +@@ distributed under the License is distributed on an "AS IS" BASIS, +@@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@@ See the License for the specific language governing permissions and +@@ limitations under the License. diff --git a/.licenseignore b/.licenseignore new file mode 100644 index 0000000..d1c5126 --- /dev/null +++ b/.licenseignore @@ -0,0 +1,41 @@ +.gitignore +**/.gitignore +.licenseignore +.gitattributes +.git-blame-ignore-revs +.gitmodules +.mailfilter +.mailmap +.spi.yml +.swift-format +.swiftformatignore +.editorconfig +.github/* +*.md +*.txt +*.yml +*.yaml +*.json +Package.swift +**/Package.swift +Package@-*.swift +**/Package@-*.swift +Package.resolved +**/Package.resolved +Makefile +*.modulemap +**/*.modulemap +**/*.docc/* +*.xcprivacy +**/*.xcprivacy +*.symlink +**/*.symlink +Dockerfile +**/Dockerfile +Snippets/* +dev/git.commit.template +dev/version-bump.commit.template +.unacceptablelanguageignore +LICENSE +**/*.swift +dev/protos/**/*.proto diff --git a/.swiftformatignore b/.swiftformatignore new file mode 100644 index 0000000..c73cb4c --- /dev/null +++ b/.swiftformatignore @@ -0,0 +1,2 @@ +*.grpc.swift +*.pb.swift diff --git a/.unacceptablelanguageignore b/.unacceptablelanguageignore new file mode 100644 index 0000000..fe70e9d --- /dev/null +++ b/.unacceptablelanguageignore @@ -0,0 +1,3 @@ +**/*.pb.swift +**/*.grpc.swift +dev/protos/upstream/**/*.proto diff --git a/Package.swift b/Package.swift index ce047e5..1e552d3 100644 --- a/Package.swift +++ b/Package.swift @@ -54,7 +54,7 @@ let dependencies: [Package.Dependency] = [ let defaultSwiftSettings: [SwiftSetting] = [ .swiftLanguageMode(.v6), .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("InternalImportsByDefault"), ] let targets: [Target] = [ @@ -90,7 +90,7 @@ let targets: [Target] = [ dependencies: [ .target(name: "GRPCInterceptors"), .product(name: "GRPCCore", package: "grpc-swift"), - .product(name: "Tracing", package: "swift-distributed-tracing") + .product(name: "Tracing", package: "swift-distributed-tracing"), ] ), @@ -111,7 +111,7 @@ let targets: [Target] = [ .product(name: "GRPCCore", package: "grpc-swift"), .product(name: "GRPCInProcessTransport", package: "grpc-swift"), ] - ) + ), ] let package = Package( diff --git a/Sources/GRPCHealthService/Health.swift b/Sources/GRPCHealthService/Health.swift index cee06bf..c2cfbc5 100644 --- a/Sources/GRPCHealthService/Health.swift +++ b/Sources/GRPCHealthService/Health.swift @@ -17,7 +17,7 @@ public import GRPCCore /// ``Health`` is gRPC’s mechanism for checking whether a server is able to handle RPCs. Its semantics are documented in -/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md. +/// https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/health-checking.md. /// /// `Health` initializes a new ``Health/Service-swift.struct`` and ``Health/Provider-swift.struct``. /// - `Health.Service` implements the Health service from the `grpc.health.v1` package and can be registered with a server diff --git a/Sources/GRPCInteropTests/InteroperabilityTestCase.swift b/Sources/GRPCInteropTests/InteroperabilityTestCase.swift index 4569897..1dc379c 100644 --- a/Sources/GRPCInteropTests/InteroperabilityTestCase.swift +++ b/Sources/GRPCInteropTests/InteroperabilityTestCase.swift @@ -27,7 +27,7 @@ public protocol InteroperabilityTest { } /// Test cases as listed by the [gRPC interoperability test description specification] -/// (https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md). +/// (https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/interop-test-descriptions.md). /// /// This is not a complete list, the following tests have not been implemented: /// - cacheable_unary (caching not supported) diff --git a/Sources/GRPCInteropTests/TestService.swift b/Sources/GRPCInteropTests/TestService.swift index ba00cc4..da9cbba 100644 --- a/Sources/GRPCInteropTests/TestService.swift +++ b/Sources/GRPCInteropTests/TestService.swift @@ -218,7 +218,7 @@ public struct TestService: Grpc_Testing_TestService.ServiceProtocol { /// This is not implemented as it is not described in the specification. /// - /// See: https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md + /// See: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/interop-test-descriptions.md public func halfDuplexCall( request: StreamingServerRequest, context: ServerContext diff --git a/Sources/GRPCReflectionService/Documentation.docc/ReflectionServiceTutorial.md b/Sources/GRPCReflectionService/Documentation.docc/ReflectionServiceTutorial.md index d43f80a..8cf1310 100644 --- a/Sources/GRPCReflectionService/Documentation.docc/ReflectionServiceTutorial.md +++ b/Sources/GRPCReflectionService/Documentation.docc/ReflectionServiceTutorial.md @@ -216,7 +216,7 @@ Note that when specifying a service, a method or a symbol, we have to use the fu [grpcurl-setup]: https://github.com/fullstorydev/grpcurl#grpcurl [grpcurl]: https://github.com/fullstorydev/grpcurl -[grpc-cli]: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md +[grpc-cli]: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/doc/command_line_tool.md [v1]: ../v1/reflection-v1.proto [v1alpha]: ../v1Alpha/reflection-v1alpha.proto [reflection-server]: ../../Examples/v1/ReflectionService/ReflectionServer.swift diff --git a/Sources/GRPCReflectionService/Server/ReflectionService.swift b/Sources/GRPCReflectionService/Server/ReflectionService.swift index aff9eaa..d6bcb1f 100644 --- a/Sources/GRPCReflectionService/Server/ReflectionService.swift +++ b/Sources/GRPCReflectionService/Server/ReflectionService.swift @@ -326,9 +326,9 @@ extension ReflectionService { var wrapped: Wrapped private init(_ wrapped: Wrapped) { self.wrapped = wrapped } - /// The v1 version of reflection service: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1/reflection.proto. + /// The v1 version of reflection service: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/src/proto/grpc/reflection/v1/reflection.proto. public static var v1: Self { Self(.v1) } - /// The v1alpha version of reflection service: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto. + /// The v1alpha version of reflection service: https://github.com/grpc/grpc/blob/5011420f160b91129a7baebe21df9444a07896a6/src/proto/grpc/reflection/v1alpha/reflection.proto. public static var v1Alpha: Self { Self(.v1Alpha) } } diff --git a/dev/check-generated-code.sh b/dev/check-generated-code.sh index 67bc71b..3094c38 100755 --- a/dev/check-generated-code.sh +++ b/dev/check-generated-code.sh @@ -1,18 +1,17 @@ #!/bin/bash - -# Copyright 2024, gRPC Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +## Copyright 2024, gRPC Authors All rights reserved. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. set -euo pipefail diff --git a/dev/format.sh b/dev/format.sh index 34870bf..8bb4db2 100755 --- a/dev/format.sh +++ b/dev/format.sh @@ -1,18 +1,17 @@ #!/bin/bash - -# Copyright 2020, gRPC Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +## Copyright 2020, gRPC Authors All rights reserved. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. set -eu @@ -68,8 +67,7 @@ if "$lint"; then To fix, run the following command: % $THIS_SCRIPT -f - " - exit "${SWIFT_FORMAT_RC}" + " "${SWIFT_FORMAT_RC}" fi log "Ran swift format lint with no errors." diff --git a/dev/license-check.sh b/dev/license-check.sh index d0961f5..ce643ac 100755 --- a/dev/license-check.sh +++ b/dev/license-check.sh @@ -1,18 +1,17 @@ #!/bin/bash - -# Copyright 2019, gRPC Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +## Copyright 2019, gRPC Authors All rights reserved. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. # This script checks the copyright headers in source *.swift source files and # exits if they do not match the expected header. The year, or year range in @@ -38,10 +37,6 @@ read -r -d '' COPYRIGHT_HEADER_SWIFT << 'EOF' EOF SWIFT_SHA=$(echo "$COPYRIGHT_HEADER_SWIFT" | shasum | awk '{print $1}') -replace_years() { - sed -e 's/201[56789]-20[12][0-9]/YEARS/' -e 's/201[56789]/YEARS/' -} - # Checks the Copyright headers for *.swift files in this repository against the # expected headers. # @@ -74,12 +69,12 @@ check_copyright_headers() { drop_first=1 expected_lines=15 ;; - */Package@swift-*.swift) + */Package@swift-*.*.swift) expected_sha="$SWIFT_SHA" drop_first=1 expected_lines=15 ;; - */Package@swift-*.*.swift) + */Package@swift-*.swift) expected_sha="$SWIFT_SHA" drop_first=1 expected_lines=15 @@ -105,7 +100,7 @@ check_copyright_headers() { done < <(find . -name '*.swift' \ ! -name '*.pb.swift' \ ! -name '*.grpc.swift' \ - ! -path './.build/*') + ! -path '.*/.build/*') } errors=0 diff --git a/dev/protos/fetch.sh b/dev/protos/fetch.sh index 72f954a..52d3a7f 100755 --- a/dev/protos/fetch.sh +++ b/dev/protos/fetch.sh @@ -1,18 +1,17 @@ #!/bin/bash -# -# Copyright 2024, gRPC Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +## Copyright 2024, gRPC Authors All rights reserved. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. set -eu diff --git a/dev/protos/generate.sh b/dev/protos/generate.sh index ee71096..143c40a 100755 --- a/dev/protos/generate.sh +++ b/dev/protos/generate.sh @@ -1,18 +1,17 @@ #!/bin/bash -# -# Copyright 2024, gRPC Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +## Copyright 2024, gRPC Authors All rights reserved. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. set -eu diff --git a/dev/sanity.sh b/dev/soundness.sh similarity index 50% rename from dev/sanity.sh rename to dev/soundness.sh index de039b5..8c9f16e 100755 --- a/dev/sanity.sh +++ b/dev/soundness.sh @@ -1,18 +1,17 @@ #!/bin/bash - -# Copyright 2020, gRPC Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +## Copyright 2020, gRPC Authors All rights reserved. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. set -eu @@ -41,16 +40,11 @@ function check_license_headers() { run_logged "Checking license headers" "$here/license-check.sh" } -function check_formatting() { - run_logged "Checking formatting" "$here/format.sh -l" -} - function check_generated_code_is_up_to_date() { run_logged "Checking generated code is up-to-date" "$here/check-generated-code.sh" } errors=0 check_license_headers -check_formatting check_generated_code_is_up_to_date exit $errors