mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 17:47:22 +00:00
chore(test): cleanup github runner native images before test start (#16788)
* chore(test): cleanup github runner native images before test start
This commit is contained in:
parent
3bc17623a0
commit
ebe39f26a0
5 changed files with 47 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ import { SettingsBar } from '/@/model/pages/settings-bar';
|
|||
import { NavigationBar } from '/@/model/workbench/navigation';
|
||||
import { canTestRegistry, setupRegistry } from '/@/setupFiles/setup-registry';
|
||||
import { expect as playExpect, test } from '/@/utility/fixtures';
|
||||
import { deleteRegistry } from '/@/utility/operations';
|
||||
import { deleteRegistry, ensureNoImagesPresentCLI } from '/@/utility/operations';
|
||||
import { isWindows } from '/@/utility/platform';
|
||||
import { waitForPodmanMachineStartup } from '/@/utility/wait';
|
||||
|
||||
|
|
@ -52,6 +52,7 @@ let registryPswdSecret: string;
|
|||
let manifestLabelComplex: string;
|
||||
|
||||
test.beforeAll(async ({ runner, welcomePage, page, navigationBar }) => {
|
||||
test.setTimeout(180_000);
|
||||
runner.setVideoAndTraceName('image-manifest-smoke-e2e');
|
||||
|
||||
await welcomePage.handleWelcomePage(true);
|
||||
|
|
@ -77,6 +78,7 @@ test.beforeAll(async ({ runner, welcomePage, page, navigationBar }) => {
|
|||
console.log('Error deleting registry:', error);
|
||||
});
|
||||
|
||||
await ensureNoImagesPresentCLI(page);
|
||||
imagesPage = await navigationBar.openImages();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import { RegistriesPage } from '/@/model/pages/registries-page';
|
|||
import { SettingsBar } from '/@/model/pages/settings-bar';
|
||||
import { canTestRegistry, setupRegistry } from '/@/setupFiles/setup-registry';
|
||||
import { expect as playExpect, test } from '/@/utility/fixtures';
|
||||
import { deleteImage, deleteRegistry } from '/@/utility/operations';
|
||||
import { deleteImage, deleteRegistry, ensureNoImagesPresentCLI } from '/@/utility/operations';
|
||||
import { waitForPodmanMachineStartup } from '/@/utility/wait';
|
||||
|
||||
const helloContainer = 'ghcr.io/podmandesktop-ci/hello';
|
||||
|
|
@ -36,6 +36,7 @@ test.beforeAll(async ({ runner, welcomePage, page }) => {
|
|||
|
||||
await welcomePage.handleWelcomePage(true);
|
||||
await waitForPodmanMachineStartup(page);
|
||||
await ensureNoImagesPresentCLI(page);
|
||||
|
||||
[registryUrl, registryUsername, registryPswdSecret] = setupRegistry();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
import { expect as playExpect, test } from '/@/utility/fixtures';
|
||||
import { ensureNoImagesPresentCLI } from '/@/utility/operations';
|
||||
import { waitForPodmanMachineStartup } from '/@/utility/wait';
|
||||
|
||||
const imageToSearch = 'ghcr.io/linuxcontainers/alpine';
|
||||
|
|
@ -28,6 +29,7 @@ test.beforeAll(async ({ runner, welcomePage, page }) => {
|
|||
|
||||
await welcomePage.handleWelcomePage(true);
|
||||
await waitForPodmanMachineStartup(page);
|
||||
await ensureNoImagesPresentCLI(page);
|
||||
});
|
||||
|
||||
test.afterAll(async ({ runner }) => {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import { ArchitectureType } from '/@/model/core/platforms';
|
|||
import { ImageState } from '/@/model/core/states';
|
||||
import { ImageDetailsPage } from '/@/model/pages/image-details-page';
|
||||
import { expect as playExpect, test } from '/@/utility/fixtures';
|
||||
import { untagImagesFromPodman } from '/@/utility/operations';
|
||||
import { ensureNoImagesPresentCLI, untagImagesFromPodman } from '/@/utility/operations';
|
||||
import { waitForPodmanMachineStartup } from '/@/utility/wait';
|
||||
|
||||
const helloContainer = 'ghcr.io/podmandesktop-ci/hello';
|
||||
|
|
@ -39,6 +39,7 @@ test.beforeAll(async ({ runner, welcomePage, page }) => {
|
|||
|
||||
await welcomePage.handleWelcomePage(true);
|
||||
await waitForPodmanMachineStartup(page);
|
||||
await ensureNoImagesPresentCLI(page);
|
||||
});
|
||||
|
||||
test.afterAll(async ({ runner }) => {
|
||||
|
|
|
|||
|
|
@ -505,6 +505,44 @@ export async function runComposeUpFromCLI(composeFilePath: string): Promise<void
|
|||
});
|
||||
}
|
||||
|
||||
export async function removeAllImagesCLI(engine: 'podman' | 'docker' = 'podman', timeout = 120_000): Promise<void> {
|
||||
return test.step(`Remove all ${engine} images via CLI`, () => {
|
||||
if (process.env.CI !== 'true') {
|
||||
console.log(`Skipping ${engine} image cleanup (CI is not set to true)`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const command = engine === 'podman' ? 'podman rmi --all --force' : 'docker image prune --all --force';
|
||||
// eslint-disable-next-line sonarjs/os-command
|
||||
execSync(command, { timeout });
|
||||
console.log(`All ${engine} images removed via CLI`);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
`No ${engine} images to remove or command not available:`,
|
||||
error instanceof Error ? error.message : String(error),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function ensureNoImagesPresentCLI(page: Page): Promise<void> {
|
||||
return test.step('Ensure no images are present', async () => {
|
||||
if (process.env.CI !== 'true') {
|
||||
console.log('Skipping image cleanup and validation (CI is not set to true)');
|
||||
return;
|
||||
}
|
||||
|
||||
await removeAllImagesCLI('podman');
|
||||
await removeAllImagesCLI('docker');
|
||||
|
||||
const navigationBar = new NavigationBar(page);
|
||||
const imagesPage = await navigationBar.openImages();
|
||||
await playExpect(imagesPage.heading).toBeVisible();
|
||||
await playExpect.poll(async () => await imagesPage.countRowsFromTable(), { timeout: 30_000 }).toBe(0);
|
||||
});
|
||||
}
|
||||
|
||||
export async function untagImagesFromPodman(name: string, tag = ''): Promise<void> {
|
||||
return test.step('Untag images from Podman', async () => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue