Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into sb/timer-api
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjbeaumont committed Jul 12, 2024
2 parents dbba9e3 + eea0f74 commit 86b8ac3
Show file tree
Hide file tree
Showing 70 changed files with 1,080 additions and 604 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pull Request

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:
call-reusable-pull-request-workflow:
name: Checks
uses: ./.github/workflows/reusable_pull_request.yml
with:
benchmarks_linux_package_path: "Benchmarks"
license_header_check_project_name: "SwiftNIO"
format_check_enabled: false
193 changes: 193 additions & 0 deletions .github/workflows/reusable_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Pull Request

on:
workflow_call:
inputs:
unit_tests_linux_enabled:
type: boolean
description: "Boolean to enable the unit tests linux job. Defaults to true."
default: true
benchmarks_linux_enabled:
type: boolean
description: "Boolean to enable the benchmarks linux job. Defaults to true."
default: true
benchmarks_linux_package_path:
type: string
description: "Path to the package containing the benchmarks. Defaults to the repository root."
default: "."
api_breakage_check_enabled:
type: boolean
description: "Boolean to enable the API breakage check job. Defaults to true."
default: true
docs_check_enabled:
type: boolean
description: "Boolean to enable the docs check job. Defaults to true."
default: true
unacceptable_language_check_enabled:
type: boolean
description: "Boolean to enable the acceptable language check job. Defaults to true."
default: true
unacceptable_language_check_word_list:
type: string
description: "List of unacceptable words. Defaults to a sensible list of words."
default: "blacklist whitelist slave master sane sanity insane insanity kill killed killing hang hung hanged hanging" #ignore-unacceptable-language
license_header_check_enabled:
type: boolean
description: "Boolean to enable the license header check job. Defaults to true."
default: true
license_header_check_project_name:
type: string
description: "Name of the project called out in the license header."
required: true
broken_symlink_check_enabled:
type: boolean
description: "Boolean to enable the broken symlink check job. Defaults to true."
default: true
format_check_enabled:
type: boolean
description: "Boolean to enable the format check job. Defaults to true."
default: true

## We are cancelling previously triggered workflow runs
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
unit-tests-linux:
name: Unit tests
if: ${{ inputs.unit_tests_linux_enabled }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift:
- image: swift:5.8-jammy
- image: swift:5.9-jammy
- image: swift:5.10-jammy
- image: swiftlang/swift:nightly-6.0-jammy
- image: swiftlang/swift:nightly-main-jammy
container:
image: ${{ matrix.swift.image }}
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
run: swift test

benchmarks-linux:
name: Benchmarks
if: ${{ inputs.benchmarks_linux_enabled }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift:
- image: swift:5.8-jammy
swift_version: "5.8"
- image: swift:5.9-jammy
swift_version: "5.9"
- image: swift:5.10-jammy
swift_version: "5.10"
- image: swiftlang/swift:nightly-6.0-jammy
swift_version: "nightly-next"
- image: swiftlang/swift:nightly-main-jammy
swift_version: "nightly-main"
container:
image: ${{ matrix.swift.image }}
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run tests
env:
PACKAGE_PATH: ${{ inputs.benchmarks_linux_package_path }}
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
run: |
apt-get update -y -q && apt-get install -y -q libjemalloc-dev
swift package --package-path ${PACKAGE_PATH} --disable-sandbox benchmark baseline check --check-absolute-path ${PACKAGE_PATH}/Thresholds/${SWIFT_VERSION}/
api-breakage-check:
name: API breakage check
if: ${{ inputs.api_breakage_check_enabled }}
runs-on: ubuntu-latest
container:
image: swift:5.10-noble
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We need to fetch everything otherwise only the head commit will be fetched.
fetch-depth: 0
- name: Mark the workspace as safe
# https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Run API breakage check
run: swift package diagnose-api-breaking-changes origin/main

docs-check:
name: Documentation check
if: ${{ inputs.docs_check_enabled }}
runs-on: ubuntu-latest
container:
image: swift:5.10-noble
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run documentation check
run: |
apt-get -qq update && apt-get -qq -y install curl
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-docs.sh | bash
unacceptable-language-check:
name: Unacceptable language check
if: ${{ inputs.unacceptable_language_check_enabled }}
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run unacceptable language check
env:
UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}}
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-unacceptable-language.sh | bash

license-header-check:
name: License headers check
if: ${{ inputs.license_header_check_enabled }}
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run license header check
env:
PROJECT_NAME: ${{ inputs.license_header_check_project_name }}
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-license-header.sh | bash

broken-symlink-check:
name: Broken symlinks check
if: ${{ inputs.broken_symlink_check_enabled }}
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run broken symlinks check
run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-broken-symlinks.sh | bash

format-check:
name: Format check
if: ${{ inputs.format_check_enabled }}
runs-on: ubuntu-latest
container:
image: swiftlang/swift:nightly-6.0-jammy
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run format check
run: swift format lint --parallel --recursive --strict
47 changes: 47 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.mailfilter
.mailmap
.spi.yml
.swift-format
.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/*
Sources/CNIOAtomics/src/cpp_magic.h
Sources/CNIOLLHTTP/LICENSE-MIT
Sources/CNIOLLHTTP/c_nio_api.c
Sources/CNIOLLHTTP/c_nio_http.c
Sources/CNIOLLHTTP/c_nio_llhttp.c
Sources/CNIOLLHTTP/include/c_nio_llhttp.h
Sources/CNIOSHA1/c_nio_sha1.c
Sources/CNIOSHA1/include/CNIOSHA1.h
dev/alloc-limits-from-test-output
dev/boxed-existentials.d
dev/git.commit.template
dev/lldb-smoker
dev/make-single-file-spm
dev/malloc-aggregation.d
dev/update-alloc-limits-to-last-completed-ci-build
scripts/nio-diagnose
44 changes: 44 additions & 0 deletions Benchmarks/Benchmarks/NIOCoreBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2024 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import Benchmark
import NIOCore
import NIOEmbedded

let benchmarks = {
let defaultMetrics: [BenchmarkMetric] = [
.mallocCountTotal,
]

Benchmark(
"NIOAsyncChannel.init",
configuration: Benchmark.Configuration(metrics: defaultMetrics)
) { benchmark in
// Elide the cost of the 'EmbeddedChannel'. It's only used for its pipeline.
var channels: [EmbeddedChannel] = []
channels.reserveCapacity(benchmark.scaledIterations.count)
for _ in 0 ..< benchmark.scaledIterations.count {
channels.append(EmbeddedChannel())
}

benchmark.startMeasurement()
defer {
benchmark.stopMeasurement()
}
for channel in channels {
let asyncChanel = try NIOAsyncChannel<ByteBuffer, ByteBuffer>(wrappingChannelSynchronously: channel)
blackHole(asyncChanel)
}
}
}
25 changes: 12 additions & 13 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
// swift-tools-version: 5.7
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftCertificates open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftCertificates project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftCertificates project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import PackageDescription

Expand All @@ -37,5 +24,17 @@ let package = Package(
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
),
.executableTarget(
name: "NIOCoreBenchmarks",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOEmbedded", package: "swift-nio"),
],
path: "Benchmarks/NIOCoreBenchmarks",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 10
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 108
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 165000
}
4 changes: 2 additions & 2 deletions IntegrationTests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ fi

# report
if [[ $cnt_fail > 0 ]]; then
# kill leftovers (the whole process group)
# terminate leftovers (the whole process group)
trap '' TERM
kill 0
kill 0 # ignore-unacceptable-language

plugins_do summary_fail "$cnt_ok" "$cnt_fail"
else
Expand Down
Loading

0 comments on commit 86b8ac3

Please sign in to comment.