Skip to content

Commit

Permalink
resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Suyash878 committed Feb 24, 2025
2 parents 2f5ed8e + 2438e61 commit dcefc58
Show file tree
Hide file tree
Showing 52 changed files with 6,400 additions and 936 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Add the PR Review Policy
uses: thollander/actions-comment-pull-request@v3
with:
comment_tag: pr_review_policy
comment-tag: pr_review_policy
message: |
## Our Pull Request Approval Process
Expand Down
33 changes: 12 additions & 21 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_biome_ignore:
name: Check for biome_ignore
python_checks:
name: Run Python Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -64,30 +64,19 @@ jobs:
with:
python-version: 3.9

- name: Run Python script
- name: Run Biome Ignore Check
run: |
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
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Run Python script
- name: Run Code Coverage Disable Check
run: |
python .github/workflows/scripts/code_coverage_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
- name: Run TS Ignore Check
run: |
python .github/workflows/scripts/detect_ts_ignore.py --files ${{ steps.changed-files.outputs.all_changed_files }}
check_gql_tada:
name: Check gql tada files and configuration
runs-on: ubuntu-latest
Expand Down Expand Up @@ -167,6 +156,8 @@ jobs:
docs/docusaurus.config.ts
docs/sidebar*
setup.ts
src/graphql/types/Mutation/**
src/graphql/types/Query/**
tsconfig.build.json
vite.config.mts
CNAME
Expand All @@ -193,7 +184,7 @@ jobs:
Run-Tests:
name: Run tests for talawa api
runs-on: ubuntu-latest
needs: [Code-Quality-Checks, check_code_coverage_disable]
needs: [Code-Quality-Checks, python_checks]
env:
CODECOV_UNIQUE_NAME: ${{github.workflow}}-${{github.ref_name}}
steps:
Expand Down Expand Up @@ -221,7 +212,7 @@ jobs:
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: "./coverage/lcov.info"
min_coverage: 45.0
min_coverage: 48.6

Test-Docusaurus-Deployment:
name: Test Deployment to https://docs-api.talawa.io
Expand Down
134 changes: 134 additions & 0 deletions .github/workflows/scripts/detect_ts_ignore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env python3
"""Script to detect and report usage of @ts-ignore comments in TypeScript."""

import argparse
import re
import sys
import logging
import os

# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s: %(message)s",
)

TS_IGNORE_PATTERN = r"(?://|/\*)\s*@ts-ignore(?:\s+|$)"

IGNORED_EXTENSIONS = {
# Image formats
".avif",
".jpeg",
".jpg",
".png",
".webp",
".gif",
".bmp",
".ico",
".svg",
# Video formats
".mp4",
".webm",
".mov",
".avi",
".mkv",
# Audio formats
".mp3",
".wav",
".ogg",
# Document formats
".pdf",
".doc",
".docx",
}


def is_binary_file(filepath: str) -> bool:
"""Check if a file is binary based on its extension.
Args:
filepath (str): The file path.
Returns:
bool: True if the file should be ignored, False otherwise.
"""
return os.path.splitext(filepath)[1].lower() in IGNORED_EXTENSIONS


def check_ts_ignore(files: list[str]) -> int:
"""Check for occurrences of '@ts-ignore' in the given files.
Args:
files (list[str]): List of file paths to check.
Returns:
int: 0 if no violations, 1 if violations are found.
"""
ts_ignore_found = False

for file in files:
if not is_binary_file(file):
try:
logging.info("Checking file: %s", file)
with open(file, encoding="utf-8") as f:
for line_num, line in enumerate(f, start=1):
# Handle more variations of @ts-ignore
if re.search(
TS_IGNORE_PATTERN,
line.strip(),
):
print(
f"❌ Error: '@ts-ignore' found in {file} ",
f"at line {line_num}",
)
logging.debug(
"Found @ts-ignore in line: %s",
line.strip(),
)
ts_ignore_found = True
except FileNotFoundError:
logging.warning("File not found: %s", file)
except OSError:
logging.exception("Could not read %s", file)
if not ts_ignore_found:
print("✅ No '@ts-ignore' comments found in the files.")

return 1 if ts_ignore_found else 0


def main() -> None:
"""Main function to parse arguments and run the check.
This function sets up argument parsing for file paths and runs the ts-ignore
check on the specified files.
Args:
None
Returns:
None: The function exits the program with status code 0 if no ts-ignore
comments are found, or 1 if any are detected.
"""
parser = argparse.ArgumentParser(
description="Check for @ts-ignore in changed files.",
)
parser.add_argument(
"--files",
nargs="+",
help="List of changed files",
required=True,
)
args = parser.parse_args()

# Filter TypeScript files
ts_files = [f for f in args.files if f.endswith((".ts", ".tsx"))]
if not ts_files:
logging.info("No TypeScript files to check.")
sys.exit(0)

exit_code = check_ts_ignore(args.files)
sys.exit(exit_code)


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions docs/docs/docs/developer-resources/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ sidebar_position: 1

Welcome to the Talawa-API developer resources.

## Design Philosophy

Coming Soon

### Authentication

We have kept the authentication system very minimal so that a proper authentication system can be put in place later on. We feel that some kind of typescript based authentication library that can integrate with the current database schema or a self hosted service with its own database is needed.

For this reason, the authentication system needs to be detached from the GraphQL schema and be handled using REST APIs using something like Better Auth: https://github.com/better-auth/better-auth

## Important Directories

Review these important locations before you start your coding journey.
Expand Down
Loading

0 comments on commit dcefc58

Please sign in to comment.