Skip to content

Commit 035315f

Browse files
authored
ci: Enable smoke tests (#13)
### Motivation The integration tests (`SmokeTests`) are not currently run on PRs because they require an instance of the container registry to be available. ### Modifications Add a custom job which runs `registry` as a service container. ### Result Integration tests will be run for every pull request. The integration test job also runs the tests run by the unit tests job, but the duplication is not very costly. ### Test Plan All tests continue to pass.
1 parent a393d2b commit 035315f

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

.github/workflows/pull_request.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,35 @@ jobs:
2121
linux_5_8_enabled: false
2222
linux_5_9_enabled: false
2323
linux_5_10_enabled: false
24-
linux_nightly_6_0_arguments_override: "--filter 'AuthTests|ReferenceTests'"
25-
linux_nightly_main_arguments_override: "--filter 'AuthTests|ReferenceTests'"
24+
linux_nightly_6_0_arguments_override: "--skip SmokeTests"
25+
linux_nightly_main_arguments_override: "--skip SmokeTests"
26+
27+
integration-tests:
28+
name: Integration tests
29+
runs-on: ubuntu-latest
30+
services:
31+
registry:
32+
image: registry:2
33+
ports:
34+
- 5000:5000
35+
container:
36+
image: swift:6.0-noble
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
with:
41+
persist-credentials: false
42+
43+
- name: Mark the workspace as safe
44+
# https://github.com/actions/checkout/issues/766
45+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
46+
47+
- name: Run test job
48+
env:
49+
REGISTRY_HOST: registry
50+
REGISTRY_PORT: 5000
51+
run: |
52+
swift test
2653
2754
swift-6-language-mode:
2855
name: Swift 6 Language Mode

NOTICE.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ function from SwiftNIO Extras.
6767
This product contains samples of how to use Swift Container Plugin with the
6868
following other projects:
6969

70+
* Distribution Registry
71+
* LICENSE (Apache License 2.0):
72+
* https://www.apache.org/licenses/LICENSE-2.0
73+
* HOMEPAGE:
74+
* https://github.com/distribution/distribution
75+
7076
* Vapor
7177
* LICENSE (MIT License):
7278
* https://mit-license.org

scripts/run-integration-tests.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the SwiftContainerPlugin open source project
5+
##
6+
## Copyright (c) 2024 Apple Inc. and the SwiftContainerPlugin project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
## See CONTRIBUTORS.txt for the list of SwiftContainerPlugin project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
17+
log() { printf -- "** %s\n" "$*" >&2; }
18+
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
19+
fatal() { error "$@"; exit 1; }
20+
21+
if [[ -n ${TOOLCHAINS+x} ]] ; then
22+
fatal "Please unset the TOOLCHAINS environment variable. The OSS Swift toolchain cannot run these tests because it does not include XCTest.framework."
23+
fi
24+
25+
set -euo pipefail
26+
27+
RUNTIME=${RUNTIME-"docker"}
28+
29+
# Start a registry on an ephemeral port
30+
REGISTRY_ID=$($RUNTIME run -d --rm -p 127.0.0.1::5000 registry:2)
31+
export REGISTRY_HOST="localhost"
32+
REGISTRY_PORT=$($RUNTIME port "$REGISTRY_ID" 5000/tcp | sed -E 's/^.+:([[:digit:]]+)$/\1/')
33+
export REGISTRY_PORT
34+
log "Registry $REGISTRY_ID listening on $REGISTRY_HOST:$REGISTRY_PORT"
35+
36+
# Delete the registry after running the tests, regardless of the outcome
37+
cleanup() {
38+
log "Deleting registry $REGISTRY_ID"
39+
$RUNTIME rm -f "$REGISTRY_ID"
40+
}
41+
trap cleanup EXIT
42+
43+
log "Running smoke tests"
44+
swift test --filter 'SmokeTests'

0 commit comments

Comments
 (0)