Skip to content

Commit

Permalink
Configure Test Action
Browse files Browse the repository at this point in the history
Just Build Phase for Now

Fix Broken Test

Restore Test Phase

Debug Xcode Select Version

Restore Remaining Workflow

Update libxmtp-swift version to 0.4.2-beta4

Update xmtplib Docker scripts

Update macOS Version

Run against latest Xcode

Colima Debug

Fix broken test

Increased Timeout for Waiters

Cleanup Workflow and Compose

Additional workflow cleanup
  • Loading branch information
zombieobject committed Feb 27, 2024
1 parent 880ec58 commit d52766b
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 18 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: iOS Tests

# temporary for manual trigger
#on:
# workflow_dispatch:

on:
push:
# branches:
# - main
# pull_request:

env:
GPR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPR_USER: ${{ secrets.GITHUB_ACTOR }}

jobs:

ios-tests:
name: iOS Tests
runs-on: macos-13

steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'

- name: Checkout project sources
uses: actions/checkout@v3

- name: Install docker
run: brew install docker docker-compose colima

- name: Start colima
run: colima start

- name: Start Docker containers
run: dev/up

# - name: Build
# run: swift build -v

- name: Run tests
run: swift test --vv

- name: Stop local test server
run: docker-compose -p xmtp-ios -f dev/local/docker-compose.yml down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/xmtp/libxmtp-swift",
"state" : {
"revision" : "de859c86a5854bdc2cfd54e8f98b6088a38a2f3c",
"version" : "0.4.2-beta2"
"revision" : "28ee27a4ded8b996a74850e366247e9fe51d782a",
"version" : "0.4.2-beta4"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
.package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"),
.package(url: "https://github.com/bufbuild/connect-swift", exact: "0.3.0"),
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"),
.package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.4.2-beta3"),
.package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.4.2-beta4"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
16 changes: 13 additions & 3 deletions Tests/XMTPTests/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,19 @@ class ClientTests: XCTestCase {
}

func testPassingMLSEncryptionKeyAndDatabasePath() async throws {
try TestConfig.skipIfNotRunningLocalNodeTests()

let bo = try PrivateKey.generate()
let key = try Crypto.secureRandomBytes(count: 32)
let dbPath = URL.documentsDirectory.appendingPathComponent("xmtp-\(bo.walletAddress).db3").path
let documentsURL = try
FileManager.default.url(
for: .documentDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: false
)

let dbPath = documentsURL.appendingPathComponent("xmtp-\(bo.walletAddress).db3").path

let client = try await Client.create(
account: bo,
Expand Down Expand Up @@ -240,7 +250,7 @@ class ClientTests: XCTestCase {
let opts = ClientOptions(api: ClientOptions.Api(env: .local, isSecure: false), preEnableIdentityCallback: preEnableIdentityCallback )
do {
_ = try await Client.create(account: fakeWallet, options: opts)
await XCTWaiter().fulfillment(of: [expectation], timeout: 5)
await XCTWaiter().fulfillment(of: [expectation], timeout: 30)
} catch {
XCTFail("Error: \(error)")
}
Expand All @@ -258,7 +268,7 @@ class ClientTests: XCTestCase {
let opts = ClientOptions(api: ClientOptions.Api(env: .local, isSecure: false), preCreateIdentityCallback: preCreateIdentityCallback )
do {
_ = try await Client.create(account: fakeWallet, options: opts)
await XCTWaiter().fulfillment(of: [expectation], timeout: 5)
await XCTWaiter().fulfillment(of: [expectation], timeout: 30)
} catch {
XCTFail("Error: \(error)")
}
Expand Down
4 changes: 4 additions & 0 deletions dev/local/compose
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -eou pipefail

docker-compose -f dev/local/docker-compose.yml -p "xmtp-ios" "$@"
29 changes: 18 additions & 11 deletions dev/local/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
version: "3.8"
services:
wakunode:
image: xmtp/node-go
node:
image: xmtp/node-go:latest
platform: linux/amd64
environment:
- GOWAKU-NODEKEY=8a30dcb604b0b53627a5adc054dbf434b446628d4bd1eccc681d223f0550ce67
command:
- --store.enable
- --store.db-connection-string=postgres://postgres:xmtp@db:5432/postgres?sslmode=disable
- --store.reader-db-connection-string=postgres://postgres:xmtp@db:5432/postgres?sslmode=disable
- --mls-store.db-connection-string=postgres://postgres:xmtp@mlsdb:5432/postgres?sslmode=disable
- --mls-validation.grpc-address=validation:50051
- --api.enable-mls
- --wait-for-db=30s
- --api.authn.enable
ports:
- 9001:9001
- 5555:5555 # http message API
- 5556:5556 # grpc message API
- 5555:5555
- 5556:5556
depends_on:
- db
healthcheck:
test: [ "CMD", "lsof", "-i", ":5556" ]
interval: 3s
timeout: 10s
retries: 5

validation:
image: ghcr.io/xmtp/mls-validation-service:main
platform: linux/amd64

db:
image: postgres:13
environment:
POSTGRES_PASSWORD: xmtp

mlsdb:
image: postgres:13
environment:
POSTGRES_PASSWORD: xmtp
1 change: 1 addition & 0 deletions dev/test/Dockerfile → dev/local/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ FROM node:19-alpine

WORKDIR /code
ADD script.js script.js
RUN apk update && apk add git
RUN npm install @xmtp/xmtp-js ethers
CMD ["node", "script.js"]
2 changes: 1 addition & 1 deletion dev/test/script.js → dev/local/test/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ async function checkAll() {
}
}

checkAll().then(() => console.log("Done"));
checkAll().then(() => console.log("Done"));
6 changes: 6 additions & 0 deletions dev/local/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -eou pipefail
script_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

"${script_dir}"/compose pull
"${script_dir}"/compose up -d --build
18 changes: 18 additions & 0 deletions dev/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -eou pipefail

if [[ "${OSTYPE}" == "darwin"* ]]; then
if ! which buf &>/dev/null; then brew install buf; fi
if ! which shellcheck &>/dev/null; then brew install shellcheck; fi
if ! which markdownlint &>/dev/null; then brew install markdownlint-cli; fi
if ! java -version &>/dev/null; then
brew install java
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/
fi
if ! kotlinc -version &>/dev/null; then brew install kotlin; fi
fi

rustup update

dev/local/up

0 comments on commit d52766b

Please sign in to comment.