Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Latest commit

 

History

History
458 lines (300 loc) · 17.8 KB

CONTRIBUTING.md

File metadata and controls

458 lines (300 loc) · 17.8 KB

Contributor's Guide

We welcome pull requests from freeCodeCamp campers (our students) and seasoned JavaScript developers alike!

Follow these steps to contribute:

  1. Find an issue that needs assistance by searching for the Help Wanted tag.

  2. Let us know you are working on it by posting a comment on the issue.

  3. Follow the Contribution Guidelines to start working on the issue.

Remember to feel free to ask for help in our general Contributors or open-api Gitter rooms.

Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub


Quick Reference

command description
yarn test run all tests
yarn commit interactive tool to help you build a good commit message
yarn start starts your Lambda locally
yarn deploy-dev deploy your Lambda to a development environment. Requires an AWS account.
yarn generate-auth-header generate headers for local testing
yarn encode-file-contents base64 encode the contents of a file

Table of Contents

Setup

Prerequisites

Prerequisite Version
Yarn
Docker
Node.js ~ ^8.10

Forking the Project

Setting Up Your System

  1. Install Git or your favorite Git client.
  2. (Optional) Setup an SSH Key for GitHub.
  3. Install Yarn
  4. Install Docker
  5. Install Node
  6. Pull the Lambda image to simulate the AWS Lambda environment: docker pull lambci/lambda

Forking freeCodeCamp

  1. Go to the top level open-api repository: https://github.com/freeCodeCamp/open-api
  2. Click the "Fork" Button in the upper right hand corner of the interface (More Details Here)
  3. After the repository (repo) has been forked, you will be taken to your copy of the freeCodeCamp repo at https://github.com/yourUsername/open-api

Cloning Your Fork

  1. Open a Terminal / Command Line / Bash Shell in your projects directory (i.e.: /yourprojectdirectory/)
  2. Clone your fork of open-api
$ git clone https://github.com/yourUsername/open-api.git

(make sure to replace yourUsername with your GitHub username)

This will download the entire freeCodeCamp repo to your projects directory.

Setup Your Upstream

  1. Change directory to the new open-api directory (cd opena-api)
  2. Add a remote to the official open-api repo:
$ git remote add upstream https://github.com/freeCodeCamp/open-api.git

Congratulations, you now have a local copy of the open-api repo!

Maintaining Your Fork

Now that you have a copy of your fork, there is work you will need to do to keep it current.

Rebasing from Upstream

Do this prior to every time you create a branch for a PR:

  1. Make sure you are on the staging branch
$ git status
On branch staging
Your branch is up-to-date with 'origin/staging'.

If your aren't on staging, resolve outstanding files / commits and checkout the staging branch

$ git checkout staging
  1. Do a pull with rebase against upstream
$ git pull --rebase upstream staging

This will pull down all of the changes to the official staging branch, without making an additional commit in your local repo.

  1. (Optional) Force push your updated staging branch to your GitHub fork
$ git push origin staging --force

This will overwrite the staging branch of your fork.

Create a Branch

Before you start working, you will need to create a separate branch specific to the issue / feature you're working on. You will push your work to this branch.

Naming Your Branch

Name the branch something like fix/xxx or feature/xxx where xxx is a short description of the changes or feature you are attempting to add. For example fix/email-login would be a branch where you fix something specific to email login.

Adding Your Branch

To create a branch on your local machine (and switch to this branch):

$ git checkout -b [name_of_your_new_branch]

and to push to GitHub:

$ git push origin [name_of_your_new_branch]

If you need more help with branching, take a look at this.

Set Up Linting

You should have ESLint running in your editor, and it will highlight anything doesn't conform to freeCodeCamp's JavaScript Style Guide (you can find a summary of those rules here).

Please do not ignore any linting errors, as they are meant to help you and to ensure a clean and simple code base.

Set Up

Once you have open-api cloned, before you start the application, you first need to install all of the dependencies:

# Install dependencies
yarn

Then you need to add the private environment variables (API Keys):

# Create a copy of the "sample.env" and name it as ".env".
# Populate it with the necessary API keys and secrets:

# macOS / Linux
cp sample.env .env

# Windows
copy sample.env .env

Then edit the .env file and modify the keys only for parts that you will use.

Note: Not all keys are required, to run the app locally, however MONGODB_URL is the most important one. Unless you have MongoDB running in a setup different than the defaults, the URL in the sample.env should work fine.

You can leave the other keys as they are.

Set up freeCodeCamp which will provide you with a pre-seeded Mongo container. Find instructions at https://github.com/freeCodeCamp/freeCodeCamp/blob/staging/CONTRIBUTING.md#setup-freecodecamp-using-docker

Run

Start a local container emulating the AWS Lambda environment

▶ yarn start
yarn run v1.6.0
$ cross-env DEBUG=fcc:* nodemon node_modules/serverless/bin/serverless offline start --skipCacheInvalidation
[nodemon] 1.17.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node node_modules/serverless/bin/serverless offline start --skipCacheInvalidation`

Serverless: Bundling with Webpack...
Time: 1002ms
Built at: 2018-05-08 11:47:35
             Asset      Size       Chunks             Chunk Names
    src/handler.js  41.4 KiB  src/handler  [emitted]  src/handler
src/handler.js.map  30.5 KiB  src/handler  [emitted]  src/handler
Entrypoint src/handler = src/handler.js src/handler.js.map
[./src/_webpack/include.js] 406 bytes {src/handler} [built]
[./src/dataLayer/index.js] 491 bytes {src/handler} [built]
[./src/graphql/resolvers/directives.js] 933 bytes {src/handler} [built]
[./src/graphql/resolvers/index.js] 193 bytes {src/handler} [built]
[./src/graphql/typeDefs/HTTPStatus/index.js] 77 bytes {src/handler} [built]
[./src/graphql/typeDefs/index.js] 262 bytes {src/handler} [built]
[./src/handler.js] 2.14 KiB {src/handler} [built]
[apollo-server-lambda] external "apollo-server-lambda" 42 bytes {src/handler} [built]
[debug] external "debug" 42 bytes {src/handler} [built]
[graphql-playground-middleware-lambda] external "graphql-playground-middleware-lambda" 42 bytes {src/handler} [built]
[0] multi ./src/_webpack/include.js ./src/handler.js 40 bytes {src/handler} [built]
[graphql-tools] external "graphql-tools" 42 bytes {src/handler} [built]
[merge-graphql-schemas] external "merge-graphql-schemas" 42 bytes {src/handler} [built]
[mongoose] external "mongoose" 42 bytes {src/handler} [built]
[source-map-support/register] external "source-map-support/register" 42 bytes {src/handler} [built]
    + 25 hidden modules
Serverless: Watching for changes...
Serverless: Starting Offline: dev/us-east-1.

Serverless: Routes for graphql:
Serverless: POST /graphql

Serverless: Routes for api:
Serverless: GET /api

Serverless: Offline listening on http://localhost:4000

You should now be able to interact the GraphQL server directly or by using the GraphQL IDE at http://localhost:4000/api .

For authenticated endpoints you'll need to pass a valid token in the authorization headers. For a local instance you can generate one by running:

yarn generate-auth-header

And then add those to "http headers" in http://localhost:4000/api.

Make Changes

This bit is up to you!

Add tests

If you have added functionality, please add unit, integration tests or both.

Place unit tests close to the code they test, in the same directory and file name, ie: foo.test.js tests foo.js.

Place integration tests in test/integration. We just Jest for integration tests.

Run The Test Suite

When you're ready to share your code, run the test suite:

yarn test

and ensure all tests pass.

Creating a Pull Request

What is a Pull Request?

A pull request (PR) is a method of submitting proposed changes to the open-api repo (or any repo, for that matter). You will make changes to copies of the files which make up open-api in a personal fork, then apply to have them accepted by open-api proper.

Need Help?

freeCodeCamp Issue Mods and staff are on hand to assist with Pull Request related issues in our general Contributors or open-api Gitter rooms.

Important: ALWAYS EDIT ON A BRANCH

Take away only one thing from this document: Never, EVER make edits to the staging branch. ALWAYS make a new branch BEFORE you edit files. This is critical, because if your PR is not accepted, your copy of staging will be forever sullied and the only way to fix it is to delete your fork and re-fork.

Methods

There are two methods of creating a pull request for freeCodeCamp:

  • Editing files on a local clone (recommended)
  • Editing files via the GitHub Interface
Method 1: Editing via your Local Fork (Recommended)

This is the recommended method. Read about How to Setup and Maintain a Local Instance of open-api.

  1. Perform the maintenance step of rebasing staging.

  2. Ensure you are on the staging branch using git status:

    $ git status
    On branch staging
    Your branch is up-to-date with 'origin/staging'.
    
    nothing to commit, working directory clean
    
  3. If you are not on staging or your working directory is not clean, resolve any outstanding files/commits and checkout staging git checkout staging

  4. Create a branch off of staging with git: git checkout -B branch/name-here Note: Branch naming is important. Use a name like fix/short-fix-description or feature/short-feature-description. Review the Contribution Guidelines for more detail.

  5. Edit your file(s) locally with the editor of your choice. To edit challenges, you may want to use unpack and repack -- see Unpack and Repack for instructions.

  6. Check your git status to see unstaged files.

  7. Add your edited files: git add path/to/filename.ext You can also do: git add . to add all unstaged files. Take care, though, because you can accidentally add files you don't want added. Review your git status first.

  8. Commit your edits: We have a tool that helps you to make standard commit messages. Execute npm run commit and follow the steps.

  9. Squash your commits if there are more than one.

  10. If you would want to add/remove changes to previous commit, add the files as in Step 5 earlier, and use git commit --amend or git commit --amend --no-edit (for keeping the same commit message).

  11. Push your commits to your GitHub Fork: git push origin branch/name-here

  12. Go to Common Steps

Method 2: Editing via the GitHub Interface

Note: Editing via the GitHub Interface is not recommended, since it is not possible to update your fork via GitHub's interface without deleting and recreating your fork.

Read the Wiki article for further information

Common Steps

  1. Once the edits have been committed, you will be prompted to create a pull request on your fork's GitHub Page.

  2. By default, all pull requests should be against the open-api main repo, staging branch. Make sure that your Base Fork is set to freeCodeCamp/open-api when raising a Pull Request.

    fork-instructions

  3. Submit a pull request from your branch to freeCodeCamp's staging branch.

  4. The title (also called the subject) of your PR should be descriptive of your changes and succinctly indicates what is being fixed.

    • Do not add the issue number in the PR title or commit message.

    • Examples: Add Test Cases to Bonfire Drop It Correct typo in Waypoint Size Your Images

  5. In the body of your PR include a more detailed summary of the changes you made and why.

    • If the PR is meant to fix an existing bug/issue then, at the end of your PR's description, append the keyword closes and #xxxx (where xxxx is the issue number). Example: closes #1337. This tells GitHub to close the existing issue, if the PR is merged.
  6. Indicate if you have tested on a local copy of the site or not.

How We Review and Merge Pull Requests

freeCodeCamp has a team of volunteer Issue Moderators. These Issue Moderators routinely go through open pull requests in a process called Quality Assurance (QA).

  1. If an Issue Moderator QA's a pull request and confirms that the new code does what it is supposed without seeming to introduce any new bugs, they will comment "LGTM" which means "Looks good to me."

  2. Another Issue Moderator will QA the same pull request. Once they have also confirmed that the new code does what it is supposed to without seeming to introduce any new bugs, they will merge the pull request.

If you would like to apply to join our Issue Moderator team, message @quincylarson with links to 5 of your pull requests that have been accepted and 5 issues where you have helped someone else through commenting or QA'ing.

How We Close Stale Issues

We will close any issues or pull requests that have been inactive for more than 15 days, except those that match the following criteria:

  • bugs that are confirmed
  • pull requests that are waiting on other pull requests to be merged
  • features that are a part of a GitHub project

Next Steps

If your PR is accepted

Once your PR is accepted, you may delete the branch you created to submit it. This keeps your working fork clean.

You can do this with a press of a button on the GitHub PR interface. You can delete the local copy of the branch with: git branch -D branch/to-delete-name

If your PR is rejected

Don't despair! You should receive solid feedback from the Issue Moderators as to why it was rejected and what changes are needed.

Many Pull Requests, especially first Pull Requests, require correction or updating. If you have used the GitHub interface to create your PR, you will need to close your PR, create a new branch, and re-submit.

If you have a local copy of the repo, you can make the requested changes and amend your commit with: git commit --amend This will update your existing commit. When you push it to your fork you will need to do a force push to overwrite your old commit: git push --force

Be sure to post in the PR conversation that you have made the requested changes.

Other Resources