Prototype re-try on snapshot warnings

This commit is contained in:
Henri Maurer
2023-06-06 16:44:27 +01:00
parent 0342e75832
commit d35955ebf6
3 changed files with 51 additions and 17 deletions
Generated Vendored
+23 -8
View File
@@ -485,19 +485,34 @@ const summary = __importStar(__nccwpck_require__(8608));
const git_refs_1 = __nccwpck_require__(1086); const git_refs_1 = __nccwpck_require__(1086);
const utils_1 = __nccwpck_require__(918); const utils_1 = __nccwpck_require__(918);
const comment_pr_1 = __nccwpck_require__(5842); const comment_pr_1 = __nccwpck_require__(5842);
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const config = yield (0, config_1.readConfig)(); const config = yield (0, config_1.readConfig)();
const refs = (0, git_refs_1.getRefs)(config, github.context); const refs = (0, git_refs_1.getRefs)(config, github.context);
const comparison = yield dependencyGraph.compare({ let changes;
owner: github.context.repo.owner, let snapshot_warnings;
repo: github.context.repo.repo, for (let i = 0; i < 60 * 5; i++) {
baseRef: refs.base, const comparison = yield dependencyGraph.compare({
headRef: refs.head owner: github.context.repo.owner,
}); repo: github.context.repo.repo,
const changes = comparison.changes; baseRef: refs.base,
const snapshot_warnings = comparison.snapshot_warnings; headRef: refs.head
});
if (comparison.snapshot_warnings.match(/No snapshots were found for the head SHA/i)) {
core.info(comparison.snapshot_warnings);
core.info('Retrying in 1 second...');
yield delay(1000);
}
else {
changes = comparison.changes;
snapshot_warnings = comparison.snapshot_warnings;
break;
}
}
if (!changes) { if (!changes) {
core.info('No Dependency Changes found. Skipping Dependency Review.'); core.info('No Dependency Changes found. Skipping Dependency Review.');
return; return;
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+27 -8
View File
@@ -17,20 +17,39 @@ import {getRefs} from './git-refs'
import {groupDependenciesByManifest} from './utils' import {groupDependenciesByManifest} from './utils'
import {commentPr} from './comment-pr' import {commentPr} from './comment-pr'
function delay(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms))
}
async function run(): Promise<void> { async function run(): Promise<void> {
try { try {
const config = await readConfig() const config = await readConfig()
const refs = getRefs(config, github.context) const refs = getRefs(config, github.context)
const comparison = await dependencyGraph.compare({ let changes
owner: github.context.repo.owner, let snapshot_warnings
repo: github.context.repo.repo, for (let i = 0; i < 60 * 5; i++) {
baseRef: refs.base, const comparison = await dependencyGraph.compare({
headRef: refs.head owner: github.context.repo.owner,
}) repo: github.context.repo.repo,
const changes = comparison.changes baseRef: refs.base,
const snapshot_warnings = comparison.snapshot_warnings headRef: refs.head
})
if (
comparison.snapshot_warnings.match(
/No snapshots were found for the head SHA/i
)
) {
core.info(comparison.snapshot_warnings)
core.info('Retrying in 1 second...')
await delay(1000)
} else {
changes = comparison.changes
snapshot_warnings = comparison.snapshot_warnings
break
}
}
if (!changes) { if (!changes) {
core.info('No Dependency Changes found. Skipping Dependency Review.') core.info('No Dependency Changes found. Skipping Dependency Review.')