Skip to content

Commit

Permalink
feat: contributing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Jul 12, 2023
1 parent a228813 commit ebfaf07
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 10 deletions.
22 changes: 18 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Here are all the different environment variables that you need to set for the workspace to function as expected.
# The values provided below are just examples and should not be used.
# Give nodejs more memory
NODE_OPTIONS=--max_old_space_size=8192

# NX
NX_CLOUD_ACCESS_TOKEN="NzIyMjllYzgtMzlkYS00N2U4LThjOGItOGU3YzM0OGQyMTk2fHJlYWQtb25seQ=="

# To be able to store build cache on NX Cloud, you need to provide an access token. The default one in `nx.json` file is used to publicly pull Noodle's cache but not be able to write to it.
NX_CLOUD_ACCESS_TOKEN="NzIyMjllYzgtMzlkYS00N2U4LThjOGItOGU3YzM0OGQyMTk2fHJlYWQtb25seQ=="
# Database
DATABASE_URL="postgres://username:password@localhost:5432/db_name"
DIRECT_URL="postgres://username:password@localhost:5432/db_name"

# Redis
REDIS_URL="<redis_url>"
REDIS_TOKEN="<redis_token>"

# Next Auth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="secretsecret"

# Github Auth
GITHUB_CLIENT_ID="<client_id>"
GITHUB_CLIENT_SECRET="<client_secret>"
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
"source.fixAll.eslint": true
},
"editor.formatOnSave": true,
"tailwindCSS.experimental.classRegex": [
Expand Down
176 changes: 174 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,175 @@
# Contributing
# Welcome to Noodle docs contributing guide

TODO: write this document
Thank you for your interest in contributing to our project! Any contribution is highly appreciated and will be reflected on our project ✨

First things first, make sure you read our [./CODE_OF_CONDUCT.md](Code of Conduct) to keep our community approachable and respectable.

In this guide, you will get an overview of the project structure and setup, as well as the workflow from opening an issue, creating a PR, reviewing, and merging the PR.

## Table of contents

- [Welcome to Noodle docs contributing guide](#welcome-to-noodle-docs-contributing-guide)
- [Table of contents](#table-of-contents)
- [New contributor guide](#new-contributor-guide)
- [Getting your foot in](#getting-your-foot-in)
- [Some simple rules](#some-simple-rules)
- [The tech stack](#the-tech-stack)
- [Getting stuff running](#getting-stuff-running)
- [Cloning the repo](#cloning-the-repo)
- [Volta](#volta)
- [Environment Variables](#environment-variables)
- [Installing dependencies](#installing-dependencies)
- [Running stuff](#running-stuff)
- [Closing notes](#closing-notes)

## New contributor guide

Here are some resources to help you get started with open source contributions:

- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests)

## Getting your foot in

Our preferred way of providing the opportunity for people to contribute to Noodle is through a process that starts with creating a new issue, the summary of the workflow that you can expect and should adhere to is the following:

- You see an area of improvement in the code base, this could be a fix, feature, refactoring...etc
- Create an [issue](https://github.com/ixahmedxi/noodle/issues) on our Github repository.
- Wait until a team member discusses the issue with you, and if both parties are in agreement, you can assign yourself to the issue.
- Start working on the issue, creating a draft pull request and remembering to link your pull request with the issue.
- Once the work is complete, change the status of the pull request to ready for review.
- We will review the pull request and if all is good, congratulations! 🥳 you are now a Noodle contributor!
- If not, we will explain the changes that need to be made for the pull request to be merged.

### Some simple rules

- Don't work on an issue that has already been assigned to someone.
- Don't work on something without getting a team member's approval, this is to not waste your time by making you work on something that won't be merged.
- Don't demand for your pull request to be approved and merged.
- Be nice to everyone involved, we are aiming to create a positive community around collaborating and contributing towards Noodle's development.

## The tech stack

The Building blocks:

- [NodeJS](https://nodejs.org/en)
- [Pnpm](https://pnpm.io/)
- [NX](https://nx.dev)

The actual stack:

- [Next.js](https://nextjs.org/)
- [TailwindCSS](https://tailwindcss.com/)
- [tRPC](https://trpc.io)
- [Prisma](https://www.prisma.io/)
- [Next-auth](https://next-auth.js.org/)

Development stuff:

- [Storybook](https://storybook.js.org/)
- [Vitest](https://vitest.dev/)
- [Playwright](https://playwright.dev/)
- [ESLint](https://eslint.org/)
- [Prettier](https://prettier.io)

There are a lot of other technologies being used in this project, however these are the most important and influential bits of it.

## Getting stuff running

### Cloning the repo

To clone the repo, you firstly need to [fork](https://github.com/ixahmedxi/noodle/fork) it, and then clone your copy of noodle locally.

```bash
git clone https://github.com/<your-gh-username>/noodle.git
```

### Volta

To get the project running locally, it is advised that you have [Volta](https://volta.sh/) installed on your system. This allows you to have the exact same versions of [NodeJS](https://nodejs.org/en) and [Pnpm](https://pnpm.io/) as we do, further lowering the chances of you getting errors that we don't get.

There are ways to do this using other tools such as NVM, but we take Noodle as an initiative to move people to arguably better tools such as Volta.

Volta's pnpm support is currently experimental, and so you need to do the following to let it manage your Pnpm version:

In your `.bashrc` or `.zshrc` file, add the following line:

```bash
export VOLTA_FEATURE_PNPM=1
```

With this out of the way, you should have the correct version of Nodejs and Pnpm once you change directory into Noodle's project folder. You can test this out as such:

```bash
# cd into noodle
cd /path/to/noodle

# output node and pnpm versions
node --version
pnpm --version
```

And make sure that the version is the same as the one defined in the root `package.json` file in the `volta` section.

### Environment Variables

Now that Volta has been installed locally on your system, it's time to configure your environment variables so that the project works as expected:

1. Duplicate the `.env.example` file as just `.env`
2. Populate the values with your own

You will need to create a postgres database and get the URL of it to use as the database for your local instance, we personally use [Neon](https://neon.tech/) as our database provider and hence we just create a development branch that we use instead of creating a local postgres instance.

We also use [Upstash](https://upstash.com/) for rate limiting and a redis instance.

You will also need to configure oauth github tokens to be able to use the authentication functionality of Noodle.

Also, if you want your own personal nx cloud instance, you will need to create a project on nx cloud and replace the default read only token provided.

### Installing dependencies

To install the dependencies needed to run Noodle, you need to run `pnpm install`, this will install all of the packages that we use.

### Running stuff

```bash
# Run the project's dev server
pnpm dev

# Build the project
pnpm build

# Run the built project in production mode
pnpm start

# Run the tests
pnpm test

# Run E2E tests
pnpm test:e2e

# Run the tests with coverage reporting
pnpm test:coverage

# Tests in watch mode
pnpm test:watch

# Lint
pnpm lint

# Format
pnpm format:write

# Storybook
pnpm storybook
```

Also, if in doubt and something is going wrong, `pnpm clean`.

This is only a subset of the important commands that you will be using throughout your usage of Noodle's codebase. Be sure to check out [the package.json file](./package.json) for the full list and get familiar with [Nx's commands](https://nx.dev/reference/commands) for more complex use cases.

## Closing notes

Again, thank you so much for your interest in contributing to Noodle, we really appreciate it, and if there is anything we can do to help your journey, make sure to join our [Discord Server](https://discord.gg/SERySfj8Eg).
4 changes: 2 additions & 2 deletions apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Redis } from '@upstash/redis';
import { NextResponse } from 'next/server';

const redis = new Redis({
url: 'https://eternal-deer-42544.upstash.io',
token: process.env['UPSTASH_TOKEN']!,
url: process.env['REDIS_URL']!,
token: process.env['REDIS_TOKEN']!,
});

const ratelimit = new Ratelimit({
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"storybook": "pnpm nx storybook storybook",
"test": "pnpm nx run-many -t test",
"test:coverage": "pnpm nx run-many -t test:coverage --output-style=stream",
"test:e2e": "pnpm nx run-many -t e2e --parallel=99 --output-style=stream",
"test:ui": "pnpm nx run-many -t test:ui --parallel=99 --output-style=stream",
"test:watch": "pnpm nx run-many -t test:watch --parallel=99 --output-style=stream",
"typecheck": "pnpm nx run-many -t typecheck"
Expand Down

0 comments on commit ebfaf07

Please sign in to comment.