Skip to content

Commit cde0dce

Browse files
authored
SWIFT-1437: Update Development Guide and Linting (#719)
1 parent bce55b4 commit cde0dce

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Guides/Development.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ Run `swift build` or simply `make` in the project's root directory.
3131
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`.
3232

3333
### In Xcode
34-
We do not provide or maintain an already-generated `.xcodeproj` in our repository. Instead, you must generate it locally.
35-
36-
**To generate the `.xcodeproj` file**:
37-
1. Install the Ruby gem `xcodeproj` with `gem install xcodeproj` (you may need to `sudo`)
38-
2. Run `make project`
39-
3. You're ready to go! Open `MongoSwift.xcodeproj` and build and test as normal.
40-
41-
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`).
34+
From the driver root directory, you can run `xed .` to open the project in xcode and be able to build and run there.
4235

4336
## Running Tests
4437
**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`.
@@ -76,12 +69,14 @@ Our documentation site is automatically generated from the source code using [Ja
7669
If you'd like to preview how new documentation you've written will look when published, you can regenerate it by running `./etc/generate-docs.sh` and then inspecting the generated HTML files in `/docs`.
7770

7871
## Linting and Style
79-
We use [SwiftLint](https://github.com/realm/SwiftLint#using-homebrew) for linting. You can see our configuration in the `.swiftlint.yml` file in the project's root directory. Run `swiftlint` in the root directory to lint all of our files. Running `swiftlint autocorrect` will correct some types of violations.
72+
We use [SwiftLint](https://github.com/realm/SwiftLint#using-homebrew) for linting. You can see our configuration in the `.swiftlint.yml` file in the project's root directory. Run `swiftlint` in the root directory to lint all of our files. Running `swiftlint --fix` will correct some types of violations.
8073

8174
We use [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) for formatting the code. You can see our configuration in the `.swiftformat` file in the project's root directory. Our linter config contains a superset of the rules that our formatter does, so some manual tweaking may be necessary to satisfy both once the formatter is run (e.g. line length enforcement). Most of the time, the formatter should put the code into a format that passes the linter. You can run the formatter on all of the files by running `swiftformat .` from the root directory.
8275

8376
To pass all the formatting stages of our testing matrix, both `swiftlint --strict` and `swiftformat --lint .` must finish successfully.
8477

78+
`make lint-and-format` runs `swiftlint --fix`, `swiftlint --strict` and `swiftformat --lint .`.
79+
8580
For style guidance, look at Swift's [API design guidelines](https://swift.org/documentation/api-design-guidelines/) and Google's [Swift Style Guide](https://google.github.io/swift/).
8681

8782
## Editor Setup
@@ -116,11 +111,8 @@ If you have a setup for developing the driver in an editor other than the ones l
116111
## Workflow
117112
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`.
118113
1. Do your work on the branch.
119-
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`.
120114
1. Ensure your code passes both the linter and the formatter.
121-
1. Make sure your code builds and passes all tests on:
122-
- [Travis](https://travis-ci.org/mongodb/mongo-swift-driver). Every time you push to GitHub or open a pull request, it will trigger a new build, which includes running the linter, formatter, and basic tests.
123-
- (If you work at MongoDB) [Evergreen](https://evergreen.mongodb.com/waterfall/mongo-swift-driver) - Our Evergreen matrix tests a variety of MongoDB configurations, operating systems, and Swift language versions, and provides a way to more robustly test the driver. A new Evergreen build is automatically triggered for every commit to `main`, but for more complex pull requests it's a good idea to run patches on Evergreen before merging.
115+
1. Make sure your code builds and passes all tests on [Evergreen](https://evergreen.mongodb.com/waterfall/mongo-swift-driver). Our Evergreen matrix tests a variety of MongoDB configurations, operating systems, and Swift language versions, and provides a way to more robustly test the driver. If you work at MongoDB, a new Evergreen build is automatically triggered for every commit to `main` and for every pull request. If you do not work at MongoDB, ask a maintainer to trigger a test run on evergreen for you.
124116
1. Open a pull request on the repository. Make sure you have rebased your branch onto the latest commits on `main`.
125117
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:
126118
1. Rebase on `main` again if needed.

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ test-pretty:
2626
set -o pipefail && swift test $(FILTERARG) 2>&1 | xcpretty
2727

2828
lint:
29-
swiftlint autocorrect
29+
swiftlint --fix
3030
swiftlint
3131

32+
lint-and-format:
33+
swiftlint --fix
34+
swiftlint --strict --quiet
35+
swiftformat --lint .
36+
3237
# MacOS only
3338
coverage:
3439
swift test --enable-code-coverage

0 commit comments

Comments
 (0)