fix(core): copilot test condition & retry (#8665)

This commit is contained in:
darkskygit
2024-11-04 06:17:06 +00:00
parent ee16ea7a5a
commit 2e7a7d5909
3 changed files with 19 additions and 16 deletions
+2 -6
View File
@@ -473,12 +473,8 @@ jobs:
env:
BASE_REF: ${{ github.base_ref }}
run: |
if [ -n "$BASE_REF" ]; then
if node ./scripts/detect-blocksuite-update.mjs "$BASE_REF"; then
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
fi
if node ./scripts/detect-blocksuite-update.mjs "$BASE_REF"; then
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
fi
+4 -4
View File
@@ -65,13 +65,13 @@ async function findPackageJson(root) {
}
async function main() {
if (process.argv.length < 3) {
console.error('Usage: node script.js <commit-hash>');
const commitHash = process.argv[2] || process.env.GITHUB_BASE_REF;
const currentHead = process.argv[3] || 'HEAD';
if (!commitHash) {
console.error('Missing base ref commit hash, skipping check.');
process.exit(1);
}
const commitHash = process.argv[2];
const currentHead = process.argv[3] || 'HEAD';
const changedPackages = new Set();
const folders = await findPackageJson(
join(fileURLToPath(import.meta.url), '..', '..')
+13 -6
View File
@@ -113,15 +113,22 @@ const focusToEditor = async (page: Page) => {
};
const getEditorContent = async (page: Page) => {
const lines = await page.$$('page-editor .inline-editor');
const contents = await Promise.all(lines.map(el => el.innerText()));
return (
contents
let content = '';
let retry = 3;
while (!content && retry > 0) {
const lines = await page.$$('page-editor .inline-editor');
const contents = await Promise.all(lines.map(el => el.innerText()));
content = contents
// cleanup zero width space
.map(c => c.replace(/\u200B/g, '').trim())
.filter(c => !!c)
.join('\n')
);
.join('\n');
if (!content) {
await page.waitForTimeout(500);
retry -= 1;
}
}
return content;
};
const switchToEdgelessMode = async (page: Page) => {