Skip to content

Commit

Permalink
github_actions: Add workflows and update docs.
Browse files Browse the repository at this point in the history
Added workflows for CI/CD, eslint and prettier.
Made changes to src files to pass the tests.
  • Loading branch information
shivansh-bhatnagar18 authored and kuv2707 committed May 27, 2024
1 parent 28361cf commit 9cd99ca
Show file tree
Hide file tree
Showing 18 changed files with 6,137 additions and 1,038 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: ESLint

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
eslint-backend:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install backend dependencies
working-directory: ./backend
run: npm install

- name: Run backend lint
working-directory: ./backend
run: npm run lint

eslint-frontend:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install frontend dependencies
working-directory: ./frontend
run: npm install

- name: Run frontend lint
working-directory: ./frontend
run: npm run lint
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI/CD Pipeline

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest

services:
mongo:
image: mongo:latest
ports:
- 27017:27017

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install backend dependencies
working-directory: ./backend
run: npm install

# - name: Run backend tests
# working-directory: ./backend
# run: npm test

- name: Install frontend dependencies
working-directory: ./frontend
run: npm install

# - name: Run frontend tests
# working-directory: ./frontend
# run: npm test

- name: Build frontend
working-directory: ./frontend
run: npm run build
52 changes: 52 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Prettier

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
prettier-backend:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install backend dependencies
working-directory: ./backend
run: npm install

- name: Run backend format check
working-directory: ./backend
run: npm run format

prettier-frontend:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install frontend dependencies
working-directory: ./frontend
run: npm install

- name: Run frontend format check
working-directory: ./frontend
run: npm run format
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Maintainers will approve the issue and add relevant labels to indicate that its
- Look for issues labeled `help wanted` or `good first issue` if you are a first-time contributor.

2. **Comment on the Issue**:
- Before starting work on an issue, comment on the issue to let others know that you are working on it. This helps prevent duplicate work.
- Before starting work on an issue, comment on the issue to let others know that you are working on it. This helps prevent duplicate work. Once the issue is assigned to you, you can start working on it.

If you are not able to make progress on an issue in 4 days, you will be unassigned from the issue and it will be available for others to work on.

3. **Fork the Repository**:
- Fork the repository to your own GitHub account by clicking the "Fork" button on the top right of the repository page.
Expand Down Expand Up @@ -65,14 +67,16 @@ Maintainers will approve the issue and add relevant labels to indicate that its
- Open a pull request (PR) against the `main` branch of the original repository. Provide a clear description of your changes and reference the issue number you are fixing. Fill the self review checklist.

11. **Address Review Comments**:
- If maintainers request changes to your code, make the necessary updates and push the changes to your branch. The fix/changes should not be in a separate commit - rather the original commit must be modified force-pushed to the branch. If merge conflicts arise, use `git rebase` to resolve them.
- If maintainers suggests changes to your code, make the necessary updates and push the changes to your branch. The fix/changes should not be in a separate commit - rather the original commit must be modified force-pushed to the branch. If merge conflicts arise, use `git rebase` to resolve them.

<!-- todo: add details about modifying pull requests following a review.-->

## Points to remember during contribution

- Editing commit history and rebasing are very valuable tools for keeping the commit history clean and easy to understand. Please familiarize yourself with these concepts before contributing. In any case, the seniors will be there to help you out.
- Before starting work, run `git fetch upstream` and then `git rebase upstream/master`, to rebase your branch on top of the main branch. This will help you avoid merge conflicts, and sync your branch with the main branch.
- Addressing reviews on existing PRs is as important as creating new PRs. Please be responsive to the feedback and make the necessary updates.
- Create a new branch for each issue you are working on. This will help you keep your changes isolated and make it easier to manage multiple PRs. The branch should be created from upstream/master, and only after fetching the latest changes from the main branch from upstream first.

## Code Review

Expand Down
23 changes: 19 additions & 4 deletions CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


## For React Components
- Use functional components with hooks insteaad of class based components.
- Use functional components with hooks instead of class based components.
- Avoid copy pasting code. If you find yourself copying and pasting code, consider refactoring it into a reusable component or function. Use array methods like `map`, `filter`, and `reduce` to avoid duplicating code.


Expand All @@ -26,14 +26,29 @@
<detailed_description>
Fixes: #<issue_number>
Fixes: #<issue_number> (omit this if there is no issue associated with the commit)
```
Some examples:
```
server: Add endpoint to fetch user data.
This commit adds a new endpoint to the server that allows clients to fetch user data.
Fixes #28686
```
```
client: Refactor user profile component.
This commit refactors the user profile component to improve code readability and maintainability.
```
## Other Important Points
- Use meaningful and descriptive names for variables, functions, and classes to enhance code readability.
- Follow consistent indentation and formatting throughout the codebase (will be enforced by ESLint).
- Follow consistent indentation and formatting throughout the codebase (will be enforced by ESLint and prettier).
- Use proper spacing and line breaks to improve code readability.
- Avoid unnecessary code duplication and strive for code reusability.
- Write clear and concise documentation for public APIs and important functions.
- Write clear and concise documentation for public APIs and important functions. Do not over-document trivial functions.
Remember to review and adhere to these conventions to maintain a clean and consistent codebase.
3 changes: 3 additions & 0 deletions backend/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/*
/dist/*
/tests/*
18 changes: 18 additions & 0 deletions backend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
// Add your custom rules here
}
}
6 changes: 6 additions & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 4,
"semi": true
}
Loading

0 comments on commit 9cd99ca

Please sign in to comment.