Skip to content

Commit

Permalink
Merge branch 'main-develop-postgres' into linux_systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
PurnenduMIshra129th committed Jan 11, 2025
2 parents 1e8d6b5 + 61a8aa5 commit d4b7b98
Show file tree
Hide file tree
Showing 315 changed files with 3,618 additions and 2,820 deletions.
2 changes: 2 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ reviews:
auto_review:
base_branches:
- develop-postgres
- develop
- main
poem: false
profile: "assertive"
request_changes_workflow: true
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"extensions": [
"biomejs.biome",
"esbenp.prettier-vscode",
"ms-azuretools.vscode-docker",
"GraphQL.vscode-graphql",
"GraphQL.vscode-graphql-syntax",
"redhat.vscode-yaml"
Expand Down Expand Up @@ -68,10 +67,11 @@
"ghcr.io/devcontainers/features/github-cli": {}
},
"init": true,
"initializeCommand": "cp ../.env_files/.env.devcontainer ../.env",
"initializeCommand": "cp -n ./envFiles/.env.devcontainer ./.env",
"name": "talawa_api",
"overrideCommand": true,
"postCreateCommand": "fnm install && fnm use && corepack enable npm && corepack enable && corepack install",
"postCreateCommand": "sudo chown talawa:talawa ./.pnpm-store ./node_modules && fnm install && fnm use && corepack enable npm && corepack enable && corepack install && pnpm install --prod=false && pnpm push_drizzle_schema && pnpm start_development_server",
"postStartCommand": "pnpm install --prod=false",
"remoteUser": "talawa",
"service": "api",
"shutdownAction": "stopCompose",
Expand Down
51 changes: 48 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
echo "Error: Close this PR and try again."
exit 1
check_eslint_disable:
name: Check for eslint-disable
check_biome_ignore:
name: Check for biome_ignore
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -66,7 +66,7 @@ jobs:

- name: Run Python script
run: |
python .github/workflows/scripts/eslint_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
python .github/workflows/scripts/biome_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
check_code_coverage_disable:
name: Check for code coverage disable
Expand Down Expand Up @@ -134,19 +134,47 @@ jobs:
with:
files: |
.coderabbit.yaml
Caddyfile
codegen.ts
Dockerfile*
docker-compose*
.dockerignore
.env.sample
.env_test
eslint.config.mjs
.gitignore
init-mongo.sh
.prettierignore
.prettierrc.json
.pylintrc
.github/**
biome.jsonc
drizzle_migrations/**
renovate.json
requirements.txt
schema.graphql
CODEOWNERS
LICENSE
tsconfig.json
vitest.config.ts
pnpm-lock.yaml
package.json
package-lock.json
.nojekyll
docs/docusaurus.config.ts
docs/sidebar*
setup.ts
tsconfig.build.json
vite.config.mts
CNAME
CODE_OF_CONDUCT.md
CODE_STYLE.md
CONTRIBUTING.md
DOCUMENTATION.md
INSTALLATION.md
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md
- env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
if: steps.changed_files.outputs.any_changed == 'true' || steps.changed_files.outputs.any_deleted == 'true'
Expand Down Expand Up @@ -193,3 +221,20 @@ jobs:
- name: Test building the website
working-directory: ./docs
run: pnpm build

Validate-Coderabbit:
name: Validate CodeRabbit Approval
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
needs: [Test-Docusaurus-Deployment]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Validate CodeRabbit.ai Approval
run: |
chmod +x $GITHUB_WORKSPACE/.github/workflows/scripts/validate-coderabbit.sh
$GITHUB_WORKSPACE/.github/workflows/scripts/validate-coderabbit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""ESLint Checker Script.
"""Biome Checker Script.
Methodology:
Recursively analyzes TypeScript files in the specified directory
or checks specific files directly to ensure they do not contain
eslint-disable statements.
This script enforces code quality practices in the project.
Recursively analyzes specified files or directories to ensure they do
not contain biome-ignore statements, enforcing code quality practices.
NOTE:
This script complies with our python3 coding and documentation standards.
Expand All @@ -27,26 +24,22 @@
import sys


def has_eslint_disable(file_path):
def has_biome_ignore(file_path: str) -> bool:
"""
Check if a TypeScript file contains eslint-disable statements.
Check if a file contains biome-ignore statements.
Args:
file_path (str): Path to the TypeScript file.
file_path (str): Path to the file.
Returns:
bool: True if eslint-disable statement is found, False otherwise.
bool: True if biome-ignore statement is found, False otherwise.
"""
eslint_disable_pattern = re.compile(
r"""\/\/\s*eslint-disable(?:-next-line
|-line)?[^\n]*|\/\*\s*eslint-disable[^\*]*\*\/""",
re.IGNORECASE,
)
biome_ignore_pattern = re.compile(r"//\s*biome-ignore.*$", re.IGNORECASE | re.MULTILINE)

try:
with open(file_path, "r", encoding="utf-8") as file:
with open(file_path, encoding="utf-8") as file:
content = file.read()
return bool(eslint_disable_pattern.search(content))
return bool(biome_ignore_pattern.search(content))
except FileNotFoundError:
print(f"File not found: {file_path}")
return False
Expand All @@ -58,42 +51,39 @@ def has_eslint_disable(file_path):
return False


def check_eslint(files_or_directories):
def check_biome(files_or_directories: list[str]) -> bool:
"""
Check TypeScript files for eslint-disable statements.
Check files for biome-ignore statements.
Args:
files_or_directories (list): List of files or directories to check.
Returns:
bool: True if eslint-disable statement is found, False otherwise.
bool: True if biome-ignore statement is found, False otherwise.
"""
eslint_found = False
biome_found = False

for item in files_or_directories:
if os.path.isfile(item):
# If it's a file, directly check it
if item.endswith(".ts") :
if has_eslint_disable(item):
print(f"File {item} contains eslint-disable statement. Please remove them and ensure the code adheres to the specified ESLint rules.")
eslint_found = True
if os.path.isfile(item) and item.endswith((".ts", ".tsx")) and has_biome_ignore(item):
print(f"File {item} contains biome-ignore statement. Please remove them and ensure the code adheres to the specified Biome rules.")
biome_found = True
elif os.path.isdir(item):
# If it's a directory, walk through it and check all
# .ts and .tsx files
for root, _, files in os.walk(item):
if "node_modules" in root:
continue
for file_name in files:
if file_name.endswith(".ts") :
if file_name.endswith((".ts", ".tsx")):
file_path = os.path.join(root, file_name)
if has_eslint_disable(file_path):
if has_biome_ignore(file_path):
print(
f"""File {file_path} contains eslint-disable
statement."""
f"""File {file_path} contains biome-ignore
statement.""",
)
eslint_found = True
biome_found = True

return eslint_found
return biome_found


def arg_parser_resolver():
Expand All @@ -108,15 +98,15 @@ def arg_parser_resolver():
type=str,
nargs="+",
default=[],
help="""List of files to check for eslint disable
help="""List of files to check for biome-ignore
statements (default: None).""",
)
parser.add_argument(
"--directory",
type=str,
nargs="+",
default=[os.getcwd()],
help="""One or more directories to check for eslint disable
help="""One or more directories to check for biome-ignore
statements (default: current directory).""",
)
return parser.parse_args()
Expand All @@ -130,9 +120,9 @@ def main():
the following tasks:
1. Validates and retrieves the files and directories to check from
command line arguments.
2. Recursively checks TypeScript files for eslint-disable statements.
2. Recursively checks files for biome-ignore statements.
3. Provides informative messages based on the analysis.
4. Exits with an error if eslint-disable statements are found.
4. Exits with an error if biome-ignore statements are found.
Raises:
SystemExit: If an error occurs during execution.
Expand All @@ -141,14 +131,14 @@ def main():

# Determine whether to check files or directories based on the arguments
files_or_directories = args.files if args.files else args.directory
# Check eslint in the specified files or directories
eslint_found = check_eslint(files_or_directories)
# Check biome in the specified files or directories
biome_found = check_biome(files_or_directories)

if eslint_found:
print("ESLint-disable check failed. Exiting with error.")
if biome_found:
print("Biome-ignore check failed. Exiting with error.")
sys.exit(1)

print("ESLint-disable check completed successfully.")
print("Biome-ignore check completed successfully.")


if __name__ == "__main__":
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/scripts/validate-coderabbit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

echo "Step 1: Fetching all PR reviews..."

response=$(curl -s -f -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews?per_page=1000") || {
echo "Error: Failed to fetch reviews from GitHub API"
exit 1
}

latest_reviews=$(echo "$response" | jq -c '[.[]] | group_by(.user.login) | map(max_by(.submitted_at))') || {
echo "Error: Failed to process reviews JSON"
exit 1
}

if [ "$latest_reviews" = "null" ] || [ -z "$latest_reviews" ]; then
echo "Error: Invalid reviews data"
exit 1
fi

echo "Step 2: Checking approval status of 'coderabbitai[bot]'..."
approval_state=$(echo "$latest_reviews" | jq -r '[.[] | select(.user.login == "coderabbitai[bot]" and .state == "APPROVED")] | length')

if [[ "$approval_state" =~ ^[0-9]+$ ]] && [[ $approval_state -gt 0 ]]; then
echo "Success: PR approved by CodeRabbit.ai."
else
echo ""
echo "ERROR:"
echo ""
echo "1) This PR is not approved by CodeRabbit.ai."
echo "2) In the 'Add a comment' section at the bottom"
echo " of the PR web page, add a comment with the"
echo " statement below to restart a review"
echo ""
echo " @coderabbitai full review"
echo ""
exit 1
fi
56 changes: 56 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Development environment setup

## Prerequisites

You must have basic competence and experience in the following technologies to be able to set up and work within the development environment of talawa api:

1. Unix based operating systems like linux based distributions, macOS or windows subsystem for linux.
2. Git
3. Github
4. Docker
5. Docker compose
6. Visual studio code with devcontainers
7. Typescript
8. Node.js

## Our recommendations

Linux based distributions are simply the best platform for a very vast majority of use cases related to software development. As such we recommend using popular linux based distributions like fedora, arch, ubuntu, linux mint, debian etc., for having a better experience during software development.

We make heavy of use docker containers in our workflows. Since, containers are a technology built on top of linux, on non-linux platforms they can only be used by emulating linux where they are ran inside linux based virtual machines. So, you should be aware that there are performance penalties and certain limitations with running containers on platforms like macOS and windows.

Though, many of these penalties and limitations don't apply to windows subsystem for linux. So, if you plan on using windows, at the very least make use of windows subsystem for linux.

## Setup

We provide a mostly automated way of setting up the development environment for talawa api using git, docker and visual studio code as shown in the following video:

1. Click on the image to play the video
2. The video is partially incorrect. Clone from this repo instead
- https://github.com/PalisadoesFoundation/talawa-api

[![Talawa API Environment Setup - Development](https://img.youtube.com/vi/jz7koJIXqtk/0.jpg)](https://www.youtube.com/watch?v=jz7koJIXqtk)

It is very important that you go through [this](https://code.visualstudio.com/docs/devcontainers/containers) official documentation for working with devcontainers in visual studio code.

# Local production environment setup

Developers working on client applications making use of talawa api can set up and run a production build of talawa api on their systems locally.

## Prerequisites

You must have basic competence and experience in the following technologies to be able to set up and run the production build of talawa api locally on your system:

1. Git
2. Docker
3. Docker compose

## Setup

We provide a mostly automated way of running the production build of talawa api locally on your system using git, docker and docker compose as shown in the following video:

1. Click on the image to play the video
2. The video is partially incorrect. Clone from this repo instead
- https://github.com/PalisadoesFoundation/talawa-api

[![Talawa API Environment Setup - Production](https://img.youtube.com/vi/10Zi2srGPHM/0.jpg)](https://www.youtube.com/watch?v=10Zi2srGPHM)
Loading

0 comments on commit d4b7b98

Please sign in to comment.