chore(publish): fix timeout problem without lerna (#3679)
This commit is contained in:
parent
1f906963e7
commit
8feb5ee3f9
@ -23,6 +23,7 @@ describe('OHIF Measurement Panel', function () {
|
|||||||
it('checks if measurement item can be Relabeled under Measurements panel', function () {
|
it('checks if measurement item can be Relabeled under Measurements panel', function () {
|
||||||
// Add length measurement
|
// Add length measurement
|
||||||
cy.addLengthMeasurement();
|
cy.addLengthMeasurement();
|
||||||
|
|
||||||
cy.get('[data-cy="viewport-notification"]').as('viewportNotification').should('exist');
|
cy.get('[data-cy="viewport-notification"]').as('viewportNotification').should('exist');
|
||||||
cy.get('[data-cy="viewport-notification"]').as('viewportNotification').should('be.visible');
|
cy.get('[data-cy="viewport-notification"]').as('viewportNotification').should('be.visible');
|
||||||
|
|
||||||
|
|||||||
@ -145,7 +145,7 @@ Cypress.Commands.add('drag', { prevSubject: 'element' }, (...args) =>
|
|||||||
*/
|
*/
|
||||||
Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
|
Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
|
||||||
const performClick = (alias, x, y) => {
|
const performClick = (alias, x, y) => {
|
||||||
cy.get(alias).as(`axu-${alias}`).click(x, y, { force: true, multiple: true }).wait(250);
|
cy.get(alias).as(`axu-${alias}`).click(x, y, { force: true, multiple: true }).wait(1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
cy.get(viewport).as('viewportAlias');
|
cy.get(viewport).as('viewportAlias');
|
||||||
@ -155,11 +155,10 @@ Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
|
|||||||
// First click
|
// First click
|
||||||
performClick('@viewportAlias', x1, y1);
|
performClick('@viewportAlias', x1, y1);
|
||||||
|
|
||||||
// Move the mouse
|
|
||||||
cy.get('@viewportAlias').trigger('mousemove', { clientX: x2, clientY: y2 }).wait(250);
|
|
||||||
|
|
||||||
// Second click
|
// Second click
|
||||||
performClick('@viewportAlias', x2, y2);
|
performClick('@viewportAlias', x2, y2);
|
||||||
|
|
||||||
|
cy.wait(1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -281,7 +280,7 @@ Cypress.Commands.add(
|
|||||||
|
|
||||||
cy.get('@lengthButton').should('have.class', 'active');
|
cy.get('@lengthButton').should('have.class', 'active');
|
||||||
|
|
||||||
cy.addLine('.viewport-element', firstClick, secondClick);
|
cy.addLine('.cornerstone-canvas', firstClick, secondClick);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -292,7 +291,7 @@ Cypress.Commands.add(
|
|||||||
cy.get('[data-cy="MeasurementTools-split-button-secondary"]').click();
|
cy.get('[data-cy="MeasurementTools-split-button-secondary"]').click();
|
||||||
cy.get('[data-cy="Angle"]').click();
|
cy.get('[data-cy="Angle"]').click();
|
||||||
|
|
||||||
cy.addAngle('.viewport-element', initPos, midPos, finalPos);
|
cy.addAngle('.cornerstone-canvas', initPos, midPos, finalPos);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -1,24 +1,63 @@
|
|||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
|
import fs from 'fs/promises';
|
||||||
|
import glob from 'glob';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const MAX_RETRIES = 3;
|
||||||
|
const RETRY_DELAY = 10000; // 10 seconds
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const { stdout: branchName } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
|
const { stdout: branchName } = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
|
||||||
|
|
||||||
// using the environment variable NPM_TOKEN, create a .npmrc file
|
const lernaJson = JSON.parse(await fs.readFile('lerna.json', 'utf8'));
|
||||||
// and set the token to the value of the environment variable
|
|
||||||
// Publishing each package, if on master/main branch publish beta versions
|
const packages = lernaJson.packages;
|
||||||
// otherwise publish latest
|
|
||||||
if (branchName === 'release') {
|
const rootDir = process.cwd();
|
||||||
await execa('npx', ['lerna', 'publish', 'from-package', '--no-verify-access', '--yes']);
|
|
||||||
} else {
|
for (const packagePathPattern of packages) {
|
||||||
await execa('npx', [
|
const matchingDirectories = glob.sync(packagePathPattern);
|
||||||
'lerna',
|
|
||||||
'publish',
|
for (const packageDirectory of matchingDirectories) {
|
||||||
'from-package',
|
// change back to the root directory
|
||||||
'--no-verify-access',
|
process.chdir(rootDir);
|
||||||
'--yes',
|
|
||||||
'--dist-tag',
|
const packageJsonPath = path.join(packageDirectory, 'package.json');
|
||||||
'beta',
|
|
||||||
]);
|
try {
|
||||||
|
const packageJsonContent = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));
|
||||||
|
|
||||||
|
if (packageJsonContent.private) {
|
||||||
|
console.log(`Skipping private package at ${packageDirectory}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
process.chdir(packageDirectory);
|
||||||
|
|
||||||
|
let retries = 0;
|
||||||
|
while (retries < MAX_RETRIES) {
|
||||||
|
try {
|
||||||
|
const publishArgs = ['publish'];
|
||||||
|
|
||||||
|
if (branchName === 'master') {
|
||||||
|
publishArgs.push('--tag', 'beta');
|
||||||
|
}
|
||||||
|
|
||||||
|
await execa('npm', publishArgs);
|
||||||
|
console.log(`Successfully published package at ${packageDirectory}`);
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
retries++;
|
||||||
|
console.error(
|
||||||
|
`Failed to publish package at ${packageDirectory} with error ${error}, retrying... (${retries}/${MAX_RETRIES})`
|
||||||
|
);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, RETRY_DELAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`An error occurred while processing ${packageDirectory}: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Finished');
|
console.log('Finished');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user