-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cat-519-cleanup-old-canvas-code' of github.com:n8n-io/n…
…8n into cat-519-cleanup-old-canvas-code
- Loading branch information
Showing
36 changed files
with
631 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,50 @@ jobs: | |
working-directory: packages/cli | ||
run: pnpm test:mariadb --testTimeout 30000 | ||
|
||
mysql: | ||
name: MySQL (${{ matrix.service-name }}) | ||
runs-on: ubuntu-latest | ||
needs: build | ||
timeout-minutes: 20 | ||
strategy: | ||
matrix: | ||
service-name: [ 'mysql-8.0.13', 'mysql-8.4' ] | ||
env: | ||
DB_MYSQLDB_PASSWORD: password | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- uses: actions/[email protected] | ||
with: | ||
node-version: 20.x | ||
|
||
- name: Setup corepack and pnpm | ||
run: | | ||
npm i -g [email protected] | ||
corepack enable | ||
- run: pnpm install --frozen-lockfile | ||
|
||
- name: Setup build cache | ||
uses: rharkor/[email protected] | ||
|
||
- name: Restore cached build artifacts | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}:db-tests | ||
|
||
- name: Start MySQL | ||
uses: isbang/[email protected] | ||
with: | ||
compose-file: ./.github/docker-compose.yml | ||
services: | | ||
${{ matrix.service-name }} | ||
- name: Test MySQL | ||
working-directory: packages/cli | ||
run: pnpm test:mysql --testTimeout 30000 | ||
|
||
postgres: | ||
name: Postgres | ||
runs-on: ubuntu-latest | ||
|
@@ -168,7 +212,7 @@ jobs: | |
notify-on-failure: | ||
name: Notify Slack on failure | ||
runs-on: ubuntu-latest | ||
needs: [mariadb, postgres] | ||
needs: [mariadb, postgres, mysql] | ||
steps: | ||
- name: Notify Slack on failure | ||
uses: act10ns/[email protected] | ||
|
@@ -177,4 +221,4 @@ jobs: | |
status: ${{ job.status }} | ||
channel: '#alerts-build' | ||
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
message: Postgres or MariaDB tests failed (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | ||
message: Postgres, MariaDB or MySQL tests failed (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |
39 changes: 39 additions & 0 deletions
39
packages/@n8n/api-types/src/dto/credentials/__tests__/generate-credential-name.dto.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { GenerateCredentialNameRequestQuery } from '../generate-credential-name.dto'; | ||
|
||
describe('GenerateCredentialNameRequestQuery', () => { | ||
describe('should pass validation', () => { | ||
it('with empty object', () => { | ||
const data = {}; | ||
|
||
const result = GenerateCredentialNameRequestQuery.safeParse(data); | ||
|
||
expect(result.success).toBe(true); | ||
expect(result.data?.name).toBeUndefined(); | ||
}); | ||
|
||
it('with valid name', () => { | ||
const data = { name: 'My Credential' }; | ||
|
||
const result = GenerateCredentialNameRequestQuery.safeParse(data); | ||
|
||
expect(result.success).toBe(true); | ||
expect(result.data?.name).toBe('My Credential'); | ||
}); | ||
}); | ||
|
||
describe('should fail validation', () => { | ||
test.each([ | ||
{ field: 'name', value: 123 }, | ||
{ field: 'name', value: true }, | ||
{ field: 'name', value: {} }, | ||
{ field: 'name', value: [] }, | ||
])('with invalid value $value for $field', ({ field, value }) => { | ||
const data = { [field]: value }; | ||
|
||
const result = GenerateCredentialNameRequestQuery.safeParse(data); | ||
|
||
expect(result.success).toBe(false); | ||
expect(result.error?.issues[0].path[0]).toBe(field); | ||
}); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
packages/@n8n/api-types/src/dto/credentials/generate-credential-name.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
export class GenerateCredentialNameRequestQuery extends Z.class({ | ||
name: z.string().optional(), | ||
}) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/cli/src/databases/migrations/mysqldb/1732271325258-CreateTestMetricTable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import assert from 'node:assert'; | ||
|
||
import type { MigrationContext, ReversibleMigration } from '@/databases/types'; | ||
|
||
const testMetricEntityTableName = 'test_metric'; | ||
|
||
export class CreateTestMetricTable1732271325258 implements ReversibleMigration { | ||
async up({ schemaBuilder: { createTable, column }, queryRunner, tablePrefix }: MigrationContext) { | ||
// Check if the previous migration MigrateTestDefinitionKeyToString1731582748663 properly updated the primary key | ||
const table = await queryRunner.getTable(`${tablePrefix}test_definition`); | ||
assert(table, 'test_definition table not found'); | ||
|
||
const brokenPrimaryColumn = table.primaryColumns.some( | ||
(c) => c.name === 'tmp_id' && c.isPrimary, | ||
); | ||
|
||
if (brokenPrimaryColumn) { | ||
// The migration was completed, but left the table in inconsistent state, let's finish the primary key change | ||
await queryRunner.query( | ||
`ALTER TABLE ${tablePrefix}test_definition MODIFY COLUMN tmp_id INT NOT NULL;`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE ${tablePrefix}test_definition DROP PRIMARY KEY, ADD PRIMARY KEY (\`id\`);`, | ||
); | ||
await queryRunner.query( | ||
`DROP INDEX \`TMP_idx_${tablePrefix}test_definition_id\` ON ${tablePrefix}test_definition;`, | ||
); | ||
await queryRunner.query(`ALTER TABLE ${tablePrefix}test_definition DROP COLUMN tmp_id;`); | ||
} | ||
// End of test_definition PK check | ||
|
||
await createTable(testMetricEntityTableName) | ||
.withColumns( | ||
column('id').varchar(36).primary.notNull, | ||
column('name').varchar(255).notNull, | ||
column('testDefinitionId').varchar(36).notNull, | ||
) | ||
.withIndexOn('testDefinitionId') | ||
.withForeignKey('testDefinitionId', { | ||
tableName: 'test_definition', | ||
columnName: 'id', | ||
onDelete: 'CASCADE', | ||
}).withTimestamps; | ||
} | ||
|
||
async down({ schemaBuilder: { dropTable } }: MigrationContext) { | ||
await dropTable(testMetricEntityTableName); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/cli/src/databases/migrations/mysqldb/1736172058779-AddStatsColumnsToTestRun.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { MigrationContext, ReversibleMigration } from '@/databases/types'; | ||
|
||
const columns = ['totalCases', 'passedCases', 'failedCases'] as const; | ||
|
||
// Note: This migration was separated from common after release to remove column check constraints | ||
// because they were causing issues with MySQL | ||
|
||
export class AddStatsColumnsToTestRun1736172058779 implements ReversibleMigration { | ||
async up({ escape, runQuery }: MigrationContext) { | ||
const tableName = escape.tableName('test_run'); | ||
const columnNames = columns.map((name) => escape.columnName(name)); | ||
|
||
// Values can be NULL only if the test run is new, otherwise they must be non-negative integers. | ||
// Test run might be cancelled or interrupted by unexpected error at any moment, so values can be either NULL or non-negative integers. | ||
for (const name of columnNames) { | ||
await runQuery(`ALTER TABLE ${tableName} ADD COLUMN ${name} INT;`); | ||
} | ||
} | ||
|
||
async down({ escape, runQuery }: MigrationContext) { | ||
const tableName = escape.tableName('test_run'); | ||
const columnNames = columns.map((name) => escape.columnName(name)); | ||
|
||
for (const name of columnNames) { | ||
await runQuery(`ALTER TABLE ${tableName} DROP COLUMN ${name}`); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/cli/src/databases/migrations/mysqldb/1739873751194-FixTestDefinitionPrimaryKey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import assert from 'node:assert'; | ||
|
||
import type { MigrationContext, IrreversibleMigration } from '@/databases/types'; | ||
|
||
export class FixTestDefinitionPrimaryKey1739873751194 implements IrreversibleMigration { | ||
async up({ queryRunner, tablePrefix }: MigrationContext) { | ||
/** | ||
* MigrateTestDefinitionKeyToString migration for MySQL/MariaDB had missing part, | ||
* and didn't complete primary key type change and deletion of the temporary column. | ||
* | ||
* This migration checks if table is in inconsistent state and finishes the primary key type change when needed. | ||
* | ||
* The MigrateTestDefinitionKeyToString migration has been patched to properly change the primary key. | ||
* | ||
* As the primary key issue might prevent the CreateTestMetricTable migration from running successfully on MySQL 8.4.4, | ||
* the CreateTestMetricTable also contains the patch. | ||
* | ||
* For users who already ran the MigrateTestDefinitionKeyToString and CreateTestMetricTable, this migration should fix the primary key. | ||
* For users who run these migrations in the same batch, this migration would be no-op, as the test_definition table should be already fixed | ||
* by either of the previous patched migrations. | ||
*/ | ||
|
||
const table = await queryRunner.getTable(`${tablePrefix}test_definition`); | ||
assert(table, 'test_definition table not found'); | ||
|
||
const brokenPrimaryColumn = table.primaryColumns.some( | ||
(c) => c.name === 'tmp_id' && c.isPrimary, | ||
); | ||
|
||
if (brokenPrimaryColumn) { | ||
// The migration was completed, but left the table in inconsistent state, let's finish the primary key change | ||
await queryRunner.query( | ||
`ALTER TABLE ${tablePrefix}test_definition MODIFY COLUMN tmp_id INT NOT NULL;`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE ${tablePrefix}test_definition DROP PRIMARY KEY, ADD PRIMARY KEY (\`id\`);`, | ||
); | ||
await queryRunner.query( | ||
`DROP INDEX \`TMP_idx_${tablePrefix}test_definition_id\` ON ${tablePrefix}test_definition;`, | ||
); | ||
await queryRunner.query(`ALTER TABLE ${tablePrefix}test_definition DROP COLUMN tmp_id;`); | ||
} | ||
} | ||
} |
Oops, something went wrong.