Skip to content

Commit aa2f35b

Browse files
authored
Merge branch 'main' into fix/mobile-auth-persistence
Signed-off-by: dinesh <midoriya54378@gmail.com>
2 parents 98a48df + 4071cbc commit aa2f35b

140 files changed

Lines changed: 34280 additions & 17714 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.

.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: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
module.exports = async ({ github, context, core }) => {
17+
const owner = context.repo.owner;
18+
const repo = context.repo.repo;
19+
const pr = context.payload.pull_request;
20+
const prNumber = pr.number;
21+
const prState = pr.state;
22+
23+
const backendFiles = [];
24+
const mobileFiles = [];
25+
const webFiles = [];
26+
27+
try {
28+
if (prState === 'closed') {
29+
console.log(`PR state is: ${prState}`);
30+
return {
31+
backendChanged: false,
32+
mobileChanged: false,
33+
webChanged: false
34+
};
35+
}
36+
37+
const changedFiles = await github.paginate(
38+
github.rest.pulls.listFiles,
39+
{
40+
owner,
41+
repo,
42+
pull_number: prNumber
43+
}
44+
);
45+
46+
changedFiles.forEach((file) => {
47+
const fileName = file.filename;
48+
49+
if (fileName.startsWith('apps/backend/')) {
50+
backendFiles.push(fileName);
51+
} else if (fileName.startsWith('apps/mobile/')) {
52+
mobileFiles.push(fileName);
53+
} else if (fileName.startsWith('apps/web/')) {
54+
webFiles.push(fileName);
55+
}
56+
});
57+
58+
const strippedBackend = backendFiles.map(f => f.replace('apps/backend/', ''));
59+
const strippedMobile = mobileFiles.map(f => f.replace('apps/mobile/', ''));
60+
61+
console.log({ backendFiles, mobileFiles, webFiles });
62+
63+
core.setOutput('backendFiles', strippedBackend.join(' '));
64+
core.setOutput('mobileFiles', strippedMobile.join(' '));
65+
core.setOutput('webFiles', webFiles.map(f => f.replace('apps/web/', '')).join(' '));
66+
core.setOutput('backendTestFiles', deriveTestFiles(strippedBackend).join(' '));
67+
core.setOutput('mobileTestFiles', deriveTestFiles(strippedMobile).join(' '));
68+
core.setOutput('backendChanged', backendFiles.length > 0);
69+
core.setOutput('mobileChanged', mobileFiles.length > 0);
70+
core.setOutput('webChanged', webFiles.length > 0);
71+
72+
} catch (error) {
73+
console.error(error);
74+
75+
return {
76+
backendChanged: false,
77+
mobileChanged: false,
78+
webChanged: false
79+
};
80+
}
81+
};

.github/scripts/commentResults.js

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

0 commit comments

Comments
 (0)