Skip to content

Commit

Permalink
Merge with Develop 20240924 (PalisadoesFoundation#2554)
Browse files Browse the repository at this point in the history
* 20240929102658 Deleted all files in the main branch in anticipation of merging develop into main cleanly

* 20240929103244 Merge develop into main

---------

Co-authored-by: Peter Harrison <[email protected]>
  • Loading branch information
palisadoes and Peter Harrison authored Sep 29, 2024
1 parent 4215ea5 commit 96d609b
Show file tree
Hide file tree
Showing 193 changed files with 5,554 additions and 2,919 deletions.
1 change: 1 addition & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ reviews:
drafts: false
base_branches:
- develop
- main
chat:
auto_reply: true
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
videos
images
data
.env
.git
.gitignore
Expand Down
18 changes: 18 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ REDIS_HOST=
REDIS_PORT=
REDIS_PASSWORD=

# These environment variables are used to provide MinIo credentials

# The endpoint URL for MinIO server, specifying where the MinIO service is hosted
MINIO_ENDPOINT=

# The username with root-level access for MinIO administration
MINIO_ROOT_USER=

# The password corresponding to the MINIO_ROOT_USER for authentication
MINIO_ROOT_PASSWORD=

# The default bucket name to use with MinIO for storing data
MINIO_BUCKET=

# The local directory where MinIO stores its data files
MINIO_DATA_DIR=


# this environment variable is for setting the environment variable for Image Upload size

IMAGE_SIZE_LIMIT_KB=3000
9 changes: 4 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error",

// Interfaces must begin with Interface or TestInterface followed by a PascalCase name
"@typescript-eslint/naming-convention": [
"error",
Expand Down Expand Up @@ -80,7 +79,7 @@
"plugins": ["@graphql-eslint"]
},
{
"files": ["tests/**/*"],
"files": ["tests/**/*", "setup.ts"],
"rules": {
"no-restricted-imports": "off"
}
Expand All @@ -107,13 +106,13 @@
],
// restrict the use of same package in multiple import statements
"import/no-duplicates": "error",

// warn/1, error/2, off/0
"tsdoc/syntax": "error",

// Typescript Rules
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
Expand Down
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ If applicable, add screenshots to help explain your problem.
Add any other context or screenshots about the feature request here.

**Potential internship candidates**
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359

Please read this if you are planning to apply for a Palisadoes Foundation internship
- https://github.com/PalisadoesFoundation/talawa/issues/359
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ A clear and concise description of approach to be followed.
Add any other context or screenshots about the feature request here.

**Potential internship candidates**
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359

Please read this if you are planning to apply for a Palisadoes Foundation internship
- https://github.com/PalisadoesFoundation/talawa/issues/359
80 changes: 80 additions & 0 deletions .github/workflows/check-tsdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const fs = require('fs');
const path = require('path');

// List of files to skip
const filesToSkip = [
"app.ts",
"index.ts",
"constants.ts",
"db.ts",
"env.ts",
"logger.ts",
"getSort.ts",
// Add more files to skip as needed
];

// List of directories to skip
const dirsToSkip = [
"typeDefs",
"services",

// Add more directories to skip as needed
];

// Recursively find all .tsx files, excluding files listed in filesToSkip and directories in dirsToSkip
function findTsxFiles(dir) {
let results = [];
try {
const list = fs.readdirSync(dir);
list.forEach((file) => {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);
if (stat && stat.isDirectory()) {
// Skip directories in dirsToSkip
if (!dirsToSkip.includes(path.basename(filePath))) {
results = results.concat(findTsxFiles(filePath));
}
} else if (
filePath.endsWith('.ts') &&
!filePath.endsWith('.spec.ts') &&
!filesToSkip.includes(path.relative(dir, filePath))
) {
results.push(filePath);
}
});
} catch (err) {
console.error(`Error reading directory ${dir}: ${err.message}`);
}
return results;
}

// Check if a file contains at least one TSDoc comment
function containsTsDocComment(filePath) {
try {
const content = fs.readFileSync(filePath, 'utf8');
return /\/\*\*[\s\S]*?\*\//.test(content);
} catch (err) {
console.error(`Error reading file ${filePath}: ${err.message}`);
return false;
}
}

// Main function to run the validation
function run() {
const dir = process.argv[2] || './src'; // Allow directory path as a command-line argument
const files = findTsxFiles(dir);
let allValid = true;

files.forEach((file) => {
if (!containsTsDocComment(file)) {
console.error(`No TSDoc comment found in file: ${file}`);
allValid = false;
}
});

if (!allValid) {
process.exit(1);
}
}

run();
123 changes: 123 additions & 0 deletions .github/workflows/eslint_disable_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""ESLint Checker Script.
Methodology:
Recursively analyzes TypeScript files in the 'src' directory and its subdirectories
as well as 'setup.ts' files to ensure they do not contain eslint-disable statements.
This script enforces code quality practices in the project.
NOTE:
This script complies with our python3 coding and documentation standards.
It complies with:
1) Pylint
2) Pydocstyle
3) Pycodestyle
4) Flake8
"""

import os
import re
import argparse
import sys

def has_eslint_disable(file_path):
"""
Check if a TypeScript file contains eslint-disable statements.
Args:
file_path (str): Path to the TypeScript file.
Returns:
bool: True if eslint-disable statement is found, False otherwise.
"""
eslint_disable_pattern = re.compile(r'//\s*eslint-disable(?:-next-line|-line)?', re.IGNORECASE)

try:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
return bool(eslint_disable_pattern.search(content))
except Exception as e:
print(f"Error reading file {file_path}: {e}")
return False

def check_eslint(directory):
"""
Recursively check TypeScript files for eslint-disable statements in the 'src' directory.
Args:
directory (str): Path to the directory.
Returns:
list: List of files containing eslint-disable statements.
"""
eslint_issues = []

src_dir = os.path.join(directory, 'src')

if not os.path.exists(src_dir):
print(f"Source directory '{src_dir}' does not exist.")
return eslint_issues

for root, dirs, files in os.walk(src_dir):
for file_name in files:
if file_name.endswith('.tsx') and not file_name.endswith('.test.tsx'):
file_path = os.path.join(root, file_name)
if has_eslint_disable(file_path):
eslint_issues.append(f'File {file_path} contains eslint-disable statement.')

setup_path = os.path.join(directory, 'setup.ts')
if os.path.exists(setup_path) and has_eslint_disable(setup_path):
eslint_issues.append(f'Setup file {setup_path} contains eslint-disable statement.')

return eslint_issues

def arg_parser_resolver():
"""Resolve the CLI arguments provided by the user."""
parser = argparse.ArgumentParser()
parser.add_argument(
"--directory",
type=str,
default=os.getcwd(),
help="Path to the directory to check (default: current directory)"
)
return parser.parse_args()

def main():
"""
Execute the script's main functionality.
This function serves as the entry point for the script. It performs
the following tasks:
1. Validates and retrieves the directory to check from
command line arguments.
2. Recursively checks TypeScript files for eslint-disable statements.
3. Provides informative messages based on the analysis.
4. Exits with an error if eslint-disable statements are found.
Raises:
SystemExit: If an error occurs during execution.
"""
args = arg_parser_resolver()
if not os.path.exists(args.directory):
print(f"Error: The specified directory '{args.directory}' does not exist.")
sys.exit(1)

eslint_issues = check_eslint(args.directory)

if eslint_issues:
for issue in eslint_issues:
print(issue)
print("ESLint-disable check failed. Exiting with error.")
sys.exit(1)

print("ESLint-disable check completed successfully.")
sys.exit(0)

if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion .github/workflows/md_mdx_format_adjuster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
3) Pycodestyle
4) Flake8
"""

import os
import argparse
import re
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: Count number of lines
run: |
chmod +x ./.github/workflows/countline.py
./.github/workflows/countline.py --lines 600 --exclude_files src/types/generatedGraphQLTypes.ts tests src/typeDefs/types.ts src/constants.ts
- name: Check for TSDoc comments
run: npm run check-tsdoc # Run the TSDoc check script

- name: Restore node_modules from cache
id: cache-npm
uses: actions/cache@v4
Expand Down Expand Up @@ -71,7 +74,7 @@ jobs:
if: steps.changed_files.outputs.any_changed == 'true'
env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
run: npx eslint ${CHANGED_FILES}
run: npx eslint ${CHANGED_FILES} --max-warnings=1500 && python .github/workflows/eslint_disable_check.py

- name: Check for formatting errors
run: npm run format:check
Expand Down Expand Up @@ -171,7 +174,7 @@ jobs:
needs: [Code-Quality-Checks]
strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
services:
mongo:
image: mongo:4.4
Expand Down Expand Up @@ -216,7 +219,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: Generate Access Token Secret
run: echo "ACCESS_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
Expand Down
Loading

0 comments on commit 96d609b

Please sign in to comment.