Static SDK installation script improvements
### Motivation:
Make static SDK installation scripts more modular and make
failures easier to diagnose.
### Modifications:
- Allow specification of binaries from outside the installation script
- Remove script dependency installation from the script
- Separate the Swift dependency installation into its own script
- Fatal error explicitly if the installed Swift can't be found
- Make curl operations for downloading artifacts explicitly fail
### Result:
Scripts which are easier to maintain and operate.
An example CI run with this in operation
https://github.com/apple/swift-nio/actions/runs/14329482180/job/40162003318?pr=3186
### Motivation:
These don't work on all versions but we should allow people to opt-in if
they know they do work
### Modifications:
Uncomment the steps and make the step default to off
### Result:
People can choose to run visionOS builds and tests
### Motivation:
Xcode 16.3 has been released, we should cover it in CI
### Modifications:
* Add Xcode 16.3 runs by default
* Disable Xcode 16.0 runs by default (soft deprecation)
Note that the Xcode version offering is still a work in progress.
### Result:
macOS CI will test using Xcode 16.3
An example run with this working
https://github.com/apple/swift-nio/actions/runs/14220724296/job/39876502770?pr=3171
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
Separate build and test steps in `macos_tests.yml`. Test execution can
now also be disabled through an input. This is useful for clarity of
output and also in some cases where test execution may not be supported
yet.
### 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
### Motivation
A few repositories have custom workflows for checking CMake, we would
like to unify this for maintenance and adoption simplicity.
Further to this at the moment they only check that the scripts are
up-to-date, we'd also like to have them build using CMake.
### Modifications
Add the re-usable workflow and supporting scripts
### Result:
Repositories using CMake can switch to the centralised workflow.
An example of it in action
https://github.com/apple/swift-crypto/actions/runs/13837092514/job/38782284575
### Motivation:
The static SDK workflow currently assumes a local setup script which
isn't true for external adopters.
### Modifications:
* The static SDK workflow now curls for the setup script.
* Run Static SDK checks on PR commits
### Result:
External adopters should be unblocked.
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:
Updating the CI parameters for changing nightly job targets with each
new Swift version (6.0, 6.1, ...) is onerous. Whilst this gives us some
value in the non-nightly pipelines by forcing adopters to apply thought
to what is applied to each supported version, the nightlies arguably
deliver less value in this regard as they tend to be non-required.
### Modifications:
Change parameters to refer to nightly_next rather than nightly_6_1,
implement
a shim so that the old parameter names still work.
### Result:
We will be able to modify top-level workflows to use nightly_next
terminology.
Test run with an additional commit opting in to use these changes at the
top level
https://github.com/apple/swift-nio/actions/runs/13524774485/job/37792437713?pr=3122
### Motivation:
It can be useful for scripts to be able to check if they are being run
in CI. Because we invoke docker on the CI runners, the env var which
people may use to do this isn't present.
### Modifications:
Expose `GITHUB_ACTIONS` env var to docker containers in the matrix
workflow
### Result:
Adopters of the matrix workflow or downstream workflows will be able to
check if they are running in CI
### Motivation:
Some repositories still use the older CI Swift matrix directly so we
need to update it to handle 6.1 nightlies.
### Modifications:
Replace 6.0 nightly with 6.1 nightly.
### Result:
External CI should use 6.1 nightly.
### 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
### Motivation:
Active development has moved to 6.1 so the Swift 6.0 nightlies no longer
deliver much value.
### Modifications:
* Deprecate 6.0 nightly CI configuration parameters
* Introduce new 6.1 nightly CI configuration parameters
* Update the matrix generation script to handle 6.1
### Result:
* No more nightly 6.0 CI, 6.1 nightlies are introduced.
* Configuration for 6.0 nightlies no longer has any effect.
* All repos are automatically opted-in to 6.1 nightly linux pipelines
**even if they opted out of 6.0**.
### Motivation:
The use of 'swift' here is very arbitrary and adds no value. The object
is only there at all because GitHub Actions seems to require it.
### Modifications:
Rename the top-level object from 'swift' to 'config' to maybe add value
to the intent of the object and hopefully be less cryptic.
### Result:
Everything should just keep working.
### Motivation:
The new test matrix workflow is quite verbose in the most common case,
unit tests, outputting two workflow entries for handling and preparing
the matrix inputs.
In addition to this, it appeared that when running in `act` the matrix
preparation step would run multiple times.
### Modifications:
* Prioritize the current most common case, string inputs, and skip the
matrix preparation step in this case reducing the number of workflows
run.
* Separate the path for loading the JSON matrix from a file into its own
workflow.
### Result:
* Less noise in the output
* More reliable and efficient local matrix runs
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 have some tests for our Vsock support that only run when we detect
the system supports Vsock. These weren't running in CI but, now we've
migrated CI to GitHub Actions, they can. In prototyping this though, I
discovered that one of our tests was too strict, and will fail for VMs
running on Hyper-V, which is the hypervisor used by GitHub actions.
Specifically, we have support for getting the local context ID by a
channel option. This is implemented by an ioctl, but the semantics of
the return value differ between the various Vsock transport kernel
modules:
- `virtio_transport`: returns the guest CID, which is a number greater
than `VMADDR_CID_HOST`, but less than `VMADDR_CID_ANY`, and returns
`VMADDR_CID_ANY` as an error.
- `vsock_loopback`: returns `VMADDR_CID_LOCAL` always.
- `vmci_transport`: returns the guest CID if the guest and host
transport are active; `VMADDR_CID_HOST` if only the host transport is
active; and `VMCI_INVALID_ID` otherwise, which happens to be the same
value as `VMADDR_CID_ANY`.
- `hyperv_transport`: returns `VMADDR_CID_ANY` always.
For this reason, we should probably remove any attempts to interpret the
validity of the value that comes back from the driver and users will
need to know what to do with it.
### Modifications:
- tests: Only run Vsock echo tests on Linux, when `vsock_loopback` is
loaded.
- tests: Remove asserts on the value of local Vsock CID.
- ci: Add pipeline that runs Vsock tests.
### Result:
- Vsock tests will no longer run unless `vsock_loopback` kernel module
is loaded.
- Vsock tests will no longer fail in Hyper-V VMs.
- Vsock tests will now run in CI.
### Motivation:
Documentation checking catches more issues in Swift 6.0.
### Modifications:
Adopt the Swift 6.0 image and fix the errors.
### Result:
More accurate docs.
Motivation:
Some repos using this as their source of GitHub Actions logic have
submodules.
Modifications:
Change workflows to checkout submodules.
Result:
All CI will work cleanly
# Motivation
Currently, the Windows 6.0 check name includes the matrix properties.
# Modification
This PR makes it dynamic with the swift version again.
# Result
Aligned CI check names across platforms.
This PR makes it possible to enable benchmarks and cxx interop checks on
Windows. By default they are turned off. This PR also fixes the job of
the Windows 6 pipeline which was broken since single configuration
matrix jobs seem to behave differently.
# Motivation
There were two small problems:
1. The CI for the nightlies wasn't properly skipped
2. The name for the matrix wasn't applied in the case where it was
skipped
# Modification
This PR hopefully fixes both issues.
# Motivation
In the long term we want to add support for Windows in our Swift
packages. To do this we need a CI setup to ensure that our packages are
building and the tests are passing.
# Modification
This PR adds a windows job to our swift matrix that installs Swift on
the runner and then uses Swift PM to build and test the package. Windows
jobs are disabled by default since most of our packages require some
work to add Windows support.
# Result
We have a Windows CI pipeline that allows us to verify that our packages
are working.
# 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.
Disable semver-label-check locally when run via `act`.
### Motivation:
This check makes no sense when run locally.
### Modifications:
Disable semver-label-check locally when run via `act`.
### Result:
The label check should no longer run and fail locally.
# 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:
This repo is providing a reusable workflow for checking API breaks but
it has two shortcomings:
1. It presumes the target branch name for the PR to be `main`.
2. It presumes the remote is named `origin`.
(2) is always the case in CI, but isn't always locally. My remote is
named `upstream` so cannot run this using `act`. (1) is worse, because
it's not actually testing against the target branch of the PR—consider
if someone was enabling this reusable workflow on a feature branch or
other-named branch.
Fortunately, Github Actions makes the target ref of the pull request
available in the `GITHUB_BASE_REF` environment variable[^0].
### Modifications:
Use `GITHUB_BASE_REF` as the argument to `swift package
diagnose-api-breaking-changes`.
### Result:
This can now be run locally.
[^0]:
https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
### Motivation:
We want to be able to run the soundness checks locally, and our current
guidance for this is to use `act`. However, there is a documented[^0]
difference in the runner images it uses and those used by Github Actions
proper. One such difference is a lack of `shellcheck` in both the small
and medium runners, which _is_ present in Github's image for the
`ubuntu-latest` platform.
### Modifications:
There are official images for `shellcheck`: both a single binary and an
alpine-based image, which are very small. Neither of these has `bash`,
nor `git`, which are dependencies of the script.
This PR updates the workflow to use a container for this job and uses
the same image used in some other jobs, along with a step to install
`shellcheck`, which is in keeping with what we do for other jobs in the
soundness workflow already to e.g. install `yq`.
### Result:
Can run the soundness job locally using `act`. No change in CI.
[^0]:
https://nektosact.com/usage/runners.html#default-runners-are-intentionally-incomplete
# 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.
…and remove docc plugin
# Motivation
Some repositories might want to run their soundness and matrix jobs
checks on different container images e.g. a repo might build against the
nightly toolchains only so their soundness jobs should also use nightly
images. Other repos might want to build against a different linux
distribution since their usual deployment target is not Ubuntu based.
Additionally, we currently require our repos to depend on the docc
plugin for building documentation which adds an unnecessary dependency
to all of our packages.
# Modification
This PR makes the container images for the soundness and matrix jobs
configurable. Furthermore, it modifies the docs check script to add the
docc-plugin dependency and removes the current dependency from our
manifest.
# Result
Our workflows can be adopted by more repositories.