Skip to content

Commit 61cfaf9

Browse files
authored
Migrate to GitHub Actions (#487)
Migrate CI to use GitHub Actions. ### 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 minus allocation tests which remain on the old CI.
1 parent 27b25e2 commit 61cfaf9

File tree

84 files changed

+4282
-3294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4282
-3294
lines changed

.github/workflows/pull_request.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
soundness:
9+
name: Soundness
10+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
11+
with:
12+
license_header_check_project_name: "SwiftNIO"
13+
unit-tests:
14+
name: Unit tests
15+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
16+
with:
17+
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
18+
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
19+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
20+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
21+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
22+
23+
integration-tests:
24+
name: Integration test
25+
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
26+
with:
27+
name: "Integration test"
28+
matrix_linux_command: "apt-get update -yq && apt-get install -yq execstack lsof dnsutils netcat-openbsd net-tools expect curl jq && ./scripts/integration_tests.sh -f test_01_renegotiation"
29+
30+
cxx-interop:
31+
name: Cxx interop
32+
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
33+
34+
swift-6-language-mode:
35+
name: Swift 6 Language Mode
36+
uses: apple/swift-nio/.github/workflows/swift_6_language_mode.yml@main
37+
if: false # Disabled for now.
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: PR label
2+
3+
on:
4+
pull_request:
5+
types: [labeled, unlabeled, opened, reopened, synchronize]
6+
7+
jobs:
8+
semver-label-check:
9+
name: Semantic Version label check
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 1
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
- name: Check for Semantic Version label
18+
uses: apple/swift-nio/.github/actions/pull_request_semver_label_checker@main

.github/workflows/scheduled.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Scheduled
2+
3+
on:
4+
schedule:
5+
- cron: "0 8,20 * * *"
6+
7+
jobs:
8+
unit-tests:
9+
name: Unit tests
10+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
11+
with:
12+
linux_5_8_enabled: false
13+
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
14+
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
15+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
16+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
17+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
18+
19+
integration-tests:
20+
name: Integration test
21+
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
22+
with:
23+
name: "Integration test"
24+
matrix_linux_command: "apt-get update -yq && apt-get install -yq execstack lsof dnsutils netcat-openbsd net-tools expect curl jq && ./scripts/integration_tests.sh -f test_01_renegotiation"

.licenseignore

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.gitignore
2+
**/.gitignore
3+
.licenseignore
4+
.gitattributes
5+
.git-blame-ignore-revs
6+
.mailfilter
7+
.mailmap
8+
.spi.yml
9+
.swift-format
10+
.editorconfig
11+
.github/*
12+
*.md
13+
*.txt
14+
*.yml
15+
*.yaml
16+
*.json
17+
Package.swift
18+
**/Package.swift
19+
Package@-*.swift
20+
**/Package@-*.swift
21+
Package.resolved
22+
**/Package.resolved
23+
Makefile
24+
*.modulemap
25+
**/*.modulemap
26+
**/*.docc/*
27+
*.xcprivacy
28+
**/*.xcprivacy
29+
*.symlink
30+
**/*.symlink
31+
Dockerfile
32+
**/Dockerfile
33+
Snippets/*
34+
Sources/CNIOBoringSSL/*
35+
dev/alloc-limits-from-test-output
36+
dev/boxed-existentials.d
37+
dev/git.commit.template
38+
dev/lldb-smoker
39+
dev/make-single-file-spm
40+
dev/malloc-aggregation.d
41+
dev/update-alloc-limits-to-last-completed-ci-build
42+
scripts/patch-1-inttypes.patch
43+
scripts/patch-2-inttypes.patch
44+
scripts/patch-3-more-inttypes.patch
45+
.unacceptablelanguageignore

.swift-format

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"version" : 1,
3+
"indentation" : {
4+
"spaces" : 4
5+
},
6+
"tabWidth" : 4,
7+
"fileScopedDeclarationPrivacy" : {
8+
"accessLevel" : "private"
9+
},
10+
"spacesAroundRangeFormationOperators" : false,
11+
"indentConditionalCompilationBlocks" : false,
12+
"indentSwitchCaseLabels" : false,
13+
"lineBreakAroundMultilineExpressionChainComponents" : false,
14+
"lineBreakBeforeControlFlowKeywords" : false,
15+
"lineBreakBeforeEachArgument" : true,
16+
"lineBreakBeforeEachGenericRequirement" : true,
17+
"lineLength" : 120,
18+
"maximumBlankLines" : 1,
19+
"respectsExistingLineBreaks" : true,
20+
"prioritizeKeepingFunctionOutputTogether" : true,
21+
"rules" : {
22+
"AllPublicDeclarationsHaveDocumentation" : false,
23+
"AlwaysUseLiteralForEmptyCollectionInit" : false,
24+
"AlwaysUseLowerCamelCase" : false,
25+
"AmbiguousTrailingClosureOverload" : true,
26+
"BeginDocumentationCommentWithOneLineSummary" : false,
27+
"DoNotUseSemicolons" : true,
28+
"DontRepeatTypeInStaticProperties" : true,
29+
"FileScopedDeclarationPrivacy" : true,
30+
"FullyIndirectEnum" : true,
31+
"GroupNumericLiterals" : true,
32+
"IdentifiersMustBeASCII" : true,
33+
"NeverForceUnwrap" : false,
34+
"NeverUseForceTry" : false,
35+
"NeverUseImplicitlyUnwrappedOptionals" : false,
36+
"NoAccessLevelOnExtensionDeclaration" : true,
37+
"NoAssignmentInExpressions" : true,
38+
"NoBlockComments" : true,
39+
"NoCasesWithOnlyFallthrough" : true,
40+
"NoEmptyTrailingClosureParentheses" : true,
41+
"NoLabelsInCasePatterns" : true,
42+
"NoLeadingUnderscores" : false,
43+
"NoParensAroundConditions" : true,
44+
"NoVoidReturnOnFunctionSignature" : true,
45+
"OmitExplicitReturns" : true,
46+
"OneCasePerLine" : true,
47+
"OneVariableDeclarationPerLine" : true,
48+
"OnlyOneTrailingClosureArgument" : true,
49+
"OrderedImports" : true,
50+
"ReplaceForEachWithForLoop" : true,
51+
"ReturnVoidInsteadOfEmptyTuple" : true,
52+
"UseEarlyExits" : false,
53+
"UseExplicitNilCheckInConditions" : false,
54+
"UseLetInEveryBoundCaseVariable" : false,
55+
"UseShorthandTypeNames" : true,
56+
"UseSingleLinePropertyGetter" : false,
57+
"UseSynthesizedInitializer" : false,
58+
"UseTripleSlashForDocumentationComments" : true,
59+
"UseWhereClausesInForLoops" : false,
60+
"ValidateDocumentationComments" : false
61+
}
62+
}

.unacceptablelanguageignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Sources/CNIOBoringSSL/*
2+
NOTICE.txt

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ We require that your commit messages match our template. The easiest way to do t
6767

6868
SwiftNIO uses XCTest to run tests on both macOS and Linux. While the macOS version of XCTest is able to use the Objective-C runtime to discover tests at execution time, the Linux version is not. For this reason, whenever you add new tests you will want to run a script that generates the hooks needed to run those tests on Linux, or our CI will complain that the tests are not all present on Linux. To do this, merely execute `ruby generate_linux_tests.rb` at the root of the package and check the changes it made.
6969

70+
### Run CI checks locally
71+
72+
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).
73+
74+
7075
## How to contribute your work
7176

7277
Please open a pull request at https://github.com/apple/swift-nio. Make sure the CI passes, and then wait for code review.

IntegrationTests/plugin_junit_xml.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function junit_output_replace() {
4444

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

IntegrationTests/run-single-test.sh

+5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ set -x
2020
set -o pipefail
2121

2222
test="$1"
23+
# shellcheck disable=SC2034 # Used by whatever we source transpile in
2324
tmp="$2"
25+
# shellcheck disable=SC2034 # Used by whatever we source transpile in
2426
root="$3"
27+
# shellcheck disable=SC2034 # Used by whatever we source transpile in
2528
g_show_info="$4"
2629
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2730

31+
# shellcheck source=IntegrationTests/test_functions.sh
2832
source "$here/test_functions.sh"
33+
# shellcheck source=/dev/null
2934
source "$test"
3035
wait
3136
)

IntegrationTests/run-tests.sh

+10-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function plugins_do() {
3636
done
3737
}
3838

39+
# shellcheck source=IntegrationTests/plugin_echo.sh
3940
source "$here/plugin_echo.sh"
41+
# shellcheck source=/dev/null
4042
source "$here/plugin_junit_xml.sh"
4143

4244
plugins="echo"
@@ -88,7 +90,7 @@ function run_test() {
8890
if $verbose; then
8991
"$@" 2>&1 | tee -a "$out"
9092
# we need to return the return value of the first command
91-
return ${PIPESTATUS[0]}
93+
return "${PIPESTATUS[0]}"
9294
else
9395
"$@" >> "$out" 2>&1
9496
fi
@@ -113,13 +115,13 @@ for f in tests_*; do
113115
plugins_do test_begin "$t" "$f"
114116
start=$(date +%s)
115117
if run_test "$here/run-single-test.sh" "$here/$f/$t" "$test_tmp" "$here/.." "$show_info"; then
116-
plugins_do test_ok "$(time_diff_to_now $start)"
118+
plugins_do test_ok "$(time_diff_to_now "$start")"
117119
suite_ok=$((suite_ok+1))
118120
if $verbose; then
119121
cat "$out"
120122
fi
121123
else
122-
plugins_do test_fail "$(time_diff_to_now $start)" "$out"
124+
plugins_do test_fail "$(time_diff_to_now "$start")" "$out"
123125
suite_fail=$((suite_fail+1))
124126
fi
125127
if ! $debug; then
@@ -131,7 +133,7 @@ for f in tests_*; do
131133
cnt_ok=$((cnt_ok + suite_ok))
132134
cnt_fail=$((cnt_fail + suite_fail))
133135
cd ..
134-
plugins_do test_suite_end "$(time_diff_to_now $start_suite)" "$suite_ok" "$suite_fail"
136+
plugins_do test_suite_end "$(time_diff_to_now "$start_suite")" "$suite_ok" "$suite_fail"
135137
done
136138

137139
if ! $debug; then
@@ -142,17 +144,17 @@ fi
142144

143145

144146
# report
145-
if [[ $cnt_fail > 0 ]]; then
146-
# kill leftovers (the whole process group)
147+
if [[ $cnt_fail -gt 0 ]]; then
148+
# terminate leftovers (the whole process group)
147149
trap '' TERM
148-
kill 0
150+
kill 0 # ignore-unacceptable-language
149151

150152
plugins_do summary_fail "$cnt_ok" "$cnt_fail"
151153
else
152154
plugins_do summary_ok "$cnt_ok" "$cnt_fail"
153155
fi
154156

155-
if [[ $cnt_fail > 0 ]]; then
157+
if [[ $cnt_fail -gt 0 ]]; then
156158
exit 1
157159
else
158160
exit 0

IntegrationTests/test_functions.sh

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function assert_greater_than_or_equal() {
6464
g_has_previously_infoed=false
6565

6666
function info() {
67+
# shellcheck disable=SC2154 # Defined by an include our by being source transpiled in
6768
if $g_show_info; then
6869
if ! $g_has_previously_infoed; then
6970
echo >&3 || true # echo an extra newline so it looks better

IntegrationTests/tests_01_general/test_01_renegotiation.sh

+3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
##
1414
##===----------------------------------------------------------------------===##
1515

16+
# shellcheck source=IntegrationTests/tests_01_general/defines.sh
1617
source defines.sh
1718

1819
swift build
1920

2021
# Generate a self-signed certificate.
22+
23+
# shellcheck disable=SC2154 # Provided by framework
2124
cat << EOF > "$tmp/openssl.cnf"
2225
[ req ]
2326
distinguished_name = subject

IntegrationTests/tests_01_general/test_02_execstack.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
##
1414
##===----------------------------------------------------------------------===##
1515

16+
# shellcheck source=IntegrationTests/tests_01_general/defines.sh
1617
source defines.sh
1718

1819
if [[ "$(uname -s)" == "Darwin" ]]; then
@@ -26,7 +27,7 @@ swift build -c release
2627
DEBUG_SERVER_PATH="$(swift build --show-bin-path)/NIOTLSServer"
2728
RELEASE_SERVER_PATH="$(swift build --show-bin-path -c release)/NIOTLSServer"
2829

29-
results=$(execstack $DEBUG_SERVER_PATH $RELEASE_SERVER_PATH)
30+
results=$(execstack "$DEBUG_SERVER_PATH" "$RELEASE_SERVER_PATH")
3031
count=$(echo "$results" | grep -c '^X' || true)
3132
if [ "$count" -ne 0 ]; then
3233
exit 1

IntegrationTests/tests_02_allocation_counters/test_01_allocation_counts.sh

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
##
1414
##===----------------------------------------------------------------------===##
1515

16+
# shellcheck source=IntegrationTests/tests_02_allocation_counters/defines.sh
1617
source defines.sh
1718

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

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

3133
for test in "${all_tests[@]}"; do

0 commit comments

Comments
 (0)