Skip to content

Commit

Permalink
fix prisma migrate dev behavior differences in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
electrovir committed Sep 10, 2024
1 parent e0e2a75 commit c5a1e0f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/node/src/docker/docker-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function removeImageFromLocalRegistry(
imageName: string,
) {
try {
const shellOutput = await runShellCommand(`docker image rm '${imageName}'`, {
await runShellCommand(`docker image rm '${imageName}'`, {
rejectOnError: true,
});
} catch (caught) {
Expand Down
14 changes: 0 additions & 14 deletions packages/node/src/docker/run-docker-test.mock.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import type {MaybePromise} from '@augment-vir/common';
import {isOperatingSystem, OperatingSystem} from '../augments/os/operating-system.js';

export function dockerTest(callback: () => MaybePromise<void>) {
if (isOperatingSystem(OperatingSystem.Mac) && process.env.CI) {
/**
* We cannot test Docker on macOS GitHub Actions runners.
*
* @see
* - https://github.com/actions/runner-images/issues/8104
* - https://github.com/douglascamata/setup-docker-macos-action?tab=readme-ov-file#arm64-processors-m1-m2-m3-series-used-on-macos-14-images-are-unsupported
* - https://github.com/actions/runner-images/issues/2150
* - https://github.com/actions/runner/issues/1456
*/
return () => {};
}

return callback;
}
21 changes: 7 additions & 14 deletions packages/node/src/prisma/prisma-migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {assert} from '@augment-vir/assert';
import {describe, it} from '@augment-vir/test';
import {existsSync} from 'node:fs';
import {readdir, rm} from 'node:fs/promises';
import {isOperatingSystem, OperatingSystem} from '../augments/os/operating-system.js';
import {prisma} from '../augments/prisma.js';
import {
testInvalidPrismaSchemaPath,
Expand Down Expand Up @@ -143,6 +142,8 @@ describe(prisma.migration.applyDev.name, () => {
});
});
it('fails when a new migration is needed', async () => {
const originalCi = process.env;
delete process.env.CI;
await clearTestDatabaseOutputs();
await prisma.database.resetDev(testPrismaSchemaPath);

Expand All @@ -152,19 +153,11 @@ describe(prisma.migration.applyDev.name, () => {
unappliedMigrations: [],
});

/**
* This behaves differently in Linux. I don't know why, and at the moment I don't care nor
* do I have an easy way to debug it.
*/
/* node:coverage ignore next 8 */
if (isOperatingSystem(OperatingSystem.Linux)) {
await prisma.migration.applyDev(testPrismaSchema2Path);
} else {
await assert.throws(prisma.migration.applyDev(testPrismaSchema2Path), {
matchMessage: 'A new Prisma migration is needed for',
matchConstructor: PrismaMigrationNeededError,
});
}
await assert.throws(prisma.migration.applyDev(testPrismaSchema2Path), {
matchMessage: 'A new Prisma migration is needed for',
matchConstructor: PrismaMigrationNeededError,
});
process.env = originalCi;
});
it('fails when a reset is needed', async () => {
await clearTestDatabaseOutputs();
Expand Down

0 comments on commit c5a1e0f

Please sign in to comment.