Instead of evaluating inputs directly in the run step, save them to an
environment variable and evaluate that.
### Motivation:
Evaluating workflow inputs directly can lead to injection attacks, such
as those described at https://docs.zizmor.sh/audits/#template-injection
### Modifications:
Evaluate workflow inputs as environment variables so that they do not
inadvertently execute arbitrary shell injections.
### Result:
The workflows should be more secure against malicious inputs.
Don't generate matrix jobs for Swift versions which aren't supported by
the package.
### Motivation:
Matrix workflows should not generate jobs for Swift versions < tools
version, doing so wastes compute and adds noise.
This means that:
- New repos don’t need to manually opt-out of old Swift versions
- Repos which have dropped an old Swift version (during a migration
window) won’t have failing tests until it’s turned off centrally.
### Modifications:
- The generate script now looks for `Package.swift` and
`Package@swift-*.swift` files and uses the lowest tools version in any
found file to determine the minimum supported Swift version
- Any Swift version lower than the minimum is disregarded and no jobs
are generated for it
- A new parameter is added to the workflows which allows the minimum
Swift version to be set manually (`minimum_swift_version`)
### Result:
By default in this and downstream packages we don't generate matrix jobs
for Swift versions which aren't supported by the package.
An example of this working:
https://github.com/apple/swift-nio/actions/runs/18711362977/job/53360387720?pr=3415
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:
Not everything that relies on these workflows builds on windows. Unit
tests and release builds should be explicitly enabled for windows
builds.
### Modifications:
Change default of windows nightly to false. Fix flag checks that enable
nightly builds.
### Result:
Easier to use CI workflows.
### 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:
To have more version about which swift is running to aid in debugging.
### Modifications:
Run swift --version on common workflows, this should be safe because
they all assume Swift is already nistalled unlike the Static SDK
workflow.
### Result:
Swift tools information will be printed before job execution
An example of this working:
https://github.com/apple/swift-nio/actions/runs/15049159516/job/42299334292
### Motivation:
Swift 5.9 is no longer supported and CI has been updated to no longer
require it, we should disable it by default.
### Modifications:
* Default Swift 5.9 CI jobs to disabled
### Result:
Swift 5.9 CI jobs will not run unless opted-in
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)
### 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:
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**.
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
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
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>