Skip to content

Commit 90642df

Browse files
authored
tests: Test main daily (#42)
Motivation ---------- It is very important that the example projects work when a new user tries them, but upstream changes might cause them to stop working even if nothing changes in this project. This PR adds a job to run the tests daily to identify such problems as early as possible. Modifications ------------- * Extract the end to end tests into a reusable workflow * Add a new action to run the tests daily, and for every push to main Result ------ Tests will be run periodically. Test Plan --------- The existing tests continue to pass - this PR will run them more often.
1 parent 13702bc commit 90642df

File tree

3 files changed

+109
-46
lines changed

3 files changed

+109
-46
lines changed

.github/workflows/endtoend_tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: End to end tests
2+
3+
on:
4+
workflow_call:
5+
# inputs:
6+
# example:
7+
# required: true
8+
# type: string
9+
10+
jobs:
11+
endtoend-tests:
12+
name: End to end tests
13+
runs-on: ubuntu-latest
14+
services:
15+
registry:
16+
image: registry:2
17+
ports:
18+
- 5000:5000
19+
strategy:
20+
matrix:
21+
example:
22+
- Examples/HelloWorldVapor
23+
- Examples/HelloWorldHummingbird
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
persist-credentials: false
29+
30+
- name: Mark the workspace as safe
31+
# https://github.com/actions/checkout/issues/766
32+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
33+
34+
- name: Install the static SDK
35+
run: |
36+
swift sdk install \
37+
https://download.swift.org/swift-6.0.2-release/static-sdk/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz \
38+
--checksum aa5515476a403797223fc2aad4ca0c3bf83995d5427fb297cab1d93c68cee075
39+
40+
- name: Build the example
41+
run: |
42+
sed -i'.bak' -e "/swift-container-plugin/ s@(url:.*),@(path: \"$PWD\"),@" ${{ matrix.example }}/Package.swift # Use plugin from this checkout
43+
cat ${{ matrix.example }}/Package.swift
44+
swift package \
45+
--package-path ${{ matrix.example }} \
46+
--swift-sdk x86_64-swift-linux-musl \
47+
--allow-network-connections all \
48+
build-container-image \
49+
--repository localhost:5000/example \
50+
--from scratch
51+
52+
- name: Run the example
53+
run: |
54+
docker run -d --platform linux/amd64 -p 8080:8080 localhost:5000/example
55+
56+
- name: Check that the service is running
57+
run: |
58+
curl -v localhost:8080 | grep "Hello World"

.github/workflows/main.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
schedule:
8+
- cron: '12 3 * * *'
9+
10+
jobs:
11+
unit-tests:
12+
name: Unit tests
13+
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
14+
with:
15+
linux_5_9_enabled: false
16+
linux_5_10_enabled: false
17+
linux_6_0_arguments_override: "--skip SmokeTests"
18+
linux_nightly_6_0_arguments_override: "--skip SmokeTests"
19+
linux_nightly_main_arguments_override: "--skip SmokeTests"
20+
21+
integration-tests:
22+
name: Integration tests
23+
runs-on: ubuntu-latest
24+
services:
25+
registry:
26+
image: registry:2
27+
ports:
28+
- 5000:5000
29+
container:
30+
image: swift:6.0-noble
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
36+
37+
- name: Mark the workspace as safe
38+
# https://github.com/actions/checkout/issues/766
39+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
40+
41+
- name: Run test job
42+
env:
43+
REGISTRY_HOST: registry
44+
REGISTRY_PORT: 5000
45+
run: |
46+
swift test
47+
48+
endtoend-tests:
49+
name: End to end tests
50+
uses: ./.github/workflows/endtoend_tests.yml

.github/workflows/pull_request.yml

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -53,52 +53,7 @@ jobs:
5353
5454
endtoend-tests:
5555
name: End to end tests
56-
runs-on: ubuntu-latest
57-
services:
58-
registry:
59-
image: registry:2
60-
ports:
61-
- 5000:5000
62-
strategy:
63-
matrix:
64-
example:
65-
- Examples/HelloWorldVapor
66-
- Examples/HelloWorldHummingbird
67-
steps:
68-
- name: Checkout repository
69-
uses: actions/checkout@v4
70-
with:
71-
persist-credentials: false
72-
73-
- name: Mark the workspace as safe
74-
# https://github.com/actions/checkout/issues/766
75-
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
76-
77-
- name: Install the static SDK
78-
run: |
79-
swift sdk install \
80-
https://download.swift.org/swift-6.0.2-release/static-sdk/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz \
81-
--checksum aa5515476a403797223fc2aad4ca0c3bf83995d5427fb297cab1d93c68cee075
82-
83-
- name: Build the example
84-
run: |
85-
sed -i'.bak' -e "/swift-container-plugin/ s@(url:.*),@(path: \"$PWD\"),@" ${{ matrix.example }}/Package.swift # Use plugin from this checkout
86-
cat ${{ matrix.example }}/Package.swift
87-
swift package \
88-
--package-path ${{ matrix.example }} \
89-
--swift-sdk x86_64-swift-linux-musl \
90-
--allow-network-connections all \
91-
build-container-image \
92-
--repository localhost:5000/example \
93-
--from scratch
94-
95-
- name: Run the example
96-
run: |
97-
docker run -d --platform linux/amd64 -p 8080:8080 localhost:5000/example
98-
99-
- name: Check that the service is running
100-
run: |
101-
curl -v localhost:8080 | grep "Hello World"
56+
uses: ./.github/workflows/endtoend_tests.yml
10257

10358
swift-6-language-mode:
10459
name: Swift 6 Language Mode

0 commit comments

Comments
 (0)