From 3dd7b9cb0b30acdedc3b6733f68052a48c43e8c1 Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 13:56:25 +0300 Subject: [PATCH 1/5] remove temporary unit test filter --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc6156c..3b1d9af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: run: pnpm run build - name: ๐Ÿงช Run tests with coverage - run: pnpm run test:cov -t controller + run: pnpm run test:cov - name: ๐Ÿ“ค Upload coverage report uses: actions/upload-artifact@v4 From eb4e4320ce15c7c8291b315d40737c6bc8755828 Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 14:04:47 +0300 Subject: [PATCH 2/5] Merge branch 'main' of https://github.com/ProGamer2711/ClassCompassServerMini into feat-10 --- .dockerignore | 31 ++++++++++++++++++++++++++++++- jest.config.ts | 13 +++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 7892d8c..98a5b25 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,35 @@ +# Node modules and build output node_modules/ dist/ + +# Environment and secrets .env +*.env *.log + +# Git and docs +.git *.md -.git \ No newline at end of file + +# Test files and folders +__tests__/ +tests/ +*.test.js +*.test.ts +*.spec.js +*.spec.ts + +# Terraform files and secrets +*.tf +*.tfvars +*.tfstate +*.tfstate.* +.terraform/ +terraform.tfstate +terraform.tfstate.* + +# Misc +Dockerfile* +docker-compose.yml +*.swp +*.bak \ No newline at end of file diff --git a/jest.config.ts b/jest.config.ts index 69f5850..b51b81b 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -19,10 +19,19 @@ aliasPaths["^@prisma/(?!(client(?:/.*)?$))(.*)$"] = "/src/prisma/$2"; const jestConfig: Config = { preset: "ts-jest", moduleFileExtensions: ["ts", "js", "json"], - rootDir: "./", - roots: ["/src"], + roots: ["src"], testEnvironment: "node", moduleNameMapper: aliasPaths, + collectCoverage: true, + coverageDirectory: "coverage", + coverageReporters: ["text", "lcov"], + collectCoverageFrom: [ + "src/**/*.{ts,js}", + "!src/main.ts", // exclude entry point + "!src/**/index.ts", // exclude barrel files + "!src/**/*.module.ts", // exclude module files + "!src/**/*.d.ts", // exclude type definitions + ], }; export default jestConfig; From e2e229fdb21579049a1edf0407958e30ee21054c Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 14:12:01 +0300 Subject: [PATCH 3/5] moved terraform files to a terraform folder --- .terraform.lock.hcl => terraform/.terraform.lock.hcl | 0 main.tf => terraform/main.tf | 7 +------ variables.tf => terraform/variables.tf | 0 3 files changed, 1 insertion(+), 6 deletions(-) rename .terraform.lock.hcl => terraform/.terraform.lock.hcl (100%) rename main.tf => terraform/main.tf (76%) rename variables.tf => terraform/variables.tf (100%) diff --git a/.terraform.lock.hcl b/terraform/.terraform.lock.hcl similarity index 100% rename from .terraform.lock.hcl rename to terraform/.terraform.lock.hcl diff --git a/main.tf b/terraform/main.tf similarity index 76% rename from main.tf rename to terraform/main.tf index 4d80331..d98b46d 100644 --- a/main.tf +++ b/terraform/main.tf @@ -10,12 +10,7 @@ terraform { provider "docker" {} resource "docker_image" "app_image" { - name = var.image_name - # we could also make the image build automatically but this causes issues with the tfstate file - # build { - # context = path.module - # dockerfile = "Dockerfile" - # } + name = var.image_name keep_locally = true } diff --git a/variables.tf b/terraform/variables.tf similarity index 100% rename from variables.tf rename to terraform/variables.tf From bf3742ec7d5c739ff0fadf2003f4094b41ed6ddf Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 14:20:52 +0300 Subject: [PATCH 4/5] updated jest config to not always collect coverage data split the test and coverage workflow into two separate actions --- .github/workflows/coverage.yml | 46 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 18 +++---------- jest.config.ts | 1 - 3 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..6750421 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,46 @@ +name: CI - Test + +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [22.x] + + steps: + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + - name: ๐Ÿ“ฆ Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: ๐ŸŸข Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "pnpm" + + - name: ๐Ÿ“ฆ Install dependencies + run: pnpm install + + - name: ๐Ÿ”จ Build the app (NestJS) + run: pnpm run build + + - name: ๐Ÿงช Run tests + run: pnpm run test:cov + + - name: ๐Ÿ“ค Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b1d9af..1b7c60e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,6 @@ -name: CI - Test & Coverage +name: CI - Test -on: - push: - branches: [main] - pull_request: - branches: [main] +on: [push, pull_request] jobs: build: @@ -35,11 +31,5 @@ jobs: - name: ๐Ÿ”จ Build the app (NestJS) run: pnpm run build - - name: ๐Ÿงช Run tests with coverage - run: pnpm run test:cov - - - name: ๐Ÿ“ค Upload coverage report - uses: actions/upload-artifact@v4 - with: - name: coverage-report - path: coverage/ + - name: ๐Ÿงช Run tests + run: pnpm run test diff --git a/jest.config.ts b/jest.config.ts index b51b81b..93ddfa2 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -22,7 +22,6 @@ const jestConfig: Config = { roots: ["src"], testEnvironment: "node", moduleNameMapper: aliasPaths, - collectCoverage: true, coverageDirectory: "coverage", coverageReporters: ["text", "lcov"], collectCoverageFrom: [ From 262c959d8e9fe5c8f704c89859c9123fbc3b0b0e Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 14:23:43 +0300 Subject: [PATCH 5/5] updated the workflow's name --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6750421..688fe78 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,4 +1,4 @@ -name: CI - Test +name: CI - Coverage Report on: workflow_dispatch: