Skip to content

Commit

Permalink
Migrate to GitHub Actions (#174)
Browse files Browse the repository at this point in the history
Migrate CI to use GitHub Actions with the exception of allocation count
performance tests which will remain on the old CI for now.

Motivation:

To migrate to GitHub actions and centralised infrastructure.

Modifications:

Changes of note:
* Disable warnings-as-errors until issues with recent NIO changes are
  resolved
* Adopt swift-format using rules from SwiftNIO
* Remove scripts which are no longer needed

Result:

Feature parity with old CI, all-but-allocations migrated to GHA.
  • Loading branch information
rnro authored Oct 24, 2024
1 parent e4301e1 commit 4b8bf94
Show file tree
Hide file tree
Showing 102 changed files with 5,016 additions and 2,078 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PR

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

jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftNIO"
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
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

swift-6-language-mode:
name: Swift 6 Language Mode
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
if: false # Disabled for now.
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 label

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

on:
schedule:
- cron: "0 8,20 * * *"

jobs:
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_8_enabled: false
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
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"
37 changes: 37 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.gitignore
**/.gitignore
.licenseignore
.gitattributes
.git-blame-ignore-revs
.mailfilter
.mailmap
.spi.yml
.swift-format
.swiftformat
.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/alloc-limits-from-test-output
dev/git.commit.template
dev/update-alloc-limits-to-last-completed-ci-build
62 changes: 62 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version" : 1,
"indentation" : {
"spaces" : 4
},
"tabWidth" : 4,
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"spacesAroundRangeFormationOperators" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 120,
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
13 changes: 0 additions & 13 deletions .swiftformat

This file was deleted.

2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language (e.g., prefer non-gendered words like “folks” to “guys”, non-ableist words like “soundness check” to “sanity check”, etc.)
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ We require that your commit messages match our template. The easiest way to do t

git config commit.template dev/git.commit.template

### Run CI checks locally

You can run the Github Actions workflows locally using [act](https://github.com/nektos/act). 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).

## How to contribute your work

Please open a pull request at https://github.com/apple/swift-nio-ssh. Make sure the CI passes, and then wait for code review.
6 changes: 3 additions & 3 deletions IntegrationTests/plugin_junit_xml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ function junit_output_replace() {

function plugin_junit_xml_test_suite_begin() {
junit_testsuite_time=0
junit_output_write "<testsuite name='$1' hostname='$(hostname)' "\
"timestamp='$(date -u +"%Y-%m-%dT%H:%M:%S")' tests='XXX-TESTS-XXX' "\
"failures='XXX-FAILURES-XXX' time='XXX-TIME-XXX' errors='0' id='$(date +%s)'"\
junit_output_write "<testsuite name='$1' hostname='$(hostname)' " \
"timestamp='$(date -u +"%Y-%m-%dT%H:%M:%S")' tests='XXX-TESTS-XXX' " \
"failures='XXX-FAILURES-XXX' time='XXX-TIME-XXX' errors='0' id='$(date +%s)'" \
" package='NIOIntegrationTests.$1'>"
}

Expand Down
5 changes: 5 additions & 0 deletions IntegrationTests/run-single-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ set -x
set -o pipefail

test="$1"
# shellcheck disable=SC2034 # Used by whatever we source transpile in
tmp="$2"
# shellcheck disable=SC2034 # Used by whatever we source transpile in
root="$3"
# shellcheck disable=SC2034 # Used by whatever we source transpile in
g_show_info="$4"
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# shellcheck source=IntegrationTests/test_functions.sh
source "$here/test_functions.sh"
# shellcheck source=/dev/null
source "$test"
wait
)
Expand Down
18 changes: 10 additions & 8 deletions IntegrationTests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function plugins_do() {
done
}

# shellcheck source=IntegrationTests/plugin_echo.sh
source "$here/plugin_echo.sh"
# shellcheck source=/dev/null
source "$here/plugin_junit_xml.sh"

plugins="echo"
Expand Down Expand Up @@ -88,7 +90,7 @@ function run_test() {
if $verbose; then
"$@" 2>&1 | tee -a "$out"
# we need to return the return value of the first command
return ${PIPESTATUS[0]}
return "${PIPESTATUS[0]}"
else
"$@" >> "$out" 2>&1
fi
Expand All @@ -113,13 +115,13 @@ for f in tests_*; do
plugins_do test_begin "$t" "$f"
start=$(date +%s)
if run_test "$here/run-single-test.sh" "$here/$f/$t" "$test_tmp" "$here/.." "$show_info"; then
plugins_do test_ok "$(time_diff_to_now $start)"
plugins_do test_ok "$(time_diff_to_now "$start")"
suite_ok=$((suite_ok+1))
if $verbose; then
cat "$out"
fi
else
plugins_do test_fail "$(time_diff_to_now $start)" "$out"
plugins_do test_fail "$(time_diff_to_now "$start")" "$out"
suite_fail=$((suite_fail+1))
fi
if ! $debug; then
Expand All @@ -131,7 +133,7 @@ for f in tests_*; do
cnt_ok=$((cnt_ok + suite_ok))
cnt_fail=$((cnt_fail + suite_fail))
cd ..
plugins_do test_suite_end "$(time_diff_to_now $start_suite)" "$suite_ok" "$suite_fail"
plugins_do test_suite_end "$(time_diff_to_now "$start_suite")" "$suite_ok" "$suite_fail"
done

if ! $debug; then
Expand All @@ -142,17 +144,17 @@ fi


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

plugins_do summary_fail "$cnt_ok" "$cnt_fail"
else
plugins_do summary_ok "$cnt_ok" "$cnt_fail"
fi

if [[ $cnt_fail > 0 ]]; then
if [[ $cnt_fail -gt 0 ]]; then
exit 1
else
exit 0
Expand Down
1 change: 1 addition & 0 deletions IntegrationTests/test_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function assert_greater_than_or_equal() {
g_has_previously_infoed=false

function info() {
# shellcheck disable=SC2154 # Defined by an include our by being source transpiled in
if $g_show_info; then
if ! $g_has_previously_infoed; then
echo >&3 || true # echo an extra newline so it looks better
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
##
##===----------------------------------------------------------------------===##

# shellcheck source=IntegrationTests/tests_01_allocation_counters/defines.sh
source defines.sh

set -eu
Expand All @@ -26,6 +27,7 @@ for file in "$here/test_01_resources/"test_*.swift; do
all_tests+=( "$test_name" )
done

# shellcheck disable=SC2154 # Provided by framework
"$here/test_01_resources/run-nio-ssh-alloc-counter-tests.sh" -t "$tmp" > "$tmp/output"

for test in "${all_tests[@]}"; do
Expand Down Expand Up @@ -53,5 +55,5 @@ for test in "${all_tests[@]}"; do
assert_less_than_or_equal "$total_allocations" "$max_allowed"
assert_greater_than "$total_allocations" "$(( max_allowed - 1000))"
fi
done < <(grep "^test_$test[^\W]*.total_allocations:" "$tmp/output" | cut -d: -f1 | cut -d. -f1 | sort | uniq)
done < <(grep "^test_${test}[^\W]*.total_allocations:" "$tmp/output" | cut -d: -f1 | cut -d. -f1 | sort | uniq)
done
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
set -eu
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# shellcheck disable=SC2154 # Provided by framework
tmp_dir="/tmp"

while getopts "t:" opt; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ final class AcceptAllHostKeysDelegate: NIOSSHClientServerAuthenticationDelegate
}

final class HardcodedClientPasswordDelegate: NIOSSHClientUserAuthenticationDelegate {
func nextAuthenticationType(availableMethods: NIOSSHAvailableUserAuthenticationMethods, nextChallengePromise: EventLoopPromise<NIOSSHUserAuthenticationOffer?>) {
func nextAuthenticationType(
availableMethods: NIOSSHAvailableUserAuthenticationMethods,
nextChallengePromise: EventLoopPromise<NIOSSHUserAuthenticationOffer?>
) {
precondition(availableMethods.contains(.password))
nextChallengePromise.succeed(NIOSSHUserAuthenticationOffer(username: "username", serviceName: "", offer: .password(.init(password: "password"))))
nextChallengePromise.succeed(
NIOSSHUserAuthenticationOffer(
username: "username",
serviceName: "",
offer: .password(.init(password: "password"))
)
)
}
}

Expand All @@ -35,7 +44,10 @@ final class HardcodedServerPasswordDelegate: NIOSSHServerUserAuthenticationDeleg
.password
}

func requestReceived(request: NIOSSHUserAuthenticationRequest, responsePromise: EventLoopPromise<NIOSSHUserAuthenticationOutcome>) {
func requestReceived(
request: NIOSSHUserAuthenticationRequest,
responsePromise: EventLoopPromise<NIOSSHUserAuthenticationOutcome>
) {
guard request.username == "username", case .password(let passwordRequest) = request.request else {
responsePromise.succeed(.failure)
return
Expand Down
Loading

0 comments on commit 4b8bf94

Please sign in to comment.