Skip to content

Commit

Permalink
Migrate CI to use swiftlang / SwiftNIO common GitHub Actions.
Browse files Browse the repository at this point in the history
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.
* Define a gRPC-specific soundness check which retains bespoke license-checking
code for .swift files as the gRPC header style is very different to most templates
and checks that generated code is up-to-date.

Result:

More test, linting, formatting coverage. More common CI with other Swift
on Server projects.
  • Loading branch information
rnro committed Nov 5, 2024
1 parent 54227cb commit db76eb8
Show file tree
Hide file tree
Showing 47 changed files with 387 additions and 251 deletions.
14 changes: 14 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -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
82 changes: 0 additions & 82 deletions .github/workflows/ci.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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"

integration-tests:
name: Integration Tests
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Integration tests"
matrix_linux_5_9_enabled: false
matrix_linux_5_10_enabled: false
matrix_linux_command: "./dev/integration_tests.sh"
72 changes: 72 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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: gRPC-specific Soundness
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: Install protoc
run: apt update && apt install -y protobuf-compiler
- name: Run soundness checks
run: |
./dev/soundness.sh
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"

integration-tests:
name: Integration Tests
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Integration Tests"
matrix_linux_5_9_enabled: false
matrix_linux_5_10_enabled: false
matrix_linux_command: "./dev/integration_tests.sh"

examples:
name: Examples
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Examples"
matrix_linux_5_9_enabled: false
matrix_linux_5_10_enabled: false
matrix_linux_command: "./dev/build-examples.sh"

benchmarks:
name: Benchmarks
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
with:
benchmark_package_path: "IntegrationTests/Benchmarks"
linux_5_9_enabled: false
linux_5_10_enabled: false

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
18 changes: 18 additions & 0 deletions .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .license_header_template
Original file line number Diff line number Diff line change
@@ -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.
40 changes: 40 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.git-blame-ignore-revs
.gitmodules
.mailfilter
.mailmap
.spi.yml
.swift-format
.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
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ In order to protect both you and ourselves, you will need to sign the

Please see the [main gRPC repository](https://github.com/grpc/grpc) for
more information about gRPC.

### Run CI checks locally

You can run the Github Actions workflows locally using [act](https://github.com/nektos/act) or in some cases calling scripts directly. For detailed steps on how to do this please see [https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally](https://github.com/swiftlang/github-workflows?tab=readme-ov-file#running-workflows-locally).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 gRPC authors.
// Copyright 2015, 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.
Expand Down
42 changes: 21 additions & 21 deletions IntegrationTests/Benchmarks/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
import PackageDescription

let package = Package(
name: "benchmarks",
platforms: [
.macOS(.v13),
],
dependencies: [
.package(path: "../../"),
.package(url: "https://github.com/ordo-one/package-benchmark", from: "1.11.2")
],
targets: [
.executableTarget(
name: "GRPCSwiftBenchmark",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "GRPCCore", package: "grpc-swift")
],
path: "Benchmarks/GRPCSwiftBenchmark",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
),
]
name: "benchmarks",
platforms: [
.macOS(.v13)
],
dependencies: [
.package(path: "../../"),
.package(url: "https://github.com/ordo-one/package-benchmark", from: "1.11.2"),
],
targets: [
.executableTarget(
name: "GRPCSwiftBenchmark",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "GRPCCore", package: "grpc-swift"),
],
path: "Benchmarks/GRPCSwiftBenchmark",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 11,
"memoryLeaked" : 0,
"releaseCount" : 3012,
"retainCount" : 2000,
"syscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 11,
"memoryLeaked" : 0,
"releaseCount" : 4012,
"retainCount" : 2000,
"syscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 0,
"memoryLeaked" : 0,
"releaseCount" : 3001,
"retainCount" : 1000,
"syscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 0,
"memoryLeaked" : 0,
"releaseCount" : 3001,
"retainCount" : 1000,
"syscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 2000,
"memoryLeaked" : 0,
"releaseCount" : 7001,
"retainCount" : 3000,
"syscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 0,
"memoryLeaked" : 0,
"releaseCount" : 3001,
"retainCount" : 1000,
"syscalls" : 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"mallocCountTotal" : 0,
"memoryLeaked" : 0,
"releaseCount" : 2002001,
"retainCount" : 1999000,
"syscalls" : 0
}
Loading

0 comments on commit db76eb8

Please sign in to comment.