Skip to content

Commit d75533d

Browse files
committed
add contributor bootstrap + doc
1 parent 9837294 commit d75533d

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
.package(url: "https://github.com/apple/swift-nio.git", from: "1.0.0"),
2424
],
2525
targets: [
26-
.target(name: "PostgreSQL", dependencies: ["Async", "Bits", "Crypto", "DatabaseKit", "NIO", "Service"]),
27-
.testTarget(name: "PostgreSQLTests", dependencies: ["PostgreSQL"]),
26+
.target(name: "PostgreSQL", dependencies: ["Async", "Bits", "Core", "Crypto", "DatabaseKit", "NIO", "Service"]),
27+
.testTarget(name: "PostgreSQLTests", dependencies: ["Core", "PostgreSQL"]),
2828
]
2929
)

Tests/PostgreSQLTests/PostgreSQLConnectionTests.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Async
22
import Foundation
33
import XCTest
44
import PostgreSQL
5+
import Core
56

67
class PostgreSQLConnectionTests: XCTestCase {
78
func testVersion() throws {
@@ -356,11 +357,17 @@ class PostgreSQLConnectionTests: XCTestCase {
356357
extension PostgreSQLConnection {
357358
/// Creates a test event loop and psql client.
358359
static func makeTest() throws -> PostgreSQLConnection {
360+
let hostname: String
361+
#if TEST_DOCKER_HOSTNAME
362+
hostname = try Process.execute("docker-machine", "ip")
363+
#else
364+
hostname = "localhost"
365+
#endif
359366
let group = MultiThreadedEventLoopGroup(numThreads: 1)
360-
let client = try PostgreSQLConnection.connect(on: group) { error in
367+
let client = try PostgreSQLConnection.connect(hostname: hostname, on: group) { error in
361368
XCTFail("\(error)")
362369
}.wait()
363-
_ = try client.authenticate(username: "vapor_username", database: "vapor_database", password: "vapor_password").wait()
370+
_ = try client.authenticate(username: "vapor_username", database: "vapor_database", password: nil).wait()
364371
return client
365372
}
366373
}

contribute_bootstrap.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
echo "💧 starting docker..."
2+
docker-machine start default
3+
4+
echo "💧 exporting docker machine environment..."
5+
eval $(docker-machine env default)
6+
7+
echo "💧 cleaning previous vapor-psql dev db..."
8+
docker stop vapor-psql
9+
docker rm vapor-psql
10+
11+
echo "💧 creating vapor-psql dev db..."
12+
docker run --name vapor-psql -e POSTGRES_USER=vapor_username -e POSTGRES_DB=vapor_database -p 5432:5432 -d postgres:latest
13+
14+
echo "💧 generating xcode proj..."
15+
swift package -Xswiftc -DTEST_DOCKER_HOSTNAME generate-xcodeproj
16+
17+
echo "💧 opening xcode..."
18+
open *.xcodeproj

contributing.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Contributing to PostgreSQL
2+
3+
👋 Welcome to the Vapor team!
4+
5+
## Bootstrap
6+
7+
To prepare your computer for developing this package, you can run the bootstrap script.
8+
9+
```sh
10+
./contribute_boostrap.sh
11+
```
12+
13+
This script will start up a PostgreSQL docker container to test against. It will also generate and open Xcode for you.
14+
15+
Be careful to observe the script's output, it may have errors or ask you to do additional steps manually.
16+
17+
## Testing
18+
19+
Once in Xcode, select the `PostgreSQL-Package` scheme and use `CMD+U` to run the tests.
20+
21+
When adding new tests (please do 😁), don't forget to add the method name to the `allTests` array.
22+
If you add a new `XCTestCase` subclass, make sure to add it to the `Tests/LinuxMain.swift` file.
23+
24+
If you are fixing a single GitHub issue in particular, you can add a test named `testGH<issue number>` to ensure
25+
that your fix is working. This will also help prevent regression.
26+
27+
## SemVer
28+
29+
Vapor follows [SemVer](https://semver.org). This means that any changes to the source code that can cause
30+
existing code to stop compiling _must_ wait until the next major version to be included.
31+
32+
Code that is only additive and will not break any existing code can be included in the next minor release.
33+
34+
----------
35+
36+
Join us on Slack if you have any questions: [http://vapor.team](http://vapor.team).
37+
38+
&mdash; Thanks! 🙌

0 commit comments

Comments
 (0)