diff --git a/.swift-version b/.swift-version index 2df33d7..760606e 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.6 +5.7 diff --git a/.travis.yml b/.travis.yml index 7de7d40..cf852d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,37 +2,36 @@ language: generic before_install: - export SWIFT_VERSION=$(<.swift-version) + - export MONGODB_VERSION=ubuntu2204-7.0.2 + - export MONGOSH_VERSION=2.0.2-linux-x64 - export SWIFT_DOCKER_IMAGE=swift:${SWIFT_VERSION}-bionic - - export MONGO_DOCKER_IMAGE=mongo:5.0 - - export MONGO_BREW_VERSION=mongodb-community@5.0 + - export MONGO_BREW_VERSION=mongodb-community@6.0 stages: -- name: test - if: tag IS NOT present + - name: test + if: tag IS NOT present jobs: include: - - stage: test name: Unit Tests os: linux - dist: bionic + dist: jammy services: docker script: + - ./Scripts/mongo_setup.sh & - docker pull ${SWIFT_DOCKER_IMAGE} - - docker pull ${MONGO_DOCKER_IMAGE} - - docker run -d -p 27001:27001 -p 27002:27002 -p 27003:27003 -v $(pwd)/Scripts:/scripts:ro --entrypoint /scripts/docker_entrypoint.sh --restart=always ${MONGO_DOCKER_IMAGE} - args="apt-get update - && apt-get -y install cmake libssl-dev libsasl2-dev - && swift build --enable-test-discovery -c debug - && swift build --enable-test-discovery -c release - && swift test --enable-test-discovery -c debug --sanitize=thread"; + && apt-get -y install cmake libssl-dev libsasl2-dev + && swift build -c debug + && swift build -c release + && swift test -c debug --sanitize=thread"; - docker run --rm --net=host -v $(pwd):/app --workdir /app ${SWIFT_DOCKER_IMAGE} bash -c "${args}" - stage: test name: Unit Tests os: osx - osx_image: xcode13.4 + osx_image: xcode14.2 before_script: - gem install bundler - bundle install diff --git a/Package.swift b/Package.swift index 75bee6a..b4554da 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.6 +// swift-tools-version:5.7 // // Package.swift @@ -19,7 +19,7 @@ let package = Package( .library(name: "FluentMongo", targets: ["FluentMongo"]) ], dependencies: [ - .package(url: "https://github.com/vapor/fluent-kit.git", .upToNextMajor(from: "1.33.1")), + .package(url: "https://github.com/vapor/fluent-kit.git", .upToNextMinor(from: "1.36.1")), .package(url: "https://github.com/mongodb/mongo-swift-driver.git", .upToNextMajor(from: "1.3.1")) ], targets: [ diff --git a/README.md b/README.md index 52fbdff..cb6f48c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # vapor-fluent-mongo -![Swift](https://img.shields.io/badge/swift-5.6-orange.svg) +![Swift](https://img.shields.io/badge/swift-5.7-orange.svg) [![Build Status](https://travis-ci.com/asensei/vapor-fluent-mongo.svg?token=eSrCssnzja3G3GciyhUB&branch=master)](https://travis-ci.com/asensei/vapor-fluent-mongo) Mongo driver for Fluent `5.x`. diff --git a/Scripts/docker_entrypoint.sh b/Scripts/docker_entrypoint.sh deleted file mode 100755 index 3221d10..0000000 --- a/Scripts/docker_entrypoint.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -set -e - -REPLICA_SET_NAME=${REPLICA_SET_NAME:=rs0} - -function waitForMongo { - port=$1 - n=0 - until [ $n -ge 20 ] - do - mongo admin --quiet --port $port --eval "db" && break - n=$[$n+1] - sleep 2 - done -} - -if [ ! "$(ls -A /data/db1)" ]; then - mkdir /data/db1 - mkdir /data/db2 - mkdir /data/db3 -fi - -echo "STARTING CLUSTER" - -mongod --port 27003 --dbpath /data/db3 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & -DB3_PID=$! -mongod --port 27002 --dbpath /data/db2 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & -DB2_PID=$! -mongod --port 27001 --dbpath /data/db1 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & -DB1_PID=$! - -waitForMongo 27001 -waitForMongo 27002 -waitForMongo 27003 - -echo "CONFIGURING REPLICA SET" -CONFIG="{ _id: '$REPLICA_SET_NAME', members: [{_id: 0, host: 'localhost:27001', priority: 2 }, { _id: 1, host: 'localhost:27002' }, { _id: 2, host: 'localhost:27003' } ]}" -mongo admin --port 27001 --eval "db.runCommand({ replSetInitiate: $CONFIG })" - -waitForMongo 27002 -waitForMongo 27003 - -mongo admin --port 27001 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" -mongo admin --port 27002 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" -mongo admin --port 27003 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" - -echo "REPLICA SET ONLINE" - -trap 'echo "KILLING"; kill $DB1_PID $DB2_PID $DB3_PID; wait $DB1_PID; wait $DB2_PID; wait $DB3_PID' SIGINT SIGTERM EXIT - -wait $DB1_PID -wait $DB2_PID -wait $DB3_PID \ No newline at end of file diff --git a/Scripts/mongo_setup.sh b/Scripts/mongo_setup.sh new file mode 100755 index 0000000..4aa978c --- /dev/null +++ b/Scripts/mongo_setup.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +echo "DOWNLOADING MONGODB" +wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB_VERSION}.tgz + +echo "EXTRACTING MONGODB" +tar xfz mongodb-linux-x86_64-${MONGODB_VERSION}.tgz + +echo "INSTALLING MONGODB" +export PATH=`pwd`/mongodb-linux-x86_64-${MONGODB_VERSION}/bin:$PATH +mongod --version + +echo "DOWNLOADING MONGOSH" +wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH_VERSION}.tgz + +echo "EXTRACTING MONGOSH" +tar xfz mongosh-${MONGOSH_VERSION}.tgz + +echo "INSTALLING MONGOSH" +chmod +x mongosh-${MONGOSH_VERSION}/bin/mongosh +export PATH=`pwd`/mongosh-${MONGOSH_VERSION}/bin:$PATH +mongosh --version + +REPLICA_SET_NAME=${REPLICA_SET_NAME:=rs0} + +function waitForMongo { + port=$1 + n=0 + until [ $n -ge 20 ] + do + mongosh admin --quiet --port $port --eval "db" && break + n=$[$n+1] + sleep 2 + done +} + +echo "STARTING CLUSTER" + +mkdir -p data/db + +mongod --port 27017 --dbpath=data/db --replSet $REPLICA_SET_NAME --bind_ip_all --quiet & +DB1_PID=$! + +waitForMongo 27017 + +echo "CONFIGURING REPLICA SET" +CONFIG="{ _id: '$REPLICA_SET_NAME', members: [{_id: 0, host: 'localhost:27017', priority: 2 } ]}" +mongosh admin --port 27017 --eval "db.runCommand({ replSetInitiate: $CONFIG })" + +mongosh admin --port 27017 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" + +echo "REPLICA SET ONLINE" + +trap 'echo "KILLING"; kill $DB1_PID; wait $DB1_PID; ' SIGINT SIGTERM EXIT + +wait $DB1_PID diff --git a/Tests/FluentMongoTests/FluentBenchmarkTests.swift b/Tests/FluentMongoTests/FluentBenchmarkTests.swift index 485f8e5..c26dc51 100644 --- a/Tests/FluentMongoTests/FluentBenchmarkTests.swift +++ b/Tests/FluentMongoTests/FluentBenchmarkTests.swift @@ -95,7 +95,7 @@ func env(_ name: String) -> String? { let mongoConnectionString: String = { #if os(Linux) - return "mongodb://localhost:27001,localhost:27002,localhost:27003" + return "mongodb://localhost:27017" #else return "mongodb://localhost:27017"