Skip to content

Commit

Permalink
ci: Use turbo for build cache (no-changelog)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Jun 11, 2024
1 parent aaa7843 commit 9480a36
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 85 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Build
run: pnpm build

Expand Down Expand Up @@ -64,6 +67,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Restore cached build artifacts
uses: actions/cache/[email protected]
with:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/ci-postgres-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
cache: 'pnpm'
- run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Build Backend
run: pnpm build:backend

Expand All @@ -52,6 +55,9 @@ jobs:
cache: 'pnpm'
- run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Restore cached build artifacts
uses: actions/cache/[email protected]
with:
Expand All @@ -78,6 +84,9 @@ jobs:
cache: 'pnpm'
- run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Restore cached build artifacts
uses: actions/cache/[email protected]
with:
Expand Down Expand Up @@ -112,6 +121,9 @@ jobs:
cache: 'pnpm'
- run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Restore cached build artifacts
uses: actions/cache/[email protected]
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Build
run: pnpm build

Expand Down Expand Up @@ -60,6 +63,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Restore cached build artifacts
uses: actions/cache/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- name: Set release version in env
run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV

- name: Setup build cache
uses: dtinth/[email protected]

- name: Build
run: pnpm build

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/units-tests-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup build cache
uses: dtinth/[email protected]

- name: Build
if: ${{ inputs.cacheKey == '' }}
run: pnpm build
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"scripts": {
"preinstall": "node scripts/block-npm-install.js",
"build": "turbo run build",
"build:backend": "pnpm --filter=!@n8n/chat --filter=!@n8n/codemirror-lang --filter=!n8n-design-system --filter=!n8n-editor-ui build",
"build:frontend": "pnpm --filter=@n8n/chat --filter=@n8n/codemirror-lang --filter=n8n-design-system --filter=n8n-editor-ui build",
"typecheck": "pnpm --filter=!@n8n/chat --filter=!@n8n/storybook --filter=!n8n-core --filter=!n8n-editor-ui --filter=!n8n-workflow --filter=!n8n typecheck",
"build:backend": "turbo run build:backend",
"build:frontend": "turbo run build:frontend",
"build:nodes": "turbo run build:nodes",
"typecheck": "turbo --filter=!@n8n/chat --filter=!@n8n/storybook --filter=!n8n-core --filter=!n8n-editor-ui --filter=!n8n-workflow --filter=!n8n typecheck",
"dev": "turbo run dev --parallel --filter=!n8n-design-system --filter=!@n8n/chat",
"dev:ai": "turbo run dev --parallel --filter=@n8n/nodes-langchain --filter=n8n --filter=n8n-core",
"clean": "turbo run clean --parallel",
Expand All @@ -26,9 +27,9 @@
"start:tunnel": "./packages/cli/bin/n8n start --tunnel",
"start:windows": "cd packages/cli/bin && n8n",
"test": "turbo run test",
"test:backend": "pnpm --filter=!@n8n/chat --filter=!@n8n/codemirror-lang --filter=!n8n-design-system --filter=!n8n-editor-ui --filter=!n8n-nodes-base --filter=!@n8n/n8n-nodes-langchain test",
"test:nodes": "pnpm --filter=n8n-nodes-base --filter=@n8n/n8n-nodes-langchain test",
"test:frontend": "pnpm --filter=@n8n/chat --filter=@n8n/codemirror-lang --filter=n8n-design-system --filter=n8n-editor-ui test",
"test:backend": "turbo run test:backend --concurrency=1",
"test:frontend": "turbo run test:frontend --concurrency=1",
"test:nodes": "turbo run test:nodes --concurrency=1",
"watch": "turbo run watch --parallel",
"webhook": "./packages/cli/bin/n8n webhook",
"worker": "./packages/cli/bin/n8n worker"
Expand All @@ -52,7 +53,7 @@
"ts-jest": "^29.1.1",
"tsc-alias": "^1.8.7",
"tsc-watch": "^6.0.4",
"turbo": "1.13.3",
"turbo": "2.0.3",
"typescript": "*",
"vite": "^5.2.12",
"vite-plugin-checker": "^0.6.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/@n8n/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build:pack": "node scripts/pack.js",
"preview": "vite preview",
"test:dev": "vitest",
"test": "vitest run --coverage",
"test": "vitest run",
"type-check": "vue-tsc --noEmit -p tsconfig.json --composite false",
"lint": "eslint . --ext .js,.ts,.vue --quiet",
"lintfix": "eslint . --ext .js,.ts,.vue --fix",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Config } from '@oclif/core';
import { nanoid } from 'nanoid';

import { CLI_DIR } from '@/constants';
import { InternalHooks } from '@/InternalHooks';
import { ImportCredentialsCommand } from '@/commands/import/credentials';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
Expand All @@ -9,9 +11,8 @@ import * as testDb from '../shared/testDb';
import { getAllCredentials, getAllSharedCredentials } from '../shared/db/credentials';
import { createMember, createOwner } from '../shared/db/users';
import { getPersonalProject } from '../shared/db/projects';
import { nanoid } from 'nanoid';

const oclifConfig = new Config({ root: __dirname });
const oclifConfig = new Config({ root: CLI_DIR });

async function importCredential(argv: string[]) {
const importer = new ImportCredentialsCommand(argv, oclifConfig);
Expand All @@ -20,10 +21,10 @@ async function importCredential(argv: string[]) {
}

beforeAll(async () => {
await oclifConfig.load();
mockInstance(InternalHooks);
mockInstance(LoadNodesAndCredentials);
await testDb.init();
await oclifConfig.load();
});

beforeEach(async () => {
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/test/integration/commands/import.cmd.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Config } from '@oclif/core';
import { nanoid } from 'nanoid';

import { CLI_DIR } from '@/constants';
import { InternalHooks } from '@/InternalHooks';
import { ImportWorkflowsCommand } from '@/commands/import/workflow';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
Expand All @@ -9,9 +11,8 @@ import * as testDb from '../shared/testDb';
import { getAllSharedWorkflows, getAllWorkflows } from '../shared/db/workflows';
import { createMember, createOwner } from '../shared/db/users';
import { getPersonalProject } from '../shared/db/projects';
import { nanoid } from 'nanoid';

const oclifConfig = new Config({ root: __dirname });
const oclifConfig = new Config({ root: CLI_DIR });

async function importWorkflow(argv: string[]) {
const importer = new ImportWorkflowsCommand(argv, oclifConfig);
Expand All @@ -20,10 +21,10 @@ async function importWorkflow(argv: string[]) {
}

beforeAll(async () => {
await oclifConfig.load();
mockInstance(InternalHooks);
mockInstance(LoadNodesAndCredentials);
await testDb.init();
await oclifConfig.load();
});

beforeEach(async () => {
Expand Down
36 changes: 19 additions & 17 deletions packages/cli/test/integration/commands/ldap/reset.test.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import { Reset } from '@/commands/ldap/reset';
import { Container } from 'typedi';
import { v4 as uuid } from 'uuid';
import { Config } from '@oclif/core';
import { EntityNotFoundError } from '@n8n/typeorm';

import * as testDb from '../../shared/testDb';
import { CLI_DIR } from '@/constants';
import { Reset } from '@/commands/ldap/reset';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
import { mockInstance } from '../../../shared/mocking';
import { InternalHooks } from '@/InternalHooks';
import { WorkflowRepository } from '@db/repositories/workflow.repository';
import { CredentialsRepository } from '@db/repositories/credentials.repository';
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
import { getLdapSynchronizations, saveLdapSynchronization } from '@/Ldap/helpers';
import { LdapService } from '@/Ldap/ldap.service';
import { Push } from '@/push';
import { WaitTracker } from '@/WaitTracker';

import * as testDb from '../../shared/testDb';
import { mockInstance } from '../../../shared/mocking';
import { createLdapUser, createMember, getUserById } from '../../shared/db/users';
import { createWorkflow } from '../../shared/db/workflows';
import { randomCredentialPayload } from '../../shared/random';
import { saveCredential } from '../../shared/db/credentials';
import Container from 'typedi';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { EntityNotFoundError } from '@n8n/typeorm';
import { Push } from '@/push';
import { SharedWorkflowRepository } from '@/databases/repositories/sharedWorkflow.repository';
import { SharedCredentialsRepository } from '@/databases/repositories/sharedCredentials.repository';
import { createTeamProject, findProject, getPersonalProject } from '../../shared/db/projects';
import { WaitTracker } from '@/WaitTracker';
import { getLdapSynchronizations, saveLdapSynchronization } from '@/Ldap/helpers';
import { createLdapConfig } from '../../shared/ldap';
import { LdapService } from '@/Ldap/ldap.service';
import { v4 as uuid } from 'uuid';
import { createTeamProject, findProject, getPersonalProject } from '../../shared/db/projects';

const oclifConfig = new Config({ root: __dirname });
const oclifConfig = new Config({ root: CLI_DIR });

async function resetLDAP(argv: string[]) {
const cmd = new Reset(argv, oclifConfig);
Expand All @@ -37,14 +39,14 @@ async function resetLDAP(argv: string[]) {
}

beforeAll(async () => {
await oclifConfig.load();
mockInstance(Push);
mockInstance(InternalHooks);
mockInstance(LoadNodesAndCredentials);
// This needs to be mocked, otherwise the time setInterval would prevent jest
// from exiting properly.
mockInstance(WaitTracker);
await testDb.init();
await oclifConfig.load();
});

afterAll(async () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/test/integration/commands/license.cmd.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { Config } from '@oclif/core';

import { CLI_DIR } from '@/constants';
import { InternalHooks } from '@/InternalHooks';
import { License } from '@/License';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
import { ClearLicenseCommand } from '@/commands/license/clear';
import { Config } from '@oclif/core';

import { mockInstance } from '../../shared/mocking';

const oclifConfig = new Config({ root: __dirname });
const oclifConfig = new Config({ root: CLI_DIR });

beforeAll(async () => {
await oclifConfig.load();
mockInstance(InternalHooks);
mockInstance(LoadNodesAndCredentials);
await oclifConfig.load();
});

test('license:clear invokes shutdown() to release any floating entitlements', async () => {
Expand Down
22 changes: 15 additions & 7 deletions packages/cli/test/integration/commands/reset.cmd.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import { Container } from 'typedi';
import { Config } from '@oclif/core';

import { CLI_DIR } from '@/constants';
import { Reset } from '@/commands/user-management/reset';
import { InternalHooks } from '@/InternalHooks';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
import { NodeTypes } from '@/NodeTypes';
import Container from 'typedi';
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
import { CredentialsRepository } from '@db/repositories/credentials.repository';
import { CredentialsEntity } from '@db/entities/CredentialsEntity';
import { SettingsRepository } from '@db/repositories/settings.repository';
import { UserRepository } from '@db/repositories/user.repository';

import { mockInstance } from '../../shared/mocking';
import * as testDb from '../shared/testDb';
import { createMember, createUser } from '../shared/db/users';
import { createWorkflow } from '../shared/db/workflows';
import { SharedWorkflowRepository } from '@/databases/repositories/sharedWorkflow.repository';
import { getPersonalProject } from '../shared/db/projects';
import { encryptCredentialData, saveCredential } from '../shared/db/credentials';
import { randomCredentialPayload } from '../shared/random';
import { SharedCredentialsRepository } from '@/databases/repositories/sharedCredentials.repository';
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
import { CredentialsEntity } from '@/databases/entities/CredentialsEntity';
import { SettingsRepository } from '@/databases/repositories/settings.repository';

const oclifConfig = new Config({ root: CLI_DIR });

beforeAll(async () => {
await oclifConfig.load();
mockInstance(InternalHooks);
mockInstance(LoadNodesAndCredentials);
mockInstance(NodeTypes);
Expand Down Expand Up @@ -65,7 +71,9 @@ test('user-management:reset should reset DB to default user state', async () =>
//
// ACT
//
await Reset.run();
const reset = new Reset([], oclifConfig);
await reset.init();
await reset.run();

//
// ASSERT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Config } from '@oclif/core';

import { CLI_DIR } from '@/constants';
import { InternalHooks } from '@/InternalHooks';
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
import { UpdateWorkflowCommand } from '@/commands/update/workflow';
Expand All @@ -7,13 +9,13 @@ import * as testDb from '../../shared/testDb';
import { createWorkflowWithTrigger, getAllWorkflows } from '../../shared/db/workflows';
import { mockInstance } from '../../../shared/mocking';

const oclifConfig = new Config({ root: __dirname });
const oclifConfig = new Config({ root: CLI_DIR });

beforeAll(async () => {
await oclifConfig.load();
mockInstance(InternalHooks);
mockInstance(LoadNodesAndCredentials);
await testDb.init();
await oclifConfig.load();
});

beforeEach(async () => {
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/test/integration/commands/worker.cmd.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Config } from '@oclif/core';
import { BinaryDataService } from 'n8n-core';

import { CLI_DIR } from '@/constants';
import { Worker } from '@/commands/worker';
import config from '@/config';
import { Telemetry } from '@/telemetry';
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
import { BinaryDataService } from 'n8n-core';
import { CacheService } from '@/services/cache/cache.service';
import { RedisServicePubSubPublisher } from '@/services/redis/RedisServicePubSubPublisher';
import { RedisServicePubSubSubscriber } from '@/services/redis/RedisServicePubSubSubscriber';
Expand All @@ -20,11 +22,12 @@ import { OrchestrationService } from '@/services/orchestration.service';
import * as testDb from '../shared/testDb';
import { mockInstance } from '../../shared/mocking';

const oclifConfig = new Config({ root: __dirname });
const oclifConfig = new Config({ root: CLI_DIR });

let eventBus: MessageEventBus;

beforeAll(async () => {
await oclifConfig.load();
config.set('executions.mode', 'queue');
config.set('binaryDataManager.availableModes', 'filesystem');
mockInstance(Telemetry);
Expand All @@ -42,7 +45,6 @@ beforeAll(async () => {
mockInstance(RedisServicePubSubSubscriber);
mockInstance(OrchestrationService);
await testDb.init();
await oclifConfig.load();
});

afterAll(async () => {
Expand Down
Loading

0 comments on commit 9480a36

Please sign in to comment.