Swift SDK installation script improvements
### Motivation:
The SDK installation scripts had a few rough edges and didn't verify the
artefacts they downloaded.
### Modifications:
* Change naming to the more accurate "Swift SDK" where we can without
breaking downstream adopters.
* Separate Android NDK installation into its own script.
* Avoid using `cd` when setting up Android NDK.
* Verify checksums for SDKs and signatures for toolchains.
* Specify/control the SDK directory.
### Result:
* More accurate naming.
* More maintainable scripts.
* More secure downloads.
An example of this working
https://github.com/apple/swift-nio/actions/runs/18944235613/job/54090944716?pr=3429
### Motivation:
Android SDKs now exist and testing is good.
### Modifications:
Add an Android GitHub Actions workflow using the latest nightly image
and enable it in NIO targetting NIOCore (matching WASM testing).
### Result:
More reusable workflows and more test coverage for NIO
See this in action here (the CI job works but NIOCore fails to build):
https://github.com/apple/swift-nio/actions/runs/18718487605/job/53384086329?pr=3418
WASM SDK GitHub Actions workflows use NIO matrix rather than the
swiftlang one
### Motivation:
Using the NIO one is more in line with the surrounding workflows and
surfaces a simpler UI (possible jobs which aren't run don't appear in
the UI)
### Modifications:
Pull in changes from https://github.com/apple/swift-nio/pull/3159 and
add in the ability to specify environment variables and other build
arguments in line with the static Linux SDK workflow.
### Result:
More regularity, simpler checks UI.
See this in action here:
https://github.com/apple/swift-nio/actions/runs/18717131164/job/53379323803?pr=3417
---------
Co-authored-by: Yuta Saito <kateinoigakukun@gmail.com>
Co-authored-by: Max Desiatov <m_desiatov@apple.com>
Add build check CI for WebAssembly SDK
### Motivation:
Add build check CI for WebAssembly SDK
### Modifications:
Add Wasm build checks in `main.yml` and `pull_request.yml` based on
https://github.com/apple/swift-nio/pull/3331
Extracted from https://github.com/apple/swift-nio/pull/3159
### Result:
Setting up the CI job makes it easier to detect such incompatibility
before merging.
Fixes all warnings when `-require-explicit-sendable` flag is enabled and
enables the flag on macOS CI.
### Motivation:
We want to ensure our public API is either explicitly marked as
`Sendable` or not.
### Modifications:
Marked appropriate public types as `Sendable`, or explicitly defined
their conformance to the `Sendable` protocol as unavailable.
### Result:
We can now enable `-require-explicit-sendable` compiler flag in our
codebase.
### Motivation:
Some errors do not show up in debug builds. Enabling release mode builds
improves the CI coverage.
### Modifications:
Enable release mode builds for pull requests and scheduled builds on
main.
### Result:
Improved CI coverage.
### Motivation:
Some 429: Too many requests responses have been seen when attempting to
curl remote CI scripts.
### Modifications:
Adding `--retry 3` which means that curl will retry 3 times on transient
error codes.
### Result:
Transient errors will be retried 3 times, first for 1 second and then
doubled each retry.
From `man curl`
```
--retry <num>
If a transient error is returned when curl tries to perform a transfer, it
retries this number of times before giving up. Setting the number to 0
makes curl do no retries (which is the default). Transient error means
either: a timeout, an FTP 4xx response code or an HTTP 408, 429, 500, 502,
503 or 504 response code.
When curl is about to retry a transfer, it first waits one second and then
for all forthcoming retries it doubles the waiting time until it reaches 10
minutes which then remains delay between the rest of the retries. By using
--retry-delay you disable this exponential backoff algorithm. See also
--retry-max-time to limit the total time allowed for retries.
curl complies with the Retry-After: response header if one was present to
know when to issue the next retry (added in 7.66.0).
If --retry is provided several times, the last set value is used.
```
Motivation:
Swift 5.9 is no longer supported, we should bump the tools version and
remove it from our CI.
Modifications:
* Bump the Swift tools version to Swift 5.10
* Remove Swift 5.9 jobs where appropriate in main.yml, pull_request.yml
Result:
Code reflects our support window.
Add and enable Swift 6.1 workflows
### Motivation:
Swift 6.1 has been released, we should add it to our CI coverage.
### Modifications:
* Update `appe/swift-nio/scripts/generate_matrix.sh`
* Update reusable adopters of `swift_test_matrix.yml`
* Update end-user adopter workflows of `swift_test_matrix.yml`
* Copy over test flags from Swift 6.0 jobs
### Result:
NIO tests against Swift 6.1 in CI and downstream repositories can
opt-in.
(Successful CI run with the workflows modified to use the changes on
this branch
https://github.com/apple/swift-nio/actions/runs/14400598096?pr=3196)
Add support for macOS CI runner pools
### Motivation:
With new runners coming online we are separating the runners into pools.
* "nightly" runners are to be targeted for asynchronous work which users
aren't waiting on such as overnight work.
* "general" runners can be used for either synchronoous or asynchronous
work.
* At the moment all runers are "general" runners, a subset are "nightly"
runners.
The aim here is to prioritize work which users are waiting for such as
on PRs. Asynchronous work prioritizing the "nightly" runners will likely
end up queuing for the contended runners but synchronous work will claim
any available node.
### Modifications:
* Add a `runner_pool` input for the macOS workflow
* Default the `runner_pool` to `nightly` since the vast majority of
existing workflows are specifying asynchronous work.
* Specify the runner pool in NIO's use of macOS CI.
### Result:
Support for runner pools.
An example of this in action:
https://github.com/apple/swift-nio/actions/runs/14188573697/job/39748250001
### Motivation:
We are still exploring the shape of macOS CI and exploring the system's
capabilities.
### Modifications:
* Add visionOS jobs
* Remove Xcode 15.4 as it is no longer on the runners
* Add support for running tests targetting other platforms
* Enable test targeting other platforms on daily jobs to increase
coverage without bloating PR runtimes.
### Result:
More macOS CI coverage
CI run with this enabled
https://github.com/apple/swift-nio/actions/runs/13944231147/job/39027647470?pr=3150
- the iOS failure is unrelated to this change
Enable macOS CI
### Motivation:
To expand test coverage to the Darwin platforms.
### Modifications:
Create a new re-usable workflow `macos_tests.yml` which offers testing
and compilation checks for multiple Xcodes and simulator destinations.
The new workflow first performs `swift test` with configurable
parameters and then goes on to build the code targeting generic
destinations for:
* iOS
* macOS
* macOS Catalyst
* tvOS
* visionOS (temporarily disabled due to a possible runner issue)
* watchOS
At the moment this is workflow is enabled to run on the NIO repository:
* on each commit to a PR
* on each merge to `main`
* overnight on a timer
This will likely be revised due to capacity.
This functionality is implemented as a standalone workflow to preserve
flexibility as requirements and capacity change over time.
### Result:
Increased test coverage.
A re-usable static SDK compilation workflow
### Motivation:
We would like to offer the ability to opt-in to CI coverage for
compilation against the Linux static SDK.
### Modifications:
Introduce a workflow which will install a Swift snapshot and Linux SDK
and test the repository builds against it.
The script which sets up the VM will install snapshots and SDKs for
either branch or released-version snapshots. They can be specified as:
- a specific version string
- the 'latest' version, the script attempts to find the most recent
version enumerated on swift.org with both SDK and toolchain available
- the most recent snapshot for the specified branch name enumerated on
swift.org with both SDK and toolchain available
At the moment the script should work on ubuntu and amazonlinux OSes,
this can be expanded in the future.
The current matrix covers testing building on Ubuntu Jammy for the main
branch and latest released Swift version (6.0.3) and enables it on our
periodic CI runs.
See
https://github.com/apple/swift-nio/actions/runs/13722773053/job/38381907947?pr=3019
for a recent example of this workflow in action.
### Result:
Increased CI coverage
### Motivation:
Some changes were missed in #3076, passing through parameters for the
new 6.1 version.
### Modifications:
Pass through more parameters, clean up misleading comments.
### Result:
6.1 nightly runs will be more like 6.0 nightly runs were
Re-usable workflows curl scripts
### Motivation:
Other workflows re-use the NIO workflows they don't do a full git
checkout so they don't have access to the scripts, we need to curl them.
### Modifications:
curl the scripts
### Result:
Downstream repositories should be able to re-use these workflows
Matrix workflows refer to main branch
### Motivation:
Now that the workflow files are committed we can refer to them on the
main branch
### Modifications:
Replace @matrix_file with @main
### Result:
More stable references in workflows.
Introduce and adopt a new method for defining test matrices,
`swift_test_matrix.yml`.
⚠️ Any external adopters of the unit tests, Cxx interop and benchmarks
workflows are automatically opted in to use the new infrastructure.
### Motivation:
* The current matrix workflow has the limitation that it only supports
pre-defined sets of variables which are explored in the test matrix. At
the moment this is a pre-defined set of Swift versions on Linux and
Windows.
* Adding more means hard-coding them at multiple levels of the workflow
hierarchy.
* Currently skipped Windows matrix jobs show up as successes in the
GitHub UI leading to a misleading impression of good coverage.
### Modifications:
Introduce and adopt a new method for defining test matrices,
`swift_test_matrix.yml`. The new method is based around the approach of
defining the test matrix via a JSON object which may be supplied via an
input string from another workflow or from a file on-disk in a
repository.
Taking this approach means that we have the ability to add new targets
to the matrix simply by adding new elements to the JSON array,
increasing flexibility and the scope for future growth.
The unit tests, Cxx interop and benchmarks workflows are all modified to
use the new approach, this opts-in all downstream adopters. This should
be transparent to all downstream adopters.
In order to unify the Linux and Windows jobs I removed the use of the
`container:` GitHub Actions affordance in the Linux jobs which
transparently means all steps are executed within the nested container.
Instead we must manually call in to the docker container which
complicates scripting a little. I tested to see if doing this slowed
down the jobs (perhaps GitHub was caching the docker images more
intelligently) but it does not.
This approach follows the pattern of @FranzBusch 's open PR
https://github.com/apple/swift-nio/pull/2942
### Result:
* More flexible test matrix definitions
* No more false-passes for disabled Windows targets
### Motivation:
Warnings are annoying.
### Modifications:
- Remove unnecessary use of `Foundation.Thread` which isn't Sendable.
- Remove now unnecessary `@retroactive`s.
- Enable `-warnings-as-errors` in CI
### Result:
- Warnings can't sneak in as easily anymore
- No more warnings left in `swift-nio`
```
$ rm -rf .build/arm64-apple-macosx/ && swift build --build-tests -Xswiftc -warnings-as-errors > /dev/null
echo $?
$ echo $?
0
```
Co-authored-by: Cory Benfield <lukasa@apple.com>
# Motivation
We only support the last three Swift released versions which are at this
time 5.9, 5.10 and 6.
# Modification
This PR drops anything related to Swift 5.8.
# Result
Version support aligned.
# Motivation
Our support strategy includes the last three released Swift versions.
After the recent release of Swift 6 this means we now support 5.9, 5.10
and 6.0.
# Modification
This PR updates our CI configuration and scripts to align with our
supported Swift versions.
# Result
Up to date CI coverage.
# Motivation
Switch to the reusable workflows from the swiftlang organization for
soundness.
# Modification
This PR moves over to the new reusable soundness workflow. Additionally,
it also deletes all files in this repo for the soundness checks since
they are no longer needed.
### Motivation:
This repo contains reusable workflows, intended for use in _other_
repos. Right now, some of these reusable workflows are nested, i.e. some
of the YAML files refer to other YAML files in the repo by a relative
path.
Unfortunately, this makes them currently unusable locally with `act`
because of https://github.com/nektos/act/issues/1875.
For now, it appears the only workaround is to have these referred to
without the local, relative path.
### Modifications:
Use the remote syntax for referencing nested workflows.
### Result:
Commands like `act -j unit-tests` will work in repos that aren't NIO
itself.
---------
Co-authored-by: Franz Busch <privat@franz-busch.de>
# Motivation
We want to get green check marks on our commits to main. To do this we
have to run part of our CI jobs when a new commit is pushed.
# Modification
This PR adds a new workflow trigger to run our CI when a commit is
pushed to the main branch.
# Result
Green checkmarks on our commits.