Skip to content

Commit

Permalink
Merge branch 'main' into BC-7772-introduce-ddd-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
CeEv authored Sep 16, 2024
2 parents 6e095be + ca17bee commit 0dd317b
Show file tree
Hide file tree
Showing 380 changed files with 10,995 additions and 1,482 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/publish_pages.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ jobs:
with:
sarif_file: 'trivy-results.sarif'

end-to-end-tests:
needs:
- build_and_push
- branch_meta
uses: hpi-schul-cloud/end-to-end-tests/.github/workflows/e2e_call.yml@main
with:
ref: ${{ needs.branch_meta.outputs.branch }}

cy-e2e-tests:
needs:
- branch_meta
Expand All @@ -202,10 +194,3 @@ jobs:
ref: ${{ needs.branch_meta.outputs.branch }}
secrets:
service-account-token: ${{ secrets.CYPRESS_ONEPWD_SERVICE_ACCOUNT_TOKEN }}

test-successful:
runs-on: ubuntu-latest
needs:
- end-to-end-tests
steps:
- run: echo "Test was successful"
47 changes: 0 additions & 47 deletions .github/workflows/test_unstable_e2e.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
*.loadtest.json

# Runtime data
pids
Expand Down
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=hpi-schul-cloud_schulcloud-server&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=hpi-schul-cloud_schulcloud-server)
## NestJS application

> Find the [NestJS applications documentation](https://hpi-schul-cloud.github.io/schulcloud-server/additional-documentation/nestjs-application.html) of this repository at GitHub pages. It contains information about
Based on [NestJS](https://docs.nestjs.com/)

> Find the [documentation](https://documentation.dbildungscloud.dev/docs/schulcloud-server/architecture) of this repository at GitHub pages. It contains information about
- setup & preconditions
- starting the application
- testing
- tools setup (VSCode, Git)
- api design
- code guidelines
- development
- migrations
- architecture

Based on [NestJS](https://docs.nestjs.com/)
There is also some old documentation in the server code /apps/server/doc/*.md.

Note that not all the .md file here are up to date.


## Feathers application

Expand Down Expand Up @@ -44,18 +49,10 @@ It is possible (not very likely) that the server api is called with URLs that us

When these paths are accessed an error with context `[DEPRECATED-PATH]` is logged.

## Setup

The whole application setup with all dependencies can be found in [System Architecture](https://docs.dbildungscloud.de/display/DBH/System+Architecture). It contains information about how different application components are connected to each other.

## Debugger Configuration in Visual Studio Code

For more details how to set up Visual Studio Code, read [this document](https://docs.dbildungscloud.de/display/DBH/Visual+Studio+Code+-+Beginners+Guide).

## How to name your branch and create a pull request (PR)

1. Take the Ticket Number from JIRA (ticketsystem.dbildungscloud.de), e.g. SC-999
2. Name the feature branch beginning with Ticket Number, all words separated by dash "-", e.g. `feature/SC-999-fantasy-problem`
2. Name the feature branch beginning with Ticket Number, all words separated by dash "-", e.g. `SC-999-fantasy-problem`
3. Create a PR on branch develop containing the Ticket Number in PR title
4. Keep the `WIP` label as long as this PR is in development, complete PR checklist (is automatically added), keep or increase code test coverage, and pass all tests before you remove the `WIP` label. Reviewers will be added automatically.

Expand All @@ -66,7 +63,7 @@ Default branch: `main`
1. Go into project folder
2. Checkout to develop branch (or clone for the first time)
3. Run `git pull`
4. Create a branch for your new feature named feature/BC-*Ticket-ID*-*Description*
4. Create a branch for your new feature named BC-*Ticket-ID*-*Description*
5. Run the tests (see above)
6. Commit with a meaningful commit message(!) even at 4 a.m. and not stuff like "dfsdfsf"
7. Start a pull request (see above) to branch develop to merge your changes
28 changes: 25 additions & 3 deletions ansible/roles/schulcloud-server-core/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,28 @@
tags:
- ingress


- name: remove old tldraw migration Job
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
api_version: batch/v1
kind: Job
name: tldraw-migration-job
state: absent
wait: yes
tags:
- job

- name: tldraw migration Job
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: tldraw-migration-job.yml.j2
when: WITH_TLDRAW2 is defined and WITH_TLDRAW2|bool
tags:
- job

- name: Delete Files CronJob
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
Expand All @@ -188,7 +210,7 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: tldraw-delete-files-cronjob.yml.j2
when: WITH_TLDRAW is defined and WITH_TLDRAW|bool
state: "{{ 'present' if WITH_TLDRAW else 'absent'}}"
tags:
- cronjob

Expand Down Expand Up @@ -315,7 +337,7 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: tldraw-deployment.yml.j2
when: WITH_TLDRAW is defined and WITH_TLDRAW|bool
state: "{{ 'present' if WITH_TLDRAW else 'absent'}}"
tags:
- deployment

Expand Down Expand Up @@ -343,7 +365,7 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: tldraw-svc-monitor.yml.j2
when: WITH_TLDRAW is defined and WITH_TLDRAW|bool
state: "{{ 'present' if WITH_TLDRAW else 'absent'}}"
tags:
- prometheus

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: batch/v1
kind: Job
metadata:
name: tldraw-migration-job
namespace: {{ NAMESPACE }}
labels:
app: tldraw-migration
spec:
template:
metadata:
labels:
app: tldraw-migration
spec:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
runAsNonRoot: true
containers:
- name: tldraw-migration-job
image: {{ SCHULCLOUD_SERVER_IMAGE }}:{{ SCHULCLOUD_SERVER_IMAGE_TAG }}
imagePullPolicy: IfNotPresent
# this is just for this job and should not be an example for anyone else
envFrom:
- configMapRef:
name: api-configmap
- secretRef:
name: api-secret
- secretRef:
name: api-files-secret
- secretRef:
name: tldraw-server-secret
command: ['/bin/sh','-c']
args: ['npm run nest:start:tldraw-console -- migration run']
resources:
limits:
cpu: {{ TLDRAW_MIGRATION_CPU_REQUESTS|default("2000m", true) }}
memory: {{ TLDRAW_MIGRATION_MEMORY_REQUESTS|default("2Gi", true) }}
requests:
cpu: {{ TLDRAW_MIGRATION_CPU_REQUESTS|default("100m", true) }}
memory: {{ TLDRAW_MIGRATION_MEMORY_REQUESTS|default("150Mi", true) }}
restartPolicy: Never
backoffLimit: 5
1 change: 0 additions & 1 deletion apps/assets/README.md

This file was deleted.

9 changes: 2 additions & 7 deletions apps/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ Beside existing [scripts](/), for the nestJS application the following scripts h
- `nest:start:files-storage:debug` run **file storage** in dev-mode with hot-reload and debug port opened on port :9229
- `nest:start:files-storage:prod` start **file storage** in production mode, requires `nest:build` to be executed beforehand

#### How to build and serve the documentation

- `nest:docs:build` builds code documentation and module relations into /documentation folder
- `nest:docs:serve` builds code documentation and module relations into /documentation folder and serves it on port :8080 with hot reload on changes

#### How to start the server console

The console offers management capabilities of the application.
Expand Down Expand Up @@ -132,9 +127,9 @@ Legacy/feathers Swagger UI documentation when running the server locally, it is

### How to get full documentation

The documentation is provided by compodoc, run `npm run nest:docs:serve`, check generated compodoc features, custom information can be found in additional information section. Your console will tell you, where it is served.
We have an extra repository for our documentation.

The updated documentation is published as [GitHub Page](https://hpi-schul-cloud.github.io/schulcloud-server/additional-documentation/nestjs-application.html)
[Doc Page](https://documentation.dbildungscloud.dev/)

### Content

Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/console/console.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@src/config';
import { ConsoleModule } from 'nestjs-console';
import { SyncModule } from '@infra/sync/sync.module';
import { ServerConsole } from './server.console';
import { mikroOrmCliConfig } from '../config/mikro-orm-cli.config';

Expand All @@ -21,6 +22,7 @@ import { mikroOrmCliConfig } from '../config/mikro-orm-cli.config';
ConfigModule.forRoot(createConfigModuleOptions(serverConfig)),
...((Configuration.get('FEATURE_IDENTITY_MANAGEMENT_ENABLED') as boolean) ? [KeycloakModule] : []),
MikroOrmModule.forRoot(mikroOrmCliConfig),
SyncModule,
],
providers: [
/** add console services as providers */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { SystemService } from '@modules/system';
import { HttpService } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';

import { systemFactory } from '@shared/testing';
import { systemFactory } from '@modules/system/testing';
import { AxiosResponse } from 'axios';
import { of } from 'rxjs';
import { v1 } from 'uuid';
Expand Down
49 changes: 49 additions & 0 deletions apps/server/src/infra/sync/console/sync.console.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { createMock } from '@golevelup/ts-jest';
import { Test } from '@nestjs/testing';
import { Logger } from '@src/core/logger';
import { SyncUc } from '../uc/sync.uc';
import { SyncConsole } from './sync.console';

describe(SyncConsole.name, () => {
let syncConsole: SyncConsole;
let syncUc: SyncUc;

beforeAll(async () => {
const module = await Test.createTestingModule({
providers: [
SyncConsole,
{
provide: SyncUc,
useValue: createMock<SyncUc>(),
},
{
provide: Logger,
useValue: createMock<Logger>(),
},
],
}).compile();

syncConsole = module.get(SyncConsole);
syncUc = module.get(SyncUc);
});

describe('when sync console is initialized', () => {
it('should be defined', () => {
expect(syncConsole).toBeDefined();
});
});

describe('startSync', () => {
const setup = () => {
const target = 'tsp';
return { target };
};

it('should call startSync method of syncUc', async () => {
const { target } = setup();
await syncConsole.startSync(target);

expect(syncUc.startSync).toHaveBeenCalledWith(target);
});
});
});
18 changes: 18 additions & 0 deletions apps/server/src/infra/sync/console/sync.console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Logger } from '@src/core/logger';
import { Command, Console } from 'nestjs-console';
import { SyncUc } from '../uc/sync.uc';

@Console({ command: 'sync', description: 'Prefixes all synchronization related console commands.' })
export class SyncConsole {
constructor(private readonly syncUc: SyncUc, private readonly logger: Logger) {
this.logger.setContext(SyncConsole.name);
}

@Command({
command: 'run <target>',
description: 'Starts the synchronization process.',
})
public async startSync(target: string): Promise<void> {
await this.syncUc.startSync(target);
}
}
Loading

0 comments on commit 0dd317b

Please sign in to comment.