From f2d165aa601d04f6f6c651f6e21bff4352787880 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Wed, 2 Apr 2025 19:49:40 +0200 Subject: [PATCH 1/7] ci: Merge testing actions --- .github/workflows/testing.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..78253d2b --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,56 @@ +name: Combined Testing + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + types: ["synchronize", "ready_for_review", "opened", "reopened"] + +jobs: + backend-test: + name: Run backend unit tests + if: "! github.event.pull_request.draft" + runs-on: [self-hosted, Linux, X64] + strategy: + matrix: + node-version: [22.x] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run test:unit -w backend + paths: + - 'backend/src/**.[jt]s' + - 'backend/tests/**.[jt]s' + - 'backend/vitest.config.ts' + + frontend-test: + name: Run frontend unit tests + if: "! github.event.pull_request.draft" + runs-on: [self-hosted, Linux, X64] + strategy: + matrix: + node-version: [22.x] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run test:unit -w frontend + paths: + - 'frontend/src/**.[jt]s' + - 'frontend/src/**.vue' + - 'frontend/src/**.css' + - 'frontend/tests/**.[jt]s' + - 'frontend/tests/**.vue' + - 'frontend/tests/**.css' + - 'frontend/vitest.config.ts' + - 'frontend/playwright.config.ts' From 80dc3acca7791ee449dda7c33bb2271519abdea4 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Wed, 2 Apr 2025 20:03:08 +0200 Subject: [PATCH 2/7] Revert "ci: Merge testing actions" This reverts commit f2d165aa601d04f6f6c651f6e21bff4352787880. --- .github/workflows/testing.yml | 56 ----------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml deleted file mode 100644 index 78253d2b..00000000 --- a/.github/workflows/testing.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Combined Testing - -on: - push: - branches: [ "dev" ] - pull_request: - branches: [ "dev" ] - types: ["synchronize", "ready_for_review", "opened", "reopened"] - -jobs: - backend-test: - name: Run backend unit tests - if: "! github.event.pull_request.draft" - runs-on: [self-hosted, Linux, X64] - strategy: - matrix: - node-version: [22.x] - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run test:unit -w backend - paths: - - 'backend/src/**.[jt]s' - - 'backend/tests/**.[jt]s' - - 'backend/vitest.config.ts' - - frontend-test: - name: Run frontend unit tests - if: "! github.event.pull_request.draft" - runs-on: [self-hosted, Linux, X64] - strategy: - matrix: - node-version: [22.x] - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run test:unit -w frontend - paths: - - 'frontend/src/**.[jt]s' - - 'frontend/src/**.vue' - - 'frontend/src/**.css' - - 'frontend/tests/**.[jt]s' - - 'frontend/tests/**.vue' - - 'frontend/tests/**.css' - - 'frontend/vitest.config.ts' - - 'frontend/playwright.config.ts' From 7e46ce9c5fb73c72d219105ade6a3cfc482a21c7 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Wed, 2 Apr 2025 20:31:40 +0200 Subject: [PATCH 3/7] fix: Linting op Actions --- .github/workflows/lint-action.yml | 4 ++-- .gitignore | 2 +- .../learning-path/learning-path-service.test.ts | 2 +- eslint.config.ts | 13 +++++++++++-- package-lock.json | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index 32823417..7fd77d28 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -43,6 +43,6 @@ jobs: with: auto_fix: true eslint: true - eslint_args: '--config eslint.config.ts' + eslint_args: "--config eslint.config.ts --ignore-pattern '**/prettier.config.js'" prettier: true - commit_message: 'style: fix linting issues met ${linter}' \ No newline at end of file + commit_message: 'style: fix linting issues met ${linter}' diff --git a/.gitignore b/.gitignore index d28e7d73..d3905d1f 100644 --- a/.gitignore +++ b/.gitignore @@ -737,4 +737,4 @@ flycheck_*.el # network security /network-security.data - +docs/.venv diff --git a/backend/tests/services/learning-path/learning-path-service.test.ts b/backend/tests/services/learning-path/learning-path-service.test.ts index 934c677b..4feb3627 100644 --- a/backend/tests/services/learning-path/learning-path-service.test.ts +++ b/backend/tests/services/learning-path/learning-path-service.test.ts @@ -48,7 +48,7 @@ describe('LearningPathService', () => { expect(result.data?.length).toBe(1); // Should include all the nodes, even those pointing to foreign learning objects. - expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort()).toEqual( + expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort((a, b) => a - b)).toEqual( example.learningPath.nodes.map((it) => it.learningObjectHruid).sort() ); }); diff --git a/eslint.config.ts b/eslint.config.ts index 831b213f..12943414 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -16,7 +16,16 @@ export default [ prettierConfig, includeIgnoreFile(gitignorePath), { - ignores: ['**/dist/**', '**/.node_modules/**', '**/coverage/**', '**/.github/**'], + ignores: [ + '**/dist/**', + '**/.node_modules/**', + '**/coverage/**', + '**/.github/**', + '**/prettier.config.js', + 'docs/.venv/**', + 'prettier.config.js', + 'frontend/prettier.config.js' + ], files: ['**/*.ts', '**/*.cts', '**.*.mts'], }, { @@ -205,6 +214,6 @@ export default [ 'no-multi-assign': 'error', 'no-nested-ternary': 'error', 'no-object-constructor': 'error', - }, + } }, ]; diff --git a/package-lock.json b/package-lock.json index 79ebf319..27d261cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "dwengo-1-monorepo", + "name": "dwengo-1", "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "dwengo-1-monorepo", + "name": "dwengo-1", "version": "0.1.1", "license": "MIT", "workspaces": [ From 0bdee56dc391ba33c2ea11b96f2203d6f53e2757 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Wed, 2 Apr 2025 18:32:29 +0000 Subject: [PATCH 4/7] style: fix linting issues met Prettier --- .../src/entities/content/learning-object-identifier.ts | 2 +- .../dwengo-api-learning-object-provider.ts | 2 +- .../services/learning-objects/learning-object-service.ts | 6 +----- backend/src/services/questions.ts | 8 ++++---- backend/src/util/links.ts | 2 +- backend/tsconfig.json | 2 +- common/package.json | 4 +++- common/src/interfaces/learning-content.ts | 2 +- eslint.config.ts | 4 ++-- tsconfig.json | 8 ++++---- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/backend/src/entities/content/learning-object-identifier.ts b/backend/src/entities/content/learning-object-identifier.ts index b7802ddd..09a9c057 100644 --- a/backend/src/entities/content/learning-object-identifier.ts +++ b/backend/src/entities/content/learning-object-identifier.ts @@ -1,4 +1,4 @@ -import { Language } from "@dwengo-1/common/util/language"; +import { Language } from '@dwengo-1/common/util/language'; export class LearningObjectIdentifier { constructor( diff --git a/backend/src/services/learning-objects/dwengo-api-learning-object-provider.ts b/backend/src/services/learning-objects/dwengo-api-learning-object-provider.ts index ffa57814..d67b69ae 100644 --- a/backend/src/services/learning-objects/dwengo-api-learning-object-provider.ts +++ b/backend/src/services/learning-objects/dwengo-api-learning-object-provider.ts @@ -69,7 +69,7 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full nodes.map(async (node) => { const learningObjectId: LearningObjectIdentifier = { hruid: node.learningobject_hruid, - language: learningPathId.language + language: learningPathId.language, }; return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId); }) diff --git a/backend/src/services/learning-objects/learning-object-service.ts b/backend/src/services/learning-objects/learning-object-service.ts index 69004ae1..5a06f0f2 100644 --- a/backend/src/services/learning-objects/learning-object-service.ts +++ b/backend/src/services/learning-objects/learning-object-service.ts @@ -2,11 +2,7 @@ import dwengoApiLearningObjectProvider from './dwengo-api-learning-object-provid import { LearningObjectProvider } from './learning-object-provider.js'; import { envVars, getEnvVar } from '../../util/envVars.js'; import databaseLearningObjectProvider from './database-learning-object-provider.js'; -import { - FilteredLearningObject, - LearningObjectIdentifier, - LearningPathIdentifier, -} from '@dwengo-1/common/interfaces/learning-content'; +import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; function getProvider(id: LearningObjectIdentifier): LearningObjectProvider { if (id.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) { diff --git a/backend/src/services/questions.ts b/backend/src/services/questions.ts index 6609a813..f92efae0 100644 --- a/backend/src/services/questions.ts +++ b/backend/src/services/questions.ts @@ -78,7 +78,7 @@ export async function createQuestion(questionDTO: QuestionDTO): Promise Date: Thu, 3 Apr 2025 05:35:57 +0000 Subject: [PATCH 5/7] style: fix linting issues met Prettier --- backend/src/controllers/learning-objects.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/backend/src/controllers/learning-objects.ts b/backend/src/controllers/learning-objects.ts index 2a64edd7..a2510631 100644 --- a/backend/src/controllers/learning-objects.ts +++ b/backend/src/controllers/learning-objects.ts @@ -6,11 +6,7 @@ import attachmentService from '../services/learning-objects/attachment-service.j import { BadRequestException } from '../exceptions/bad-request-exception.js'; import { NotFoundException } from '../exceptions/not-found-exception.js'; import { envVars, getEnvVar } from '../util/envVars.js'; -import { - FilteredLearningObject, - LearningObjectIdentifier, - LearningPathIdentifier, -} from '@dwengo-1/common/interfaces/learning-content'; +import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier { if (!req.params.hruid) { From 6d7d29ce3c9c442d9fee728a4db5ef25269f9f82 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Thu, 3 Apr 2025 07:43:59 +0200 Subject: [PATCH 6/7] fix(backend): Restore sort --- .../tests/services/learning-path/learning-path-service.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/tests/services/learning-path/learning-path-service.test.ts b/backend/tests/services/learning-path/learning-path-service.test.ts index 4feb3627..934c677b 100644 --- a/backend/tests/services/learning-path/learning-path-service.test.ts +++ b/backend/tests/services/learning-path/learning-path-service.test.ts @@ -48,7 +48,7 @@ describe('LearningPathService', () => { expect(result.data?.length).toBe(1); // Should include all the nodes, even those pointing to foreign learning objects. - expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort((a, b) => a - b)).toEqual( + expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort()).toEqual( example.learningPath.nodes.map((it) => it.learningObjectHruid).sort() ); }); From ced27c148bee43ca2dd32aba4060450ea79062bb Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Thu, 3 Apr 2025 07:53:05 +0200 Subject: [PATCH 7/7] fixup! fix(backend): Restore sort --- .../services/learning-path/learning-path-service.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/tests/services/learning-path/learning-path-service.test.ts b/backend/tests/services/learning-path/learning-path-service.test.ts index 934c677b..972a7fa1 100644 --- a/backend/tests/services/learning-path/learning-path-service.test.ts +++ b/backend/tests/services/learning-path/learning-path-service.test.ts @@ -48,8 +48,8 @@ describe('LearningPathService', () => { expect(result.data?.length).toBe(1); // Should include all the nodes, even those pointing to foreign learning objects. - expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort()).toEqual( - example.learningPath.nodes.map((it) => it.learningObjectHruid).sort() + expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort((a, b) => a.localeCompare(b))).toEqual( + example.learningPath.nodes.map((it) => it.learningObjectHruid).sort((a, b) => a.localeCompare(b)) ); }); });