-
Notifications
You must be signed in to change notification settings - Fork 536
Contributing
If you'd like to contribute to the Fluid Framework open source codebase, first of all, thank you! We'd love to see your ideas and appreciate your contributions, whether they be in the form of bug reports, idea suggestions, code submissions, or just trying out our platform.
We have tried to make it as easy as possible to set up your local clone of the Fluid Framework so that you can hit the ground running. Let's get started!
The official Fluid Framework code repository resides on GitHub. In the next few steps, we will look at how to create our own fork of the official repository and set up a local git clone.
If you are not familiar with git or GitHub, please take a look at this introduction to familiarize yourself with fundamental git concepts such as cloning, branching, forking etc.
We are now going to create your own personal fork of the entire repo. This will give you a sandbox environment to add and remove any changes as you wish. You will have full freedom to do whatever you want on this fork.
We will establish upstream hooks later on to allow you to pull updates from the official repo, and submit pull requests to add changes to the official repo.
Please go to the repo and click "Fork". Then choose your personal account.
Awesome! Now you should be on a page with a URL that looks like "https://github.com/{YOUR-USER-NAME}/FluidFramework". This is your own fork of the most current version of the repo, hot off the presses!
Let's get it onto your local machine now!
Over the following steps, we will clone the repo and add upstream remote connections to the official repo so that you can fetch updates from it in your own master branch.
The remote you fork from is most often referred to as upstream
, and we will use that name in this example. But you can name it microsoft
, ms
, etc. as you wish.
- With our own fork available now, we can clone it using the command line tool of your choice
git clone https://github.com/{YOUR-USER-NAME}/FluidFramework.git
- Now, we will add the
upstream
remote to the official version of the repo.
git remote add upstream https://github.com/microsoft/FluidFramework
- With that added, we will fetch any new updates from the official repo.
git fetch upstream
- Now, we want our fork's
master
branch to track the official repo'smaster
so that we always get the latest code there when we pull
git branch master --set-upstream-to upstream/master
You can also optionally set a different branch to track the official repo, if you'd like to keep your personal master
separate. But you will need to remember to merge with that branch prior to submitting any changes to the official repo.
- Pull the contents of
upstream/master
to your localmaster
, since it was previously tracking your forked copy of the repo
git pull
- Optional - Prevent yourself from ever pushing a branch to
upstream
by setting theupstream
remote to an invalid URL. All developer branches should instead be merged into the official repo using the Pull Request process.
git remote set-url --push upstream no_push
And now, we should have our personal repo all set up! We can quickly run
git remote -v
to verify that everything is setup correctly. It should look something like this.
upstream https://github.com/microsoft/FluidFramework (fetch)
upstream no_push (push)
origin https://github.com/{YOUR-USER-NAME}/FluidFramework.git (fetch)
origin https://github.com/{YOUR-USER-NAME}/FluidFramework.git (push)
With your local version of the code now setup, let's walk through how to start making changes.
- Get the latest changes from the official repo using our
upstream
remote
git checkout master
git pull
- Create and checkout a new local branch to start making changes on
git checkout -b {YOUR-LOCAL-BRANCH}
- At this point, you can add any changes using the normal
git add
andgit commit
commands.
When you are ready to push to your fork, use the following
git push --set-upstream origin {YOUR-LOCAL-BRANCH}
This is only needed the first time you push your branch. Any subsequent pushes only need a git push
- With the branch now available on your remote fork, we can go to the official repo website and you should see a prompt requesting you to make a Pull Request
Go ahead and click "Compare and Pull Request".
This will automatically select the official repository's master
branch as the target for the merge and display your changes.
Alternatively, you can also navigate to Pull Requests. Here, click "New Pull Request" and you will see this.
Here, you will need to click on "compare across forks" to start seeing the branches on your fork. Select your fork in "Head repository" and your branch in "compare" for the source:
- Now you can simply click "Create Pull Request" to start the review process. Alternatively, you can also create a "Draft Pull Request" if the branch is still a work-in-progress.
You will need to complete a Contributor License Agreement (CLA) to submit changes. This agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. Upon submitting a pull request, you will automatically be given instructions on how to sign the CLA.
The only pre-requisites for running the Fluid Framework code are:
- Git LFS (included by default with most Git installations)
- Node v12.x
-
Docker (only required for running the
routerlicious
server docker image locally, not needed for just running client component packages)
With these dependencies installed, simply navigate to the FluidFramework directory and run the following two commands:
npm install
npm run build:fast
This will automatically install all dependency packages, and then build & compile the entire FluidFramework codebase.
When it has successfully finished, your output will look similar to this
The first time you run these commands, they will take some time as it is downloading all of the dependencies and setting up symlinks for the local packages to be able to use them. Any subsequent runs should be much faster.
npm install
will only re-download packages that were not present locally or ones that were updated
npm run build:fast
will only re-compile code that has been edited, and any code that is dependent on the edited code. It will skip the tasks for any unedited code.
- Navigate to the specific component directory from the repo root, i.e. for
Clicker
this is
cd ./components/examples/clicker
- Start the component
npm run start
- Open you browser and navigate to the http://localhost:8080 to see two renders of
Clicker
side-by-side. The two represent two different clients renderingClicker
using a local in-memory server.
You can think of the user on the left as User A and the right as User B. When one user clicks, the clicker increments for both users since it is a synced Fluid component. This allows you to quickly test cross-client behavior locally without needing a second device.
You will also have noticed that something got added to the URL and it looks similar to "http://localhost:8080/second-hand-shop". The bit after "http://localhost:8080/" is a random string used to represent different sessions.
That's why, if you refresh the page using the same URL, you will see that the Clicker
count is persistent since it reloads the same session.
To load a new session, simply change the string or remove it all together. You will see that on the new page, Clicker
once again starts from 0.
- To open another component simultaneously, just navigate to its directory in a separate terminal window and run
npm run start
again. It will now load the second component in http://localhost:8081 since 8080 is already in use.
You can dynamically edit components while they are running! Simply run the component as described above, using npm run start
and edit away!
As long as the changes are local to the component package itself, the script running the component will automatically recompile when you save your changes and refresh with your updates.
It's usually a good idea to update the string at the end of your "http://localhost:8080/" URL after this as the older session storage may be corrupted from your older code. Starting a new session by changing the string will give you a clean environment.
If you are editing code across multiple packages, you will need to run npm run build:fast
again to have your component pick these changes up.
Clicker
, for example, has dependencies on the @fluidframework/aqueduct
package. If we modified code in aqueduct
and we needed Clicker
to pick these up, simply re-run npm run build:fast
from the repo root.
If this is not the first build, it will only re-build @fluidframework/aqueduct
and any packages that depend on it (including Clicker
). All other packages will be ignored as there is no change there.
- Navigate to the
./server/tinylicious
directory and build it.
npm i
npm run build
NOTE: You will get some errors on install from kafka-node
if you don't have Python, Visual Studio, and Desktop Development with C++ Workload installed – these are safe to ignore, since they are from an optional dependency (more info).
- If the build succeeds, start the
tinylicious
server
npm start
- Now, we can run components against this server. We will use
Clicker
as an example. Navigate to theClicker
directory and start the component using thestart:tinylicious
command
cd ./components/examples/clicker
npm run start:tinylicious
This command is running the following script for reference
webpack-dev-server --config webpack.config.js --package package.json --env.mode tinylicious
- Now navigate to http://localhost:8080 to see
Clicker
running ontinylicious
NOTE: tinylicious
stores persisted data on your filesystem at /var/lib/tinylicious
. On Windows, this will be C:/var/lib/tinylicious
. If you want to clear everything and start fresh, then shut down tinylicious
and delete that folder. The next time you start tinylicious
everything should be as new.
This wiki is focused on contributing to the Fluid Framework codebase.
For information on using Fluid Framework or building applications on it, please refer to fluidframework.com.
- Submitting Bugs and Feature Requests
-
Contributing to the Repo
- Repo Basics
- Common Workflows and Patterns
- Managing dependencies
- Client Code
- Server Code
- PR Guidelines
- CI Pipelines
- Breaking vs Non-Breaking Changes
- Branches, Versions, and Releases
- Compatibility & Versioning
- Testing
- Debugging
- npm package scopes
- Maintaining API support levels
- Developer Tooling Maintenance
- API Deprecation
- Working with the Website (fluidframework.com)
- Coding Guidelines
- Documentation Guidelines
- CLA