PromucFlow_constructor/.github/workflows/scripts/client-build-compliance.js
Shrikant Sharat Kandula 2459607a3f
ci: Move check for new JS Cypress tests to GitHub script (#33560)
We have a check when running Cypress tests to ensure that no new `.js`
files are added under Cypress folder. This PR moves this check to a
separate JS file. There's another check that does some ADS compliance,
which I'll port in a follow-up PR.

Why am I hitting on this? One, to move away from `umani/changed-files`
workflow, which has randomly failed for us in the past, and id doesn't
do so much special for us anyway. Two, this workflow is the last usage
of `APPSMITH_CI_TEST_PAT` secret, so I should be able to remove that
secret as well. One less secret.
2024-05-20 20:39:33 +05:30

29 lines
944 B
JavaScript

module.exports = async ({core, github, context}) => {
const prNumber = context.payload.inputs.pr;
const affectedFiles = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
per_page: 100,
});
console.log(affectedFiles);
const nonTsFiles = affectedFiles.filter(f => f.status === "added" && f.filename.startsWith("app/client/cypress/e2e/") && !f.filename.endsWith(".ts"));
console.log(nonTsFiles);
if (nonTsFiles.length > 0) {
const body = [
"🔴 There's new test files in JS, please port to TS and re-trigger Cypress tests:",
`1. ${nonTsFiles.map(f => f.filename).join("\n1. ")}`,
].join("\n");
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
core.setFailed("There's new test files in JS\n" + body);
}
};