Allow the specification of custom environment variables in our matrix
workflow and those which use it.
### Motivation:
It can be useful to supply custom environment variables to control build
and runtime options.
### Modifications:
Allow users to supply a string of custom environment variable key-value
pairs which are supplied to the docker container running the matrix
commands.
To attempt to avoid issues with this string concatenation the change
also allows the user to specify custom list entry and key-value-pair
separators.
To avoid parameter bloat the env vars are set for all Swift versions,
hopefully that's sufficient for now.
### Result:
Adopters can
Examples of this working on Linux and Windows, note the presence of the
test environment variables I injected:
-
https://github.com/apple/swift-nio/actions/runs/17917619451/job/50943847555?pr=3376
- https://github.com/apple/swift-crypto/pull/413/checks
e.g.
```
Executing Docker command: docker run -v /home/runner/work/swift-nio/swift-nio:/swift-nio -w /swift-nio -e CI=true -e GITHUB_ACTIONS=true -e SWIFT_VERSION=6.0 -e workspace=/swift-nio -e TEST_DEBUG=1 -e TEST_LOG_LEVEL=info swift:6.0-jammy bash -c swift --version && swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error
```
### 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.
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:
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:
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
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