You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Guides/Development.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Swift Driver Development Guide
2
2
3
3
## Index
4
-
*[Things to Install](#things-to-install)
4
+
*[Things to Install](#things-to-install)
5
5
*[The Code](#the-code)
6
6
*[Building](#building)
7
7
*[Running Tests](#running-tests)
@@ -15,15 +15,17 @@
15
15
*[swiftenv](https://swiftenv.fuller.li/en/latest/installation.html): a command-line tool that allows easy installation of and switching between versions of Swift.
16
16
*[Jazzy](https://github.com/realm/jazzy#installation): the tool we use to generate documentation.
17
17
*[SwiftFormat](https://github.com/nicklockwood/SwiftFormat#how-do-i-install-it): the Swift formatter we use.
18
-
*[SwiftLint](https://github.com/realm/SwiftLint#using-homebrew): the Swift linter we use.
18
+
*[SwiftLint](https://github.com/realm/SwiftLint#using-homebrew): the Swift linter we use.
19
19
*[Sourcery](https://github.com/krzysztofzablocki/Sourcery/#installation): the tool we use for code generation.
20
20
21
21
## The code
22
22
You should clone this repository, as well as the [MongoDB Driver specifications](https://github.com/mongodb/specifications).
23
23
24
-
## Building
24
+
## Building
25
25
### From the Command line
26
-
Run `swift build` or simply `make` in the project's root directory.
26
+
Run `swift build` or simply `make` in the project's root directory.
27
+
28
+
If you add symbols you may need to run `make exports` which will generate [Sources/MongoSwiftSync/Exports.swift](Sources/MongoSwiftSync/Exports.swift). This makes symbols declared in `MongoSwift` available to importers of `MongoSwiftSync`.
27
29
28
30
### In Xcode
29
31
We do not provide or maintain an already-generated `.xcodeproj` in our repository. Instead, you must generate it locally.
@@ -33,21 +35,21 @@ We do not provide or maintain an already-generated `.xcodeproj` in our repositor
33
35
2. Run `make project`
34
36
3. You're ready to go! Open `MongoSwift.xcodeproj` and build and test as normal.
35
37
36
-
Why is this necessary? The project requires a customized "copy resources" build phase to include various test `.json` files. By default, this phase is not included when you run `swift package generate-xcodeproj`. So `make project` first generates the project, and then uses `xcodeproj` to manually add the files to the appropriate targets (see `add_json_files.rb`).
38
+
Why is this necessary? The project requires a customized "copy resources" build phase to include various test `.json` files. By default, this phase is not included when you run `swift package generate-xcodeproj`. So `make project` first generates the project, and then uses `xcodeproj` to manually add the files to the appropriate targets (see `add_json_files.rb`).
37
39
38
40
## Running Tests
39
41
**NOTE**: Several of the tests require a mongod instance to be running on the default host/port, `localhost:27017`. You can start this by running `mongod --setParameter enableTestCommands=1`. The `enableTestCommands` parameter is required to use some test-only commands built into MongoDB that we utilize in our tests, e.g. `failCommand`.
40
42
41
43
You can run tests from Xcode as usual. If you prefer to test from the command line, keep reading.
42
44
43
-
### From the Command Line
45
+
### From the Command Line
44
46
We recommend installing the ruby gem `xcpretty` and running tests by executing `make test-pretty`, as this provides output in a much more readable format. (Works on MacOS only.)
45
47
46
48
Alternatively, you can just run the tests with `swift test`, or `make test`.
47
49
48
50
To filter tests by regular expression:
49
-
- If you are using `swift test`, provide the `--filter` argument: for example, `swift test --filter=MongoClientTests`.
50
-
- If you are using `make test` or `make test-pretty`, provide the `FILTER` environment variable: for example, `make test-pretty FILTER=MongoCollectionTests`.
51
+
- If you are using `swift test`, provide the `--filter` argument: for example, `swift test --filter=MongoClientTests`.
52
+
- If you are using `make test` or `make test-pretty`, provide the `FILTER` environment variable: for example, `make test-pretty FILTER=MongoCollectionTests`.
This will require you to manually provide the path to the compiled test binary (e.g. `.build/x86_64-unknown-linux/debug/MongoSwiftPackageTests.xctest`).
62
64
63
65
## Writing and Generating Documentation
64
-
We document new code as we write it. We use C-style documentation blocks (`/** ... */`) for documentation longer than 3 lines, and triple-slash (`///`) for shorter documentation.
66
+
We document new code as we write it. We use C-style documentation blocks (`/** ... */`) for documentation longer than 3 lines, and triple-slash (`///`) for shorter documentation.
65
67
Comments that are _not_ documentation should use two slashes (`//`).
66
68
67
-
Documentation comments should generally be complete sentences and should end with periods.
69
+
Documentation comments should generally be complete sentences and should end with periods.
68
70
69
71
Our documentation site is automatically generated from the source code using [Jazzy](https://github.com/realm/jazzy#installation). We regenerate it via our release script each time we release a new version of the driver.
70
72
@@ -93,7 +95,7 @@ If you have a setup for developing the driver in an editor other than the ones l
93
95
* Please read the [NOTICE](https://github.com/Utagai/swift.vim#notice) for proper credits.
94
96
95
97
## Workflow
96
-
1. Create a feature branch, named by the corresponding JIRA ticket if exists, along with a short descriptor of the work: for example, `SWIFT-30/writeconcern`.
98
+
1. Create a feature branch, named by the corresponding JIRA ticket if exists, along with a short descriptor of the work: for example, `SWIFT-30/writeconcern`.
97
99
1. Do your work on the branch.
98
100
1. If you add, remove, or rename any tests, make sure to update `LinuxMain.swift` accordingly. If you are on MacOS, you can do that by running `make linuxmain`.
99
101
1. Ensure your code passes both the linter and the formatter.
@@ -103,8 +105,8 @@ If you have a setup for developing the driver in an editor other than the ones l
103
105
1. Open a pull request on the repository. Make sure you have rebased your branch onto the latest commits on `master`.
104
106
1. Go through code review to get the team's approval on your changes. (See the next section on [Code Review](#code-review) for more details on this process.) Once you get the required approvals and your code passes all tests:
105
107
1. Rebase on master again if needed.
106
-
1. Rerun tests.
107
-
1. Squash all commits into a single, descriptive commit method, formatted as: `TICKET-NUMBER: Description of changes`. For example, `SWIFT-30: Implement WriteConcern type`.
108
+
1. Rerun tests.
109
+
1. Squash all commits into a single, descriptive commit method, formatted as: `TICKET-NUMBER: Description of changes`. For example, `SWIFT-30: Implement WriteConcern type`.
108
110
1. Merge it, or if you don't have permissions, ask someone to merge it for you.
0 commit comments