Skip to content

Commit 91e43e0

Browse files
Merge branch 'main' into anika00mangla-issue256
Signed-off-by: Anika Mangla <anikamanglaavbil@gmail.com>
2 parents 2e042c9 + 4ebb949 commit 91e43e0

44 files changed

Lines changed: 5055 additions & 4602 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ DATABASE_URL=postgresql://devcard:devcard@localhost:5432/devcard?schema=public
44
# ─── Redis ───
55
REDIS_URL=redis://localhost:6379
66

7+
# ─── Set The Url ───
8+
PUBLIC_APP_URL=
9+
710
# ─── JWT ───
811
# JWT_SECRET: any long random string, minimum 32 characters
912
# Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

.github/scripts/ciScript.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
module.exports = async ({ github, context, core }) => {
2+
const owner = context.repo.owner;
3+
const repo = context.repo.repo;
4+
const pr = context.payload.pull_request;
5+
const prNumber = pr.number;
6+
const prState = pr.state;
7+
8+
const backendFiles = [];
9+
const backendTests = [];
10+
const mobileFiles = [];
11+
const webFiles = [];
12+
13+
try {
14+
if (prState === 'closed') {
15+
console.log(`PR state is: ${prState}`);
16+
return {
17+
backendChanged: false,
18+
mobileChanged: false,
19+
webChanged: false
20+
};
21+
}
22+
23+
const changedFiles = await github.paginate(
24+
github.rest.pulls.listFiles,
25+
{
26+
owner,
27+
repo,
28+
pull_number: prNumber
29+
}
30+
);
31+
32+
changedFiles.forEach((file) => {
33+
const fileName = file.filename;
34+
35+
if (fileName.startsWith('apps/backend/')) {
36+
backendFiles.push(fileName);
37+
38+
const relative = fileName.replace('apps/backend/src/', '');
39+
const baseName = relative
40+
.split('/')
41+
.pop()
42+
?.replace(/\.(ts|tsx|js|jsx)$/, '');
43+
44+
if (baseName) {
45+
backendTests.push(`src/__tests__/${baseName}.test.ts`);
46+
}
47+
48+
} else if (fileName.startsWith('apps/mobile/')) {
49+
mobileFiles.push(fileName);
50+
} else if (fileName.startsWith('apps/web/')) {
51+
webFiles.push(fileName);
52+
}
53+
});
54+
55+
console.log({
56+
backendFiles,
57+
backendTests,
58+
mobileFiles,
59+
webFiles,
60+
});
61+
62+
core.setOutput(
63+
"backendFiles",
64+
backendFiles
65+
.map(file => file.replace("apps/backend/", ""))
66+
.join(" ")
67+
);
68+
69+
core.setOutput(
70+
"backendTests",
71+
[...new Set(backendTests)].join(" ")
72+
);
73+
74+
core.setOutput(
75+
"mobileFiles",
76+
mobileFiles
77+
.map(file => file.replace("apps/mobile/", ""))
78+
.join(" ")
79+
);
80+
81+
core.setOutput(
82+
"webFiles",
83+
webFiles
84+
.map(file => file.replace("apps/web/", ""))
85+
.join(" ")
86+
);
87+
88+
core.setOutput("backendChanged", backendFiles.length > 0);
89+
core.setOutput("mobileChanged", mobileFiles.length > 0);
90+
core.setOutput("webChanged", webFiles.length > 0);
91+
92+
} catch (error) {
93+
console.error(error);
94+
95+
return {
96+
backendChanged: false,
97+
mobileChanged: false,
98+
webChanged: false
99+
};
100+
}
101+
};

.github/scripts/commentResults.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
module.exports = async ({
2+
github,
3+
context,
4+
backend,
5+
mobile,
6+
web,
7+
backendLint,
8+
backendTest,
9+
backendTypecheck,
10+
mobileLint,
11+
mobileTest,
12+
webCheck,
13+
webBuild
14+
}) => {
15+
const owner = context.repo.owner;
16+
const repo = context.repo.repo;
17+
const prNumber = context.payload.pull_request.number;
18+
19+
const emoji = (status) => {
20+
if (status === 'success') return '✅';
21+
if (status === 'failure') return '❌';
22+
if (status === 'skipped') return '⏭️';
23+
return '⚪';
24+
};
25+
26+
const label = (status) => {
27+
if (!status) return '⚪ unknown';
28+
return `${emoji(status)} ${status}`;
29+
};
30+
31+
const anyFailure = [
32+
backend,
33+
mobile,
34+
web
35+
].includes('failure');
36+
37+
const title = anyFailure
38+
? '❌ Some checks failed'
39+
: '✅ CI completed';
40+
41+
const timestamp = new Date().toUTCString();
42+
43+
const body = `## CI Results — ${title}
44+
45+
### 🖥️ Backend (${label(backend)})
46+
| Check | Status |
47+
|---|---|
48+
| Lint | ${label(backendLint)} |
49+
| Test | ${label(backendTest)} |
50+
| Typecheck | ${label(backendTypecheck)} |
51+
52+
### 📱 Mobile (${label(mobile)})
53+
| Check | Status |
54+
|---|---|
55+
| Lint | ${label(mobileLint)} |
56+
| Test | ${label(mobileTest)} |
57+
58+
### 🌐 Web (${label(web)})
59+
| Check | Status |
60+
|---|---|
61+
| Check | ${label(webCheck)} |
62+
| Build | ${label(webBuild)} |
63+
64+
---
65+
🕐 Last updated: \`${timestamp}\``;
66+
67+
const COMMENT_MARKER = '## CI Results —';
68+
69+
try {
70+
const comments = await github.paginate(
71+
github.rest.issues.listComments,
72+
{
73+
owner,
74+
repo,
75+
issue_number: prNumber
76+
}
77+
);
78+
79+
const existing = comments.find(
80+
c => c.body && c.body.startsWith(COMMENT_MARKER)
81+
);
82+
83+
if (existing) {
84+
await github.rest.issues.updateComment({
85+
owner,
86+
repo,
87+
comment_id: existing.id,
88+
body
89+
});
90+
} else {
91+
await github.rest.issues.createComment({
92+
owner,
93+
repo,
94+
issue_number: prNumber,
95+
body
96+
});
97+
}
98+
} catch (err) {
99+
console.error(err);
100+
}
101+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = async ({ github, context }) => {
2+
const pr = context.payload.pull_request;
3+
const ignoreUsers = [
4+
'ShantKhatri',
5+
'Harxhit',
6+
'blankirigaya'
7+
]
8+
try {
9+
// Only continue if merged
10+
if (!pr || !pr.merged) {
11+
console.log('PR not merged.');
12+
return;
13+
}
14+
15+
const prNumber = pr.number;
16+
const contributor = pr.user.login;
17+
18+
if(ignoreUsers.includes(contributor)){
19+
console.log(`Ignoring PR #${prNumber} by ${contributor}`);
20+
return;
21+
}
22+
23+
await github.rest.issues.createComment({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
issue_number: prNumber,
27+
body: `Congratulations @${contributor} on getting PR #${prNumber} merged!
28+
29+
Thank you for your contribution. Please mention @Harxhit in our Discord server to receive the appropriate GSSoC labels and recognition.
30+
`
31+
});
32+
33+
console.log(`Comment added to PR #${prNumber}`);
34+
} catch (error) {
35+
console.error(error)
36+
}
37+
};

.github/scripts/unassignIssues.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ module.exports = async ({ github, context }) => {
44

55
const PROTECTED_ASSIGNEES = [
66
'ShantKhatri',
7-
'Harxhit'
7+
'Harxhit',
8+
'blankirigaya'
89
];
910

1011
// Fetch all open issues (excluding PRs)

.github/scripts/welcomeScript.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,34 @@ module.exports = async ({ github, context }) => {
1111

1212
if (
1313
eventName === 'issues' &&
14-
issueAssociation === 'FIRST_TIMER'
14+
issueAssociation === 'NONE'
1515
) {
16-
return await github.rest.issues.createComment({
16+
// Verify this is truly their first issue (listForRepo returns PRs too)
17+
const userIssues = await github.rest.issues.listForRepo({
1718
owner,
1819
repo,
19-
issue_number: issueNumber,
20-
body: `👋 Thanks for opening your first issue, @${ghUsername}!
20+
state: 'all',
21+
creator: ghUsername,
22+
per_page: 10
23+
});
24+
25+
const actualIssues = userIssues.data.filter(issue => !issue.pull_request);
26+
27+
if (actualIssues.length === 1) {
28+
return await github.rest.issues.createComment({
29+
owner,
30+
repo,
31+
issue_number: issueNumber,
32+
body: `👋 Thanks for opening your first issue, @${ghUsername}!
2133
2234
We appreciate your contribution and are excited to have you here. Please make sure to follow the contribution guidelines and provide as much detail as possible.
2335
2436
To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community:
2537
https://discord.gg/QueQN83wn
2638
2739
Looking forward to collaborating with you!`
28-
});
40+
});
41+
}
2942
}
3043

3144
const prAssociation =

0 commit comments

Comments
 (0)