Skip to content

Commit 176a2bc

Browse files
authored
fix(ci): refine workflow execution, reporting, and collaborator handling (#455)
* fix: Fixed linting issues * fix(ci): improve workflow reporting and add collaborator support
1 parent ff3da15 commit 176a2bc

4 files changed

Lines changed: 98 additions & 35 deletions

File tree

.github/scripts/ciScript.js

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = async ({ github, context, core }) => {
66
const prState = pr.state;
77

88
const backendFiles = [];
9+
const backendTests = [];
910
const mobileFiles = [];
1011
const webFiles = [];
1112

@@ -33,43 +34,60 @@ module.exports = async ({ github, context, core }) => {
3334

3435
if (fileName.startsWith('apps/backend/')) {
3536
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+
3648
} else if (fileName.startsWith('apps/mobile/')) {
3749
mobileFiles.push(fileName);
3850
} else if (fileName.startsWith('apps/web/')) {
3951
webFiles.push(fileName);
4052
}
4153
});
4254

43-
console.log({
44-
backendFiles,
45-
mobileFiles,
46-
webFiles
47-
});
48-
49-
core.setOutput(
50-
"backendFiles",
51-
backendFiles
52-
.map(file => file.replace("apps/backend/", ""))
53-
.join(" ")
54-
)
55-
56-
core.setOutput(
57-
"mobileFiles",
58-
mobileFiles
59-
.map(file => file.replace("apps/mobile/", ""))
60-
.join(" ")
61-
)
62-
63-
core.setOutput(
64-
"webFiles",
65-
webFiles
66-
.map(file => file.replace("apps/web/", ""))
67-
.join(" ")
68-
)
69-
70-
core.setOutput("backendChanged", backendFiles.length > 0)
71-
core.setOutput("mobileChanged", mobileFiles.length > 0)
72-
core.setOutput("webChanged", webFiles.length > 0)
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);
7391

7492
} catch (error) {
7593
console.error(error);

.github/scripts/discordPinReminder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ module.exports = async ({ github, context }) => {
22
const pr = context.payload.pull_request;
33
const ignoreUsers = [
44
'ShantKhatri',
5-
'Harxhit'
5+
'Harxhit',
6+
'blankirigaya'
67
]
78
try {
89
// Only continue if merged
9-
if (!pr || !pr.merged) {
10+
if (!pr || !pr.merged) {
1011
console.log('PR not merged.');
1112
return;
1213
}

.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/workflows/ci.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ jobs:
3636
if: needs.detect-changes.outputs.backendChanged == 'true'
3737
runs-on: ubuntu-latest
3838

39+
outputs:
40+
backend_lint: ${{ steps.backend_lint.outcome }}
41+
backend_test: ${{ steps.backend_test.outcome }}
42+
backend_typecheck: ${{ steps.backend_typecheck.outcome }}
43+
3944
steps:
4045
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
4146

@@ -49,21 +54,32 @@ jobs:
4954

5055
- name: Backend lint
5156
id: backend_lint
57+
continue-on-error: true
5258
run: cd apps/backend && pnpm eslint ${{ needs.detect-changes.outputs.backendFiles }}
5359

5460
- name: Backend test
5561
id: backend_test
62+
continue-on-error: true
5663
run: cd apps/backend && pnpm test ${{ needs.detect-changes.outputs.backendFiles }}
5764

5865
- name: Backend typecheck
5966
id: backend_typecheck
67+
continue-on-error: true
6068
run: cd apps/backend && pnpm typecheck ${{ needs.detect-changes.outputs.backendFiles }}
6169

70+
- name: Fail backend if checks failed
71+
if: steps.backend_lint.outcome == 'failure' || steps.backend_test.outcome == 'failure' || steps.backend_typecheck.outcome == 'failure'
72+
run: exit 1
73+
6274
web-ci:
6375
needs: detect-changes
6476
if: needs.detect-changes.outputs.webChanged == 'true'
6577
runs-on: ubuntu-latest
6678

79+
outputs:
80+
web_check: ${{ steps.web_check.outcome }}
81+
web_build: ${{ steps.web_build.outcome }}
82+
6783
steps:
6884
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
6985

@@ -77,17 +93,27 @@ jobs:
7793

7894
- name: Web check
7995
id: web_check
96+
continue-on-error: true
8097
run: cd apps/web && pnpm check
8198

8299
- name: Web build
83100
id: web_build
101+
continue-on-error: true
84102
run: cd apps/web && pnpm build
85103

104+
- name: Fail web if checks failed
105+
if: steps.web_check.outcome == 'failure' || steps.web_build.outcome == 'failure'
106+
run: exit 1
107+
86108
mobile-ci:
87109
needs: detect-changes
88110
if: needs.detect-changes.outputs.mobileChanged == 'true'
89111
runs-on: ubuntu-latest
90112

113+
outputs:
114+
mobile_lint: ${{ steps.mobile_lint.outcome }}
115+
mobile_test: ${{ steps.mobile_test.outcome }}
116+
91117
steps:
92118
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
93119

@@ -101,12 +127,18 @@ jobs:
101127

102128
- name: Mobile lint
103129
id: mobile_lint
130+
continue-on-error: true
104131
run: cd apps/mobile && pnpm eslint ${{ needs.detect-changes.outputs.mobileFiles }}
105132

106133
- name: Mobile test
107134
id: mobile_test
135+
continue-on-error: true
108136
run: cd apps/mobile && pnpm test
109137

138+
- name: Fail mobile if checks failed
139+
if: steps.mobile_lint.outcome == 'failure' || steps.mobile_test.outcome == 'failure'
140+
run: exit 1
141+
110142
comment-results:
111143
needs:
112144
- backend-ci
@@ -128,7 +160,18 @@ jobs:
128160
await script({
129161
github,
130162
context,
163+
131164
backend: '${{ needs.backend-ci.result }}',
132165
web: '${{ needs.web-ci.result }}',
133-
mobile: '${{ needs.mobile-ci.result }}'
134-
});
166+
mobile: '${{ needs.mobile-ci.result }}',
167+
168+
backendLint: '${{ needs.backend-ci.outputs.backend_lint }}',
169+
backendTest: '${{ needs.backend-ci.outputs.backend_test }}',
170+
backendTypecheck: '${{ needs.backend-ci.outputs.backend_typecheck }}',
171+
172+
mobileLint: '${{ needs.mobile-ci.outputs.mobile_lint }}',
173+
mobileTest: '${{ needs.mobile-ci.outputs.mobile_test }}',
174+
175+
webCheck: '${{ needs.web-ci.outputs.web_check }}',
176+
webBuild: '${{ needs.web-ci.outputs.web_build }}'
177+
});

0 commit comments

Comments
 (0)