Skip to content

Commit 730c935

Browse files
authored
Merge branch 'develop-postgres' into setup_script
2 parents bb5de4c + 792e6ee commit 730c935

File tree

12 files changed

+894
-97
lines changed

12 files changed

+894
-97
lines changed

.github/workflows/pull-request-target.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Add the PR Review Policy
2222
uses: thollander/actions-comment-pull-request@v3
2323
with:
24-
comment_tag: pr_review_policy
24+
comment-tag: pr_review_policy
2525
message: |
2626
## Our Pull Request Approval Process
2727

.github/workflows/pull-request.yml

+10-21
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ jobs:
4848
echo "Error: Close this PR and try again."
4949
exit 1
5050
51-
check_biome_ignore:
52-
name: Check for biome_ignore
51+
python_checks:
52+
name: Run Python Checks
5353
runs-on: ubuntu-latest
5454
steps:
5555
- name: Checkout code
@@ -64,30 +64,19 @@ jobs:
6464
with:
6565
python-version: 3.9
6666

67-
- name: Run Python script
67+
- name: Run Biome Ignore Check
6868
run: |
6969
python .github/workflows/scripts/biome_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
7070
71-
check_code_coverage_disable:
72-
name: Check for code coverage disable
73-
runs-on: ubuntu-latest
74-
steps:
75-
- name: Checkout code
76-
uses: actions/checkout@v4
77-
78-
- name: Get changed files
79-
id: changed-files
80-
uses: tj-actions/changed-files@v45
8171
82-
- name: Set up Python
83-
uses: actions/setup-python@v5
84-
with:
85-
python-version: 3.9
86-
87-
- name: Run Python script
72+
- name: Run Code Coverage Disable Check
8873
run: |
8974
python .github/workflows/scripts/code_coverage_disable_check.py --files ${{ steps.changed-files.outputs.all_changed_files }}
9075
76+
- name: Run TS Ignore Check
77+
run: |
78+
python .github/workflows/scripts/detect_ts_ignore.py --files ${{ steps.changed-files.outputs.all_changed_files }}
79+
9180
check_gql_tada:
9281
name: Check gql tada files and configuration
9382
runs-on: ubuntu-latest
@@ -195,7 +184,7 @@ jobs:
195184
Run-Tests:
196185
name: Run tests for talawa api
197186
runs-on: ubuntu-latest
198-
needs: [Code-Quality-Checks, check_code_coverage_disable]
187+
needs: [Code-Quality-Checks, python_checks]
199188
env:
200189
CODECOV_UNIQUE_NAME: ${{github.workflow}}-${{github.ref_name}}
201190
steps:
@@ -223,7 +212,7 @@ jobs:
223212
uses: VeryGoodOpenSource/very_good_coverage@v2
224213
with:
225214
path: "./coverage/lcov.info"
226-
min_coverage: 45.0
215+
min_coverage: 48.6
227216

228217
Test-Docusaurus-Deployment:
229218
name: Test Deployment to https://docs-api.talawa.io
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env python3
2+
"""Script to detect and report usage of @ts-ignore comments in TypeScript."""
3+
4+
import argparse
5+
import re
6+
import sys
7+
import logging
8+
9+
# Configure logging
10+
logging.basicConfig(
11+
level=logging.INFO,
12+
format="%(levelname)s: %(message)s",
13+
)
14+
15+
TS_IGNORE_PATTERN = r"(?://|/\*)\s*@ts-ignore(?:\s+|$)"
16+
17+
18+
def check_ts_ignore(files: list[str]) -> int:
19+
"""Check for occurrences of '@ts-ignore' in the given files.
20+
21+
Args:
22+
files (list[str]): List of file paths to check.
23+
24+
Returns:
25+
int: 0 if no violations, 1 if violations are found.
26+
"""
27+
ts_ignore_found = False
28+
29+
for file in files:
30+
try:
31+
logging.info("Checking file: %s", file)
32+
with open(file, encoding="utf-8") as f:
33+
for line_num, line in enumerate(f, start=1):
34+
# Handle more variations of @ts-ignore
35+
if re.search(
36+
TS_IGNORE_PATTERN,
37+
line.strip(),
38+
):
39+
print(
40+
"❌ Error: '@ts-ignore' found in %s at line %d",
41+
file,
42+
line_num,
43+
)
44+
logging.debug(
45+
"Found @ts-ignore in line: %s",
46+
line.strip(),
47+
)
48+
ts_ignore_found = True
49+
except FileNotFoundError:
50+
logging.warning("File not found: %s", file)
51+
except OSError:
52+
logging.exception("Could not read %s", file)
53+
if not ts_ignore_found:
54+
print("✅ No '@ts-ignore' comments found in the files.")
55+
56+
return 1 if ts_ignore_found else 0
57+
58+
59+
def main() -> None:
60+
"""Main function to parse arguments and run the check.
61+
62+
This function sets up argument parsing for file paths and runs the ts-ignore
63+
check on the specified files.
64+
65+
Args:
66+
None
67+
68+
Returns:
69+
None: The function exits the program with status code 0 if no ts-ignore
70+
comments are found, or 1 if any are detected.
71+
"""
72+
parser = argparse.ArgumentParser(
73+
description="Check for @ts-ignore in changed files.",
74+
)
75+
parser.add_argument(
76+
"--files",
77+
nargs="+",
78+
help="List of changed files",
79+
required=True,
80+
)
81+
args = parser.parse_args()
82+
83+
# Filter TypeScript files
84+
ts_files = [f for f in args.files if f.endswith((".ts", ".tsx"))]
85+
if not ts_files:
86+
logging.info("No TypeScript files to check.")
87+
sys.exit(0)
88+
89+
exit_code = check_ts_ignore(args.files)
90+
sys.exit(exit_code)
91+
92+
93+
if __name__ == "__main__":
94+
main()

docs/docs/docs/developer-resources/testing.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ This section covers how to access the GraphQL API interface.
6161

6262
#### Interactive Web Queries With GraphiQL
6363

64-
The url for accessing the GraphQL Playground is
64+
You can use GraphiQL to test your GraphQL queries interactively via a web page.
65+
66+
The url for accessing the GraphQL Playground is:
6567

6668
```bash
6769
http://127.0.0.1:4000/graphiql
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,100 @@
11
---
22
id: troubleshooting
3-
title: Operation
3+
title: Troubleshooting
44
slug: /developer-resources/troubleshooting
55
sidebar_position: 5
66
---
77

88
## Introduction
99

10-
Coming soon.
10+
This page provides basic troubleshooting steps for the applications.
11+
12+
## Docker
13+
14+
When running the application using docker it may seem difficult at first to troubleshoot failures. This section covers some basic troubleshooting strategies.
15+
16+
### Status Validation
17+
18+
You can get a summary of all the running docker containers using the `docker ps` command.
19+
20+
It will provide this information under these headings:
21+
22+
1. **CONTAINER ID**: Container IDs
23+
1. **IMAGE**: Image names on which the containers are based
24+
1. **COMMAND**: The command that created the containers
25+
1. **CREATED**: The time of containers
26+
1. **STATUS**: Whether or not the containers are healthy
27+
1. **PORTS**: The exposed ports they use
28+
1. **NAMES**: The names of the running containers
29+
30+
Here is an example:
31+
32+
```
33+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
34+
3a6743b03029 docker-app "docker-entrypoint.s…" 42 minutes ago Up 41 minutes 0.0.0.0:4321->4321/tcp docker-app-1
35+
f86a9f480819 talawa-api-dev "/bin/bash /init-dat…" 42 minutes ago Up 42 minutes 0.0.0.0:4000->4000/tcp talawa-api-dev
36+
83ae5ff56a3f redis:8.0 "docker-entrypoint.s…" 42 minutes ago Up 42 minutes 0.0.0.0:6379->6379/tcp talawa-api-redis
37+
44c8a0f38b04 minio/minio "/usr/bin/docker-ent…" 42 minutes ago Up 42 minutes 0.0.0.0:9000->9001/tcp talawa-api-minio-1
38+
3a9deccdb68e caddy/caddy:2.9 "caddy run --config …" 42 minutes ago Up 42 minutes 0.0.0.0:9080->9080/tcp caddy-service
39+
132dacf0aff4 mongo "/bin/bash /init-mon…" 42 minutes ago Up 42 minutes 0.0.0.0:27017->27017/tcp mongo
40+
```
41+
42+
You can get information on each of the headings by using filters like this:
43+
44+
1. CONTAINER ID: `docker ps --format '{{.ID}}'`
45+
1. IMAGE: `docker ps --format '{{.Names}}'`
46+
1. COMMAND: `docker ps --format '{{.Command}}'`
47+
1. CREATED: `docker ps --format '{{.RunningFor}}'`
48+
1. STATUS: `docker ps --format '{{.Status}}'`
49+
1. PORTS: `docker ps --format '{{.Ports}}'`
50+
1. NAMES: `docker ps --format '{{.Names}}'`
51+
52+
### Accessing The Container CLI
53+
54+
You can access the CLI of each container using the docker interactive TTY mode flags `-it`.
55+
56+
Here is an example accessing the `/bin/bash` CLI of the `talawa-api-dev` container:
57+
58+
```bash
59+
$ docker exec -it talawa-api-dev /bin/bash
60+
root@f86a9f480819:/usr/src/app# ls
61+
CODEOWNERS Caddyfile Dockerfile.prod
62+
CODE_OF_CONDUCT.md DOCUMENTATION.md INSTALLATION.md
63+
CONTRIBUTING.md Dockerfile.dev ISSUE_GUIDELINES.md
64+
root@f86a9f480819:/usr/src/app# exit
65+
$
66+
```
67+
68+
Here is an example accessing the `/bin/mongosh` CLI of the `mongo` container:
69+
70+
```bash
71+
$ docker exec -it mongo /bin/mongosh
72+
...
73+
...
74+
...
75+
rs0 [direct: primary] test> show databases
76+
admin 80.00 KiB
77+
config 356.00 KiB
78+
local 1.92 MiB
79+
talawa-api 2.49 MiB
80+
rs0 [direct: primary] test> exit
81+
$
82+
```
83+
84+
### Viewing Container Logs
85+
86+
You can view the container logs in real time by using the `docker logs -f` command. The output will update dynamically as you run the app.
87+
88+
In this case we see the logs of the `mongo` container. The `-n 10` flag makes the output start with the most recent 10 rows of logs which makes the output less verbose.
89+
90+
```bash
91+
$ docker logs -f mongo -n 10
92+
```
93+
94+
```
95+
mongosh","version":"6.12.0|2.3.8"},"platform":"Node.js v20.18.1, LE","os":{"name":"linux","architecture":"x64","version":"3.10.0-327.22.2.el7.x86_64","type":"Linux"},"env":{"container":{"runtime":"docker"}}}}}
96+
{"t":{"$date":"2025-02-22T01:14:08.038+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn2194","msg":"client metadata","attr":{"remote":"127.0.0.1:36844","client":"conn2194","negotiatedCompressors":[],"doc":{"application":{"name":"mongosh 2.3.8"},"driver":{"name":"nodejs|mongosh","version":"6.12.0|2.3.8"},"platform":"Node.js v20.18.1, LE","os":{"name":"linux","architecture":"x64","version":"3.10.0-327.22.2.el7.x86_64","type":"Linux"},"env":{"container":{"runtime":"docker"}}}}}
97+
{"t":{"$date":"2025-02-22T01:14:08.040+00:00"},"s":"I", "c":"NETWORK", "id":6788700, "ctx":"conn2193","msg":"Received first command on ingress connection since session start or auth handshake","attr":{"elapsedMillis":2}}
98+
{"t":{"$date":"2025-02-22T01:14:08.040+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:36848","uuid":{"uuid":{"$uuid":"1ef5fcbd-4913-45fe-bc66-7bc3600a941a"}},"connectionId":2195,"connectionCount":24}}
99+
{"t":{"$date":"2025-02-22T01:14:08.043+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:36854","uuid":{"uuid":{"$uuid":"48522796-7b00-46df-a5d1-3e2a9ec7edd8"}},"connectionId":2196,"connectionCount":25}}
100+
```

lefthook.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@ pre-commit:
3030
pnpm fix_code_quality
3131
git add {staged_files}
3232
8_check_type_errors:
33-
run: pnpm check_type_errors
34-
piped: true
33+
run: pnpm check_type_errors
34+
9_check_tests:
35+
run: |
36+
set -e
37+
pnpm check_tests
38+
piped: true

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"push_drizzle_schema": "drizzle-kit push",
9393
"push_drizzle_test_schema": "drizzle-kit push --config=./test/drizzle.config.ts",
9494
"run_tests": "vitest --coverage",
95+
"check_tests": "vitest run",
9596
"start_development_server": "tsx watch ./src/index.ts",
9697
"start_development_server_with_debugger": "tsx watch --inspect=${API_DEBUGGER_HOST:-127.0.0.1}:${API_DEBUGGER_PORT:-9229} ./src/index.ts",
9798
"start_production_server": "pnpm build_production && node ./dist/index.js",

0 commit comments

Comments
 (0)