Developer Flow¶
If you haven’t set up your developer environment, please do so before continuing with this section.
Workflow¶
Here’s a general workflow a Mattermost developer working on our platform repository follows:
- Take a look at the Repository structure to find out where to look for what you’re working on.
- On your fork, create a branch PLT-####where #### is the ticket number if it is a Jira ticket, orGH-####if it is a GitHub Issue without a Jira ticket.
- Make the code changes required to complete your ticket, making sure to write or modify unit tests where appropriate.
- To test your changes, run make runfrom the root directory of the respository. This will start up the server and a watcher process that will build any changes to the client as you make them. To get changes to the server it must be restarted withmake restart-server. Your server will be running athttp://localhost:8065.
- Once everything works to meet the ticket requirements, stop the server with make stopand then run bothmake check-styleandmake testto make sure there are no errors with your syntax or tests.
- Commit your changes, push your branch and create a pull request.
- Respond to feedback on your pull request and make changes as necessary by commiting to your branch and pushing it. You might need to rebase your changes if another pull request creates conflicts.
- That’s it! Rejoice that you’ve helped make Mattermost better.
Useful Makefile commands¶
Some other make commands that might be useful in addition to the ones mentioned above:
- make run-serverwill run only the server and not the client
- make clean-dockerstops and removes your docker images and is a good way to wipe your database
- make run-fullmapwill run the server and build the client with the full source map for easier debugging
- make cleancleans your local environment of temporary files
- make nukewipes your local envrionment back to a completely fresh start
Running only specific unit tests¶
Since running every single unit test takes a lot of time while making changes, you can run a subset of the serverside unit tests by using the following:
go test -v -run='<test name or regex>' ./<package containing test>
For example, if you wanted to run TestPostUpdate in api/post_test.go, you would run the following:
go test -v -run='TestPostUpdate' ./api
Alternatively, if you’re writing client-side code, you can run only the client-side unit tests by using make test-client.
Repository structure¶
For server work, all the directories you’ll need are at the root of the repository.
- ./api/ holds all API and application related code
- ./model/ holds all data model definitions and the Go driver
- ./store/ holds all database querying code
- ./utils/ holds all utilities, such as the mail utility
- ./i18n/ holds all localization files for the server
For client work, you’ll mostly be working in ./webapp/.
- ./webapp/components/ holds all the React UI components and views
- ./webapp/actions/ holds all Flux actions where the majority of the logic of the webapp takes place
- ./webapp/stores/ holds the stores responsible for storing and providing the views with data
- ./webapp/routes/ holds the definitions for all the React-Router routes
- ./webapp/i18n/ holds the localization files for the client
- ./webapp/utils/ holds all widely-used utilities
- ./webapp/tests/ holds all the client unit tests
