Skip to content

Commit

Permalink
[GHA] Cxx interoperability compatibility and integration tests check
Browse files Browse the repository at this point in the history
# Motivation

Another reusable check is to make sure that all library products of a package are successfully building when consumed from a module that has Cxx interoperability enabled. Another check that's missing is running the integration tests.

# Modification

This PR adds two new checks to the reusable workflow. One to check for Cxx interoperability compatibility and another one to run the integration tests. I also fixed a misalgined name for the nightly benchmarks.

# Result

This should be one of the last reusable workflow checks.
  • Loading branch information
FranzBusch committed Jul 15, 2024
1 parent b1bf036 commit 6b84f1d
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,18 @@ jobs:
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Benchmarks"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q libjemalloc-dev && swift package --package-path Benchmarks/ --disable-sandbox benchmark baseline check --check-absolute-path Benchmarks/Thresholds/${SWIFT_VERSION}/
"
matrix_linux_command: "apt-get update -y -q && apt-get install -y -q libjemalloc-dev && swift package --package-path Benchmarks/ --disable-sandbox benchmark baseline check --check-absolute-path Benchmarks/Thresholds/${SWIFT_VERSION}/"

call-pull-request-cxx-interop-workflow:
name: Cxx interop
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Cxx interop"
matrix_linux_command: "./scripts/check-cxx-interop-compatibility.sh"

call-pull-request-integration-tests-workflow:
name: Integration tests
uses: ./.github/workflows/pull_request_swift_matrix.yml
with:
name: "Integration tests"
matrix_linux_command: "./scripts/integration_tests.sh"
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
test:
image: swift-nio:22.04-next
environment:
- SWIFT_VERSION=nightly-next
- SWIFT_VERSION=nightly-6.0
- MAX_ALLOCS_ALLOWED_10000000_asyncsequenceproducer=21
- MAX_ALLOCS_ALLOWED_1000000_asyncwriter=1000050
- MAX_ALLOCS_ALLOWED_1000_addHandlers=45050
Expand Down Expand Up @@ -79,7 +79,7 @@ services:
update-benchmark-baseline:
image: swift-nio:22.04-next
environment:
- SWIFT_VERSION=nightly-next
- SWIFT_VERSION=nightly-6.0

shell:
image: swift-nio:22.04-next
Expand Down
42 changes: 42 additions & 0 deletions scripts/check-cxx-interop-compatibility.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## 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
##
##===----------------------------------------------------------------------===##

set -euo pipefail

log() { printf -- "** %s\n" "$*" >&2; }
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
fatal() { error "$@"; exit 1; }

log "Checking for Cxx interoperability comaptibility..."

source_dir=$(pwd)
working_dir=$(mktemp -d)
project_name=$(basename "$working_dir")
source_file=Sources/$project_name/$(echo "$project_name" | tr . _).swift
library_products=$( swift package dump-package | jq -r '.products[] | select(.type.library != null) | .name')
package_name=$(swift package dump-package | jq -r '.name')

cd "$working_dir"
swift package init
echo "package.dependencies.append(.package(path: \"$source_dir\"))" >> Package.swift

for product in $library_products; do
echo "package.targets.first!.dependencies.append(.product(name: \"$product\", package: \"$package_name\"))" >> Package.swift
echo "import $product" >> "$source_file"
done

swift build

log "✅ Passed the Cxx interoperability tests."
8 changes: 7 additions & 1 deletion scripts/check-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
##
##===----------------------------------------------------------------------===##

set -eu
set -euo pipefail

log() { printf -- "** %s\n" "$*" >&2; }
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
fatal() { error "$@"; exit 1; }

raw_targets=$(sed -E -n -e 's/^.* - documentation_targets: \[(.*)\].*$/\1/p' .spi.yml)
targets=(${raw_targets//,/ })

for target in "${targets[@]}"; do
swift package plugin generate-documentation --target "$target" --warnings-as-errors --analyze --level detailed
done

log "✅ Found no documentation issues."

0 comments on commit 6b84f1d

Please sign in to comment.