Skip to content

Commit 4cefe63

Browse files
committed
Motivation:
Make use of more common GitHub Actions migration workflows and repository style changes. Modifications: * Unit tests workflows run redis in a separate services container to speed up unit tests * Introduce `main.yml` which runs workflows on each commit to main and periodically to catch any regressions in merges or from upstream. * Remove the docker files which are no longer used and contained outdated pipelines. * Add Cxx interoperability checks Result: More in common with other GitHub Actions adoptions.
1 parent 2df3239 commit 4cefe63

13 files changed

+133
-260
lines changed

.github/workflows/main.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches: [main]
6+
schedule:
7+
- cron: "0 8,20 * * *"
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit tests
12+
uses: ./.github/workflows/unit_tests.yml
13+
with:
14+
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
15+
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
16+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
17+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
18+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

.github/workflows/pull_request.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ jobs:
1313

1414
unit-tests:
1515
name: Unit tests
16-
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
16+
uses: ./.github/workflows/unit_tests.yml
1717
with:
18-
linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}]"
19-
# since we don't have systemctl, we run the redis server manually in the background
20-
linux_pre_build_command: apt-get update -y && apt-get install redis -y
21-
linux_build_command: bash -c 'nohup redis-server & swift test'
22-
enable_windows_checks: false
18+
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
19+
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -strict-concurrency=complete"
20+
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
21+
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
22+
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
23+
24+
cxx-interop:
25+
name: Cxx interop
26+
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main

.github/workflows/unit_tests.yml

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Unit tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
linux_5_9_enabled:
7+
type: boolean
8+
description: "Boolean to enable the Linux 5.9 Swift version matrix job. Defaults to true."
9+
default: true
10+
linux_5_9_arguments_override:
11+
type: string
12+
description: "The arguments passed to swift test in the Linux 5.9 Swift version matrix job."
13+
default: ""
14+
linux_5_10_enabled:
15+
type: boolean
16+
description: "Boolean to enable the Linux 5.10 Swift version matrix job. Defaults to true."
17+
default: true
18+
linux_5_10_arguments_override:
19+
type: string
20+
description: "The arguments passed to swift test in the Linux 5.10 Swift version matrix job."
21+
default: ""
22+
linux_6_0_enabled:
23+
type: boolean
24+
description: "Boolean to enable the Linux 6.0 Swift version matrix job. Defaults to true."
25+
default: true
26+
linux_6_0_arguments_override:
27+
type: string
28+
description: "The arguments passed to swift test in the Linux 6.0 Swift version matrix job."
29+
default: ""
30+
linux_nightly_6_0_enabled:
31+
type: boolean
32+
description: "Boolean to enable the Linux nightly 6.0 Swift version matrix job. Defaults to true."
33+
default: true
34+
linux_nightly_6_0_arguments_override:
35+
type: string
36+
description: "The arguments passed to swift test in the Linux nightly 6.0 Swift version matrix job."
37+
default: ""
38+
linux_nightly_main_enabled:
39+
type: boolean
40+
description: "Boolean to enable the Linux nightly main Swift version matrix job. Defaults to true."
41+
default: true
42+
linux_nightly_main_arguments_override:
43+
type: string
44+
description: "The arguments passed to swift test in the Linux nightly main Swift version matrix job."
45+
default: ""
46+
47+
jobs:
48+
unit-tests:
49+
name: Unit tests
50+
runs-on: ubuntu-latest
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
# We are specifying only the major and minor of the docker images to automatically pick up the latest patch release
55+
swift:
56+
- image: "swift:5.9-jammy"
57+
swift_version: "5.9"
58+
enabled: ${{ inputs.linux_5_9_enabled }}
59+
- image: "swift:5.10-jammy"
60+
swift_version: "5.10"
61+
enabled: ${{ inputs.linux_5_10_enabled }}
62+
- image: "swift:6.0-jammy"
63+
swift_version: "6.0"
64+
enabled: ${{ inputs.linux_6_0_enabled }}
65+
- image: "swiftlang/swift:nightly-6.0-jammy"
66+
swift_version: "nightly-6.0"
67+
enabled: ${{ inputs.linux_nightly_6_0_enabled }}
68+
- image: "swiftlang/swift:nightly-main-jammy"
69+
swift_version: "nightly-main"
70+
enabled: ${{ inputs.linux_nightly_main_enabled }}
71+
steps:
72+
- name: Checkout repository
73+
if: ${{ matrix.swift.enabled }}
74+
uses: actions/checkout@v4
75+
with:
76+
persist-credentials: false
77+
submodules: true
78+
- name: Mark the workspace as safe
79+
if: ${{ matrix.swift.enabled }}
80+
# https://github.com/actions/checkout/issues/766
81+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
82+
- name: Run matrix job
83+
if: ${{ matrix.swift.enabled }}
84+
env:
85+
SWIFT_VERSION: ${{ matrix.swift.swift_version }}
86+
COMMAND: "swift test"
87+
COMMAND_OVERRIDE_5_9: "swift test ${{ inputs.linux_5_9_arguments_override }}"
88+
COMMAND_OVERRIDE_5_10: "swift test ${{ inputs.linux_5_10_arguments_override }}"
89+
COMMAND_OVERRIDE_6_0: "swift test ${{ inputs.linux_6_0_arguments_override }}"
90+
COMMAND_OVERRIDE_NIGHTLY_6_0: "swift test ${{ inputs.linux_nightly_6_0_arguments_override }}"
91+
COMMAND_OVERRIDE_NIGHTLY_MAIN: "swift test ${{ inputs.linux_nightly_main_arguments_override }}"
92+
REDIS_URL: redis
93+
run: |
94+
apt-get -qq update && apt-get -qq -y install curl
95+
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash
96+
container:
97+
image: ${{ matrix.swift.image }}
98+
services:
99+
redis:
100+
image: redis:7

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ docker run -d -p 6379:6379 --name redis redis:5
5151

5252
Otherwise, install Redis directly on your machine from [Redis.io](https://redis.io/download).
5353

54+
### Run CI checks locally
55+
56+
You can run the GitHub Actions workflows locally using
57+
[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).
58+
5459
### Submitting a Pull Request
5560

5661
A great PR that is likely to be merged quickly is:

docker/Dockerfile

-28
This file was deleted.

docker/docker-compose.2004.56.yaml

-20
This file was deleted.

docker/docker-compose.2204.510.yaml

-20
This file was deleted.

docker/docker-compose.2204.57.yaml

-20
This file was deleted.

docker/docker-compose.2204.58.yaml

-21
This file was deleted.

docker/docker-compose.2204.59.yaml

-21
This file was deleted.

docker/docker-compose.2204.main.yaml

-20
This file was deleted.

docker/docker-compose.yaml

-51
This file was deleted.

0 commit comments

Comments
 (0)