Skip to content

Commit

Permalink
feat: fix crud e2e on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiocro committed Nov 2, 2024
1 parent 089c014 commit 881f7ad
Show file tree
Hide file tree
Showing 51 changed files with 1,004 additions and 1,152 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ next-env.d.ts
cloud_sql_proxy

# turbo
.turbo
**/.turbo/*
!**/.turbo/config.json

## crud test migrations
/libs/crud/test/e2e/migrations/

# testing
Expand Down
42 changes: 14 additions & 28 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
image: node:20-alpine

services:
- name: docker:dind
command: ["--tls=false"]
- name: docker:24.0.6-dind
command:
- --tls=false
- --registry-mirror=https://mirror.gcr.io

variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://0.0.0.0:2375
DOCKER_TLS_CERTDIR: ''
DOCKER_DRIVER: overlay2
TESTCONTAINERS_HOST_OVERRIDE: "host.docker.internal"
KUBERNETES_CPU_REQUEST: "0.5"
KUBERNETES_CPU_LIMIT: "1"
DOCKER_BUILDKIT: '1'
KUBERNETES_CPU_REQUEST: '0.5'
KUBERNETES_CPU_LIMIT: '1'
KUBERNETES_MEMORY_REQUEST: 2Gi
KUBERNETES_MEMORY_LIMIT: 4Gi

Expand All @@ -28,7 +30,7 @@ stages:

build-lib:
stage: build
only: ["merge_requests", "main"]
only: ['merge_requests', 'main']
script:
- yarn --immutable
- yarn build --filter='./libs/*'
Expand All @@ -39,7 +41,7 @@ build-lib:

build-samples:
stage: build
only: ["merge_requests", "main"]
only: ['merge_requests', 'main']
allow_failure: true
script:
- yarn --immutable
Expand All @@ -56,25 +58,9 @@ build-samples:
# - yarn --immutable
# - yarn changesets-gitlab comment

lint-lib:
stage: test
only: ["merge_requests", "main"]
script:
- yarn --immutable
- yarn turbo run lint --filter='./libs/*'
cache:
paths:
- node_modules/
- .yarn

# manual beacuse not working properly:
# Could not find a working container runtime strategy
# const pgContainer = await new PostgreSqlContainer()'
test-lib:
stage: test
only: ["merge_requests", "main"]
allow_failure: true
when: manual
only: ['merge_requests', 'main']
script:
- yarn --immutable
- yarn turbo run test --filter='./libs/*'
Expand All @@ -88,7 +74,7 @@ test-lib:

test-samples:
stage: test
only: ["merge_requests", "main"]
only: ['merge_requests', 'main']
allow_failure: true
script:
- yarn --immutable
Expand All @@ -101,7 +87,7 @@ test-samples:

release:
stage: release
only: ["main"]
only: ['main']
script:
- apk add --no-cache git
- yarn --immutable
Expand Down
5 changes: 5 additions & 0 deletions .turbo/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"teamId":"team_manul",
"apiUrl": "https://pan-turbo-cache-prod-turbo-cache-v4e7fsmyqa-oa.a.run.app/turbo/api",
"loginUrl": "https://pan-turbo-cache-prod-turbo-cache-v4e7fsmyqa-oa.a.run.app/turbo/login"
}
6 changes: 3 additions & 3 deletions libs/asset-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"@rummel/eslint-config-custom": "*",
"@rummel/tsconfig": "*",
"@types/uuid": "^9.0.7",
"eslint": "8.57.0",
"rimraf": "^5.0.5",
"typescript": "^5.3.3",
"eslint": "8.57.1",
"rimraf": "^6.0.1",
"typescript": "^5.6.3",
"uuid": "^9.0.1"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions libs/auth-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"devDependencies": {
"@rummel/eslint-config-custom": "*",
"@rummel/tsconfig": "*",
"eslint": "8.57.0",
"eslint": "8.57.1",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"typescript": "^5.3.3"
"rimraf": "^6.0.1",
"typescript": "^5.6.3"
},
"peerDependencies": {
"react": "18"
"react": "18.2.0"
},
"dependencies": {
"@apollo/client": "^3.11.8",
Expand Down
36 changes: 19 additions & 17 deletions libs/crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
},
"dependencies": {
"lodash": "^4.17.21",
"nestjs-pino": "^4.1.0",
"pino-http": "^10.3.0",
"pluralize": "^8.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -63,25 +65,25 @@
"typescript": "^5.6.3"
},
"peerDependencies": {
"@mikro-orm/cli": "6.3.x",
"@mikro-orm/core": "6.3.x",
"@mikro-orm/migrations": "6.3.x",
"@mikro-orm/nestjs": "6.0.x",
"@mikro-orm/postgresql": "6.3.x",
"@mikro-orm/reflection": "6.3.x",
"@mikro-orm/seeder": "6.3.x",
"@mikro-orm/sql-highlighter": "^1.0.x",
"@nestjs/apollo": "^12.2.x",
"@nestjs/common": "^10.4.x",
"@mikro-orm/cli": "6.3.13",
"@mikro-orm/core": "6.3.13",
"@mikro-orm/migrations": "6.3.13",
"@mikro-orm/nestjs": "6.0.2",
"@mikro-orm/postgresql": "6.3.13",
"@mikro-orm/reflection": "6.3.13",
"@mikro-orm/seeder": "6.3.13",
"@mikro-orm/sql-highlighter": "^1.0.1",
"@nestjs/apollo": "^12.2.1",
"@nestjs/common": "^10.4.6",
"@nestjs/config": "^3.3.x",
"@nestjs/core": "^10.4.x",
"@nestjs/graphql": "^12.2.x",
"@nestjs/core": "^10.4.6",
"@nestjs/graphql": "^12.2.1",
"@panter/nestjs-utils": "*",
"class-transformer": "^0.5.x",
"class-validator": "^0.14.x",
"graphql": "^16.9.x",
"reflect-metadata": "^0.2.x",
"rxjs": "^7.8.x"
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"graphql": "^16.9.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
},
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion libs/crud/src/crud.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type CrudModuleAsyncOptions<T> = ModuleAsyncOptions<
CrudModuleOptions<T>
> & { defaultRelationModifier?: boolean };

let relationModifier: boolean | undefined = undefined;
let relationModifier: boolean | undefined = true;

export const defaultRelationModifier = () => relationModifier;

Expand Down
45 changes: 27 additions & 18 deletions libs/crud/src/graphql/many-relation-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,37 @@ import { typesCache } from './types-cache';
import { updateManyEntityInput } from './update-many-entity-input';
import { upsertInput } from './upsert-input';
import { getTypeName } from './utils';
import { operationsName } from './update-one-relation-input';

// CRO TODO: hideReference, hideDisconnect
export const manyRelationInput = <T, NA extends string>(
classRef: CrudEntityType<T, NA>,
isUpdate: boolean,
options?: {
options: {
parentRef: CrudEntityType;
hideConnect?: boolean;
hideCreate?: boolean;
hideUpdate?: boolean;
hideDisconnect?: boolean;
parentProperty?: string;
},
) => {
const operations = operationsName({
...options,
hideUpdate: isUpdate ? options.hideUpdate : true,
});

if (operations === '') {
return undefined;
}

const typeName = getTypeName(classRef);
const withoutTypeName = options?.parentRef
? `Without${getTypeName(options?.parentRef)}`
const withoutTypeName = options.parentRef
? `Without${getTypeName(options.parentRef)}`
: '';
const operationsName =
!options?.hideCreate && !options?.hideUpdate
? 'ConnectCreateUpdate'
: !options?.hideCreate
? 'ConnectCreate'
: !options?.hideUpdate
? 'ConnectUpdate'
: 'Connect';

const type = isUpdate ? 'Update' : 'Create';
const name = `${typeName}${operationsName}NestedMany${withoutTypeName}${type}Input`;
const name = `${typeName}${operations}Many${withoutTypeName}${type}Input`;

if (typesCache[name]) {
return typesCache[name];
Expand All @@ -41,7 +44,6 @@ export const manyRelationInput = <T, NA extends string>(
@ArgsType()
@InputType(name, { isAbstract: false })
class RelationInputArgsType {
@Field(() => [ConnectRelationInput], { nullable: true })
connect?: ConnectRelationInput[];

disconnect?: EntityIdInput[];
Expand All @@ -53,29 +55,36 @@ export const manyRelationInput = <T, NA extends string>(

typesCache[name] = RelationInputArgsType;

if (!options?.hideCreate) {
if (!options.hideConnect) {
Field(() => [ConnectRelationInput], { nullable: true })(
RelationInputArgsType.prototype,
'connect',
);
}

if (!options.hideCreate) {
// call createInput after adding to cache because of recursive call
const CreateInputType = upsertInput(classRef, {
ignoreType: options?.parentRef,
ignoreType: options.parentRef,
});
Field(() => [CreateInputType], { nullable: true })(
RelationInputArgsType.prototype,
'create',
);
}

if (!options?.hideUpdate) {
if (isUpdate && !options.hideUpdate) {
// call createInput after adding to cache because of recursive call
const UpdateInputType = updateManyEntityInput(classRef, {
ignoreType: options?.parentRef,
ignoreType: options.parentRef,
});
Field(() => [UpdateInputType], { nullable: true })(
RelationInputArgsType.prototype,
'update',
);
}

if (!options?.hideDisconnect) {
if (!options.hideDisconnect) {
// call createInput after adding to cache because of recursive call
Field(() => [EntityIdInput], { nullable: true })(
RelationInputArgsType.prototype,
Expand Down
Loading

0 comments on commit 881f7ad

Please sign in to comment.