Skip to content

Commit bf3dfaa

Browse files
committed
Add Linux CI
1 parent d61d745 commit bf3dfaa

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.github/workflows/test.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: test
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
7+
push: { branches: [main] }
8+
9+
env:
10+
LOG_LEVEL: info
11+
SWIFT_DETERMINISTIC_HASHING: 1
12+
jobs:
13+
test:
14+
services:
15+
ssh-server:
16+
image: lscr.io/linuxserver/openssh-server:latest
17+
ports:
18+
- 2222:2222
19+
env:
20+
USER_PASSWORD: hunter2
21+
USER_NAME: citadel
22+
runs-on: ubuntu-latest
23+
container:
24+
image: swift:5.10-jammy
25+
env:
26+
SWIFT_DETERMINISTIC_HASHING: 1
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Resolve
30+
run: swift package resolve
31+
- name: Run tests
32+
run: swift test
33+
env:
34+
SWIFT_DETERMINISTIC_HASHING: 1
35+
SSH_HOST: ssh-server
36+
SSH_POST: 2222
37+
SSH_USER: citadel
38+
SSH_PASSWORD: hunter2

Tests/CitadelTests/Citadel2Tests.swift

+24
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,28 @@ final class Citadel2Tests: XCTestCase {
254254
i += 1
255255
}
256256
}
257+
258+
func testConnectToOpenSSHServer() async throws {
259+
guard
260+
let host = ProcessInfo.processInfo.environment["SSH_HOST"],
261+
let _port = ProcessInfo.processInfo.environment["SSH_PORT"],
262+
let port = Int(_port),
263+
let username = ProcessInfo.processInfo.environment["SSH_USERNAME"],
264+
let password = ProcessInfo.processInfo.environment["SSH_PASSWORD"]
265+
else {
266+
throw XCTSkip()
267+
}
268+
269+
let client = try await SSHClient.connect(
270+
host: host,
271+
port: port,
272+
authenticationMethod: .passwordBased(username: username, password: password),
273+
hostKeyValidator: .acceptAnything(),
274+
reconnect: .never
275+
)
276+
277+
_ = try await client.executeCommand("ls")
278+
279+
try await client.close()
280+
}
257281
}

0 commit comments

Comments
 (0)