diff --git a/.github/scripts/ciScript.js b/.github/scripts/ciScript.js index 810a91fb..f054146b 100644 --- a/.github/scripts/ciScript.js +++ b/.github/scripts/ciScript.js @@ -6,6 +6,7 @@ module.exports = async ({ github, context, core }) => { const prState = pr.state; const backendFiles = []; + const backendTests = []; const mobileFiles = []; const webFiles = []; @@ -33,6 +34,17 @@ module.exports = async ({ github, context, core }) => { if (fileName.startsWith('apps/backend/')) { backendFiles.push(fileName); + + const relative = fileName.replace('apps/backend/src/', ''); + const baseName = relative + .split('/') + .pop() + ?.replace(/\.(ts|tsx|js|jsx)$/, ''); + + if (baseName) { + backendTests.push(`src/__tests__/${baseName}.test.ts`); + } + } else if (fileName.startsWith('apps/mobile/')) { mobileFiles.push(fileName); } else if (fileName.startsWith('apps/web/')) { @@ -40,36 +52,42 @@ module.exports = async ({ github, context, core }) => { } }); - console.log({ - backendFiles, - mobileFiles, - webFiles - }); - - core.setOutput( - "backendFiles", - backendFiles - .map(file => file.replace("apps/backend/", "")) - .join(" ") - ) - - core.setOutput( - "mobileFiles", - mobileFiles - .map(file => file.replace("apps/mobile/", "")) - .join(" ") - ) - - core.setOutput( - "webFiles", - webFiles - .map(file => file.replace("apps/web/", "")) - .join(" ") - ) - - core.setOutput("backendChanged", backendFiles.length > 0) - core.setOutput("mobileChanged", mobileFiles.length > 0) - core.setOutput("webChanged", webFiles.length > 0) + console.log({ + backendFiles, + backendTests, + mobileFiles, + webFiles + }); + + core.setOutput( + "backendFiles", + backendFiles + .map(file => file.replace("apps/backend/", "")) + .join(" ") + ); + + core.setOutput( + "backendTests", + [...new Set(backendTests)].join(" ") + ); + + core.setOutput( + "mobileFiles", + mobileFiles + .map(file => file.replace("apps/mobile/", "")) + .join(" ") + ); + + core.setOutput( + "webFiles", + webFiles + .map(file => file.replace("apps/web/", "")) + .join(" ") + ); + + core.setOutput("backendChanged", backendFiles.length > 0); + core.setOutput("mobileChanged", mobileFiles.length > 0); + core.setOutput("webChanged", webFiles.length > 0); } catch (error) { console.error(error); diff --git a/.github/scripts/discordPinReminder.js b/.github/scripts/discordPinReminder.js index 5e4df420..d5724578 100644 --- a/.github/scripts/discordPinReminder.js +++ b/.github/scripts/discordPinReminder.js @@ -2,11 +2,12 @@ module.exports = async ({ github, context }) => { const pr = context.payload.pull_request; const ignoreUsers = [ 'ShantKhatri', - 'Harxhit' + 'Harxhit', + 'blankirigaya' ] try { // Only continue if merged - if (!pr || !pr.merged) { + if (!pr || !pr.merged) { console.log('PR not merged.'); return; } diff --git a/.github/scripts/unassignIssues.js b/.github/scripts/unassignIssues.js index 017d641c..b4886e91 100644 --- a/.github/scripts/unassignIssues.js +++ b/.github/scripts/unassignIssues.js @@ -4,7 +4,8 @@ module.exports = async ({ github, context }) => { const PROTECTED_ASSIGNEES = [ 'ShantKhatri', - 'Harxhit' + 'Harxhit', + 'blankirigaya' ]; // Fetch all open issues (excluding PRs) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25f71019..e3c4e311 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,11 @@ jobs: if: needs.detect-changes.outputs.backendChanged == 'true' runs-on: ubuntu-latest + outputs: + backend_lint: ${{ steps.backend_lint.outcome }} + backend_test: ${{ steps.backend_test.outcome }} + backend_typecheck: ${{ steps.backend_typecheck.outcome }} + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -49,21 +54,32 @@ jobs: - name: Backend lint id: backend_lint + continue-on-error: true run: cd apps/backend && pnpm eslint ${{ needs.detect-changes.outputs.backendFiles }} - name: Backend test id: backend_test + continue-on-error: true run: cd apps/backend && pnpm test ${{ needs.detect-changes.outputs.backendFiles }} - name: Backend typecheck id: backend_typecheck + continue-on-error: true run: cd apps/backend && pnpm typecheck ${{ needs.detect-changes.outputs.backendFiles }} + - name: Fail backend if checks failed + if: steps.backend_lint.outcome == 'failure' || steps.backend_test.outcome == 'failure' || steps.backend_typecheck.outcome == 'failure' + run: exit 1 + web-ci: needs: detect-changes if: needs.detect-changes.outputs.webChanged == 'true' runs-on: ubuntu-latest + outputs: + web_check: ${{ steps.web_check.outcome }} + web_build: ${{ steps.web_build.outcome }} + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -77,17 +93,27 @@ jobs: - name: Web check id: web_check + continue-on-error: true run: cd apps/web && pnpm check - name: Web build id: web_build + continue-on-error: true run: cd apps/web && pnpm build + - name: Fail web if checks failed + if: steps.web_check.outcome == 'failure' || steps.web_build.outcome == 'failure' + run: exit 1 + mobile-ci: needs: detect-changes if: needs.detect-changes.outputs.mobileChanged == 'true' runs-on: ubuntu-latest + outputs: + mobile_lint: ${{ steps.mobile_lint.outcome }} + mobile_test: ${{ steps.mobile_test.outcome }} + steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd @@ -101,12 +127,18 @@ jobs: - name: Mobile lint id: mobile_lint + continue-on-error: true run: cd apps/mobile && pnpm eslint ${{ needs.detect-changes.outputs.mobileFiles }} - name: Mobile test id: mobile_test + continue-on-error: true run: cd apps/mobile && pnpm test + - name: Fail mobile if checks failed + if: steps.mobile_lint.outcome == 'failure' || steps.mobile_test.outcome == 'failure' + run: exit 1 + comment-results: needs: - backend-ci @@ -128,7 +160,18 @@ jobs: await script({ github, context, + backend: '${{ needs.backend-ci.result }}', web: '${{ needs.web-ci.result }}', - mobile: '${{ needs.mobile-ci.result }}' - }); \ No newline at end of file + mobile: '${{ needs.mobile-ci.result }}', + + backendLint: '${{ needs.backend-ci.outputs.backend_lint }}', + backendTest: '${{ needs.backend-ci.outputs.backend_test }}', + backendTypecheck: '${{ needs.backend-ci.outputs.backend_typecheck }}', + + mobileLint: '${{ needs.mobile-ci.outputs.mobile_lint }}', + mobileTest: '${{ needs.mobile-ci.outputs.mobile_test }}', + + webCheck: '${{ needs.web-ci.outputs.web_check }}', + webBuild: '${{ needs.web-ci.outputs.web_build }}' + }); \ No newline at end of file