Skip to content

Commit 758a7cb

Browse files
committed
feat: apply PR574 with auth flow fixes
1 parent c602ee0 commit 758a7cb

143 files changed

Lines changed: 32403 additions & 15709 deletions

File tree

Some content is hidden

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

.github/scripts/ciScript.js

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

.github/scripts/commentResults.js

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
webBuild,
13+
backendLintOutput,
14+
mobileLintOutput,
15+
}) => {
16+
const owner = context.repo.owner;
17+
const repo = context.repo.repo;
18+
const prNumber = context.payload.pull_request.number;
19+
20+
const status = (s) => {
21+
if (s === 'success') return 'PASS';
22+
if (s === 'failure') return 'FAIL';
23+
if (s === 'skipped') return 'SKIP';
24+
return '-';
25+
};
26+
27+
const lintDetails = (output) => {
28+
if (!output || !output.trim()) return '';
29+
return `\n<details>\n<summary>View lint errors</summary>\n\n\`\`\`\n${output.trim()}\n\`\`\`\n</details>`;
30+
};
31+
32+
const anyFailure = [backend, mobile, web].includes('failure');
33+
const title = anyFailure ? 'CI — Checks Failed' : 'CI — All Checks Passed';
34+
const timestamp = new Date().toUTCString();
35+
36+
const body = `## ${title}
37+
38+
### Backend — ${status(backend)}
39+
40+
| Check | Result |
41+
|---|---|
42+
| Lint | ${status(backendLint)} |
43+
| Test | ${status(backendTest)} |
44+
| Typecheck | ${status(backendTypecheck)} |
45+
${backendLint === 'failure' ? lintDetails(backendLintOutput) : ''}
46+
47+
### Mobile — ${status(mobile)}
48+
49+
| Check | Result |
50+
|---|---|
51+
| Lint | ${status(mobileLint)} |
52+
| Test | ${status(mobileTest)} |
53+
${mobileLint === 'failure' ? lintDetails(mobileLintOutput) : ''}
54+
55+
### Web — ${status(web)}
56+
57+
| Check | Result |
58+
|---|---|
59+
| Build | ${status(webBuild)} |
60+
61+
---
62+
Last updated: \`${timestamp}\``;
63+
64+
const COMMENT_MARKER = '## CI —';
65+
66+
try {
67+
const comments = await github.paginate(
68+
github.rest.issues.listComments,
69+
{
70+
owner,
71+
repo,
72+
issue_number: prNumber
73+
}
74+
);
75+
76+
const existing = comments.find(
77+
c => c.body && c.body.startsWith(COMMENT_MARKER)
78+
);
79+
80+
if (existing) {
81+
await github.rest.issues.updateComment({
82+
owner,
83+
repo,
84+
comment_id: existing.id,
85+
body
86+
});
87+
} else {
88+
await github.rest.issues.createComment({
89+
owner,
90+
repo,
91+
issue_number: prNumber,
92+
body
93+
});
94+
}
95+
} catch (err) {
96+
console.error(err);
97+
}
98+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = async ({ github, context }) => {
2+
const pr = context.payload.pull_request;
3+
const ignoreUsers = [
4+
'ShantKhatri',
5+
'Harxhit',
6+
'blankirigaya',
7+
];
8+
9+
try {
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 to the project.
30+
31+
To receive the appropriate GSSoC labels and recognition, please mention @Harxhit in the **#get-labels** channel on our Discord server and share your merged PR link.`,
32+
});
33+
34+
console.log(`Comment added to PR #${prNumber}`);
35+
} catch (error) {
36+
console.error(error);
37+
}
38+
};

.github/scripts/triageIssue.js

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
module.exports = async({github, context}) => {
2+
const owner = context.repo.owner;
3+
const repo = context.repo.repo;
4+
const issue = context.payload.issue;
5+
const issueNumber = issue.number;
6+
const issueDescription = issue.body;
7+
const username = issue.user.login
8+
9+
if(context.eventName === 'issues'){
10+
try {
11+
if(!issueDescription || !issueDescription.trim()){
12+
return await github.rest.issues.createComment({
13+
owner,
14+
repo,
15+
issue_number: issueNumber,
16+
body: `Hi @${username},
17+
18+
Thanks for opening this issue.
19+
20+
It looks like the issue description is currently missing.
21+
22+
Please provide:
23+
- A brief summary of the problem
24+
- Expected behavior
25+
- Actual behavior (if applicable)
26+
- Any relevant screenshots, logs, or context
27+
28+
This helps the team understand, prioritize, and route the issue correctly.
29+
30+
Thank you!
31+
32+
`
33+
})
34+
}
35+
36+
return await github.rest.issues.createComment({
37+
owner,
38+
repo,
39+
issue_number: issueNumber,
40+
body: `Hi @${username},
41+
42+
Thanks for opening this issue.
43+
44+
Please reply with one of the following areas so the issue can be routed to the appropriate team member:
45+
46+
- /backend
47+
- /web
48+
- /mobile
49+
- /devops
50+
51+
Once an area is selected, the corresponding label will be added automatically.`
52+
})
53+
54+
} catch (error) {
55+
console.error(error)
56+
}
57+
}else if(context.eventName === 'issue_comment'){
58+
if (context.payload.comment.user.type === 'Bot' || context.payload.comment.user.login === 'github-actions[bot]') {
59+
return;
60+
}
61+
62+
const comment = (context.payload.comment.body || '').trim().toLowerCase();
63+
const existingLabels = (issue.labels || []).map(label => label.name);
64+
65+
if (
66+
existingLabels.includes('backend') ||
67+
existingLabels.includes('web') ||
68+
existingLabels.includes('mobile') ||
69+
existingLabels.includes('devops')
70+
) {
71+
return;
72+
}
73+
74+
if (!['/backend', '/web', '/mobile', '/devops'].includes(comment)) {
75+
return;
76+
}
77+
if(comment === '/backend'){
78+
await github.rest.issues.addLabels({
79+
owner,
80+
repo,
81+
issue_number: issueNumber,
82+
labels: ['backend']
83+
84+
})
85+
return await github.rest.issues.createComment({
86+
owner,
87+
repo,
88+
issue_number: issueNumber,
89+
body: `The issue has been classified as **backend**.
90+
91+
@Harxhit, please review and triage this issue when available.
92+
93+
The **backend** label has been applied and the issue has been routed accordingly.`
94+
})
95+
}else if(comment === '/web'){
96+
await github.rest.issues.addLabels({
97+
owner,
98+
repo,
99+
issue_number: issueNumber,
100+
labels: ['web']
101+
102+
})
103+
return await github.rest.issues.createComment({
104+
owner,
105+
repo,
106+
issue_number: issueNumber,
107+
body: `The issue has been classified as **web**.
108+
109+
@ShantKhatri, please review and triage this issue when available.
110+
111+
The **web** label has been applied and the issue has been routed accordingly.`
112+
})
113+
}else if(comment === '/mobile'){
114+
await github.rest.issues.addLabels({
115+
owner,
116+
repo,
117+
issue_number: issueNumber,
118+
labels: ['mobile']
119+
120+
})
121+
return await github.rest.issues.createComment({
122+
owner,
123+
repo,
124+
issue_number: issueNumber,
125+
body: `The issue has been classified as **mobile**.
126+
127+
@blankirigaya, please review and triage this issue when available.
128+
129+
The **mobile** label has been applied and the issue has been routed accordingly.`
130+
})
131+
}else if(comment === '/devops'){
132+
await github.rest.issues.addLabels({
133+
owner,
134+
repo,
135+
issue_number: issueNumber,
136+
labels: ['devops']
137+
138+
})
139+
return await github.rest.issues.createComment({
140+
owner,
141+
repo,
142+
issue_number: issueNumber,
143+
body: `The issue has been classified as **devops**.
144+
145+
@ShantKhatri, please review and triage this issue when available.
146+
147+
The **devops** label has been applied and the issue has been routed accordingly.`
148+
})
149+
}
150+
}
151+
}

0 commit comments

Comments
 (0)