From 6a1b7e9d61606417c6a738e5878a11866d5a98d6 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 27 Mar 2025 15:07:11 +0530 Subject: [PATCH 01/22] feat: added unit test cases check in workflow --- .github/workflows/unit-test.yml | 33 ++++++++++++++++++++++++ packages/contentstack-audit/package.json | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000000..1491e81e47 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,33 @@ +name: Unit Test & Reports + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + # Create a job for each plugin dynamically + test-plugins: + runs-on: ubuntu-latest + strategy: + matrix: + plugin: + - contentstack-audit + - contentstack-export-to-csv + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + run: | + npm install + + - name: Run tests for the plugin + run: | + cd packages/${{ matrix.plugin }} # Navigate to the plugin directory + npm test:unit # Run unit tests for the plugin \ No newline at end of file diff --git a/packages/contentstack-audit/package.json b/packages/contentstack-audit/package.json index 339f8c2b62..9f0f448d50 100644 --- a/packages/contentstack-audit/package.json +++ b/packages/contentstack-audit/package.json @@ -74,7 +74,8 @@ "test": "mocha --forbid-only \"test/**/*.test.ts\"", "version": "oclif readme && git add README.md", "clean": "rm -rf ./lib ./node_modules tsconfig.tsbuildinfo oclif.manifest.json", - "test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"" + "test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"", + "test:unit": "mocha --timeout 10000 --forbid-only \"test/unit/**/*.test.ts\"" }, "engines": { "node": ">=16" From b8588fa3ef6f3e44a96d1c650c3927b8626f9697 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 27 Mar 2025 15:09:20 +0530 Subject: [PATCH 02/22] fix --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 1491e81e47..cd075f7ca5 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -30,4 +30,4 @@ jobs: - name: Run tests for the plugin run: | cd packages/${{ matrix.plugin }} # Navigate to the plugin directory - npm test:unit # Run unit tests for the plugin \ No newline at end of file + npm run test:unit # Run unit tests for the plugin \ No newline at end of file From 928f2ae7b5dfc2da7b9c683cce6fb8cc09127113 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 27 Mar 2025 15:11:50 +0530 Subject: [PATCH 03/22] fix --- .github/workflows/unit-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index cd075f7ca5..7d481fd02a 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -25,6 +25,7 @@ jobs: - name: Install dependencies run: | + cd packages/${{ matrix.plugin }} # Navigate to the plugin directory npm install - name: Run tests for the plugin From 8a55d323d0f35d37c1daac3e10b0d770d4fc22b2 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 27 Mar 2025 22:10:12 +0530 Subject: [PATCH 04/22] fix: unit test workflow --- .github/workflows/unit-test.yml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 7d481fd02a..df566aa49f 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -5,9 +5,26 @@ on: types: [opened, synchronize, reopened] jobs: - # Create a job for each plugin dynamically + # Install dependencies once globally + install-dependencies: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies for all plugins + run: | + npm run setup-repo-old + + # Test plugins dynamically test-plugins: runs-on: ubuntu-latest + needs: install-dependencies # Ensures this job runs after dependencies are installed strategy: matrix: plugin: @@ -21,14 +38,9 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '22' - - - name: Install dependencies - run: | - cd packages/${{ matrix.plugin }} # Navigate to the plugin directory - npm install + node-version: '22' - name: Run tests for the plugin run: | - cd packages/${{ matrix.plugin }} # Navigate to the plugin directory - npm run test:unit # Run unit tests for the plugin \ No newline at end of file + cd packages/${{ matrix.plugin }} + npm run test:unit From a950945de25207e9cfa672a350637ed2f1a4c8ba Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 27 Mar 2025 22:26:03 +0530 Subject: [PATCH 05/22] fix: unit test workflow --- .github/workflows/unit-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index df566aa49f..bb14c753df 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -40,6 +40,11 @@ jobs: with: node-version: '22' + - name: Install dependencies for the plugin + run: | + cd packages/${{ matrix.plugin }} + npm install + - name: Run tests for the plugin run: | cd packages/${{ matrix.plugin }} From 7dc783a9298573017d297adec14ebd4ec13d8566 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 10:51:34 +0530 Subject: [PATCH 06/22] fix --- .github/workflows/unit-test.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index bb14c753df..47f232a093 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -24,10 +24,10 @@ jobs: # Test plugins dynamically test-plugins: runs-on: ubuntu-latest - needs: install-dependencies # Ensures this job runs after dependencies are installed + needs: install-dependencies # Ensures this job runs after dependencies are installed strategy: matrix: - plugin: + plugin: - contentstack-audit - contentstack-export-to-csv @@ -39,11 +39,16 @@ jobs: uses: actions/setup-node@v4 with: node-version: '22' + + - name: Check contents of plugin directory + run: | + cd packages/${{ matrix.plugin }} + ls -la - name: Install dependencies for the plugin run: | cd packages/${{ matrix.plugin }} - npm install + ls -la - name: Run tests for the plugin run: | From 27d3c4807c9b1ceeb590d4c6124c23514f3edbe2 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 11:11:16 +0530 Subject: [PATCH 07/22] fix --- .github/workflows/unit-test.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 47f232a093..935c951b72 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -38,19 +38,12 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '22' - - - name: Check contents of plugin directory - run: | - cd packages/${{ matrix.plugin }} - ls -la + node-version: '22.x' - name: Install dependencies for the plugin - run: | - cd packages/${{ matrix.plugin }} - ls -la + working-directory: ./packages/${{ matrix.plugin }} + run: npm install - name: Run tests for the plugin - run: | - cd packages/${{ matrix.plugin }} - npm run test:unit + working-directory: ./packages/${{ matrix.plugin }} + run: npm run test:unit From 7a9b4c3aef5703912182619adee45e4661dd9b69 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 11:25:22 +0530 Subject: [PATCH 08/22] fix --- .github/workflows/unit-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 935c951b72..55f62bfc7f 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -1,4 +1,4 @@ -name: Unit Test & Reports +name: Run Unit Tests on: pull_request: @@ -15,11 +15,11 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '22' + node-version: '22.x' - name: Install dependencies for all plugins run: | - npm run setup-repo-old + npm install # Test plugins dynamically test-plugins: From 7c283b25fc2a1b9f1f01d96117ee7a1121c7106a Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 11:28:58 +0530 Subject: [PATCH 09/22] debug --- .github/workflows/unit-test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 55f62bfc7f..44e4f35d15 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -44,6 +44,15 @@ jobs: working-directory: ./packages/${{ matrix.plugin }} run: npm install + - name: Debug environment + run: | + echo "Current directory: $(pwd)" + echo "Node version: $(node -v)" + echo "NPM version: $(npm -v)" + echo "Installed packages:" + npm ls @contentstack/cli-utilities + + - name: Run tests for the plugin working-directory: ./packages/${{ matrix.plugin }} run: npm run test:unit From 0279269e27eec2ac99982d6fbe8503d15bd7eabf Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 11:32:45 +0530 Subject: [PATCH 10/22] added prepack --- .github/workflows/unit-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 44e4f35d15..4d80813101 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -43,6 +43,10 @@ jobs: - name: Install dependencies for the plugin working-directory: ./packages/${{ matrix.plugin }} run: npm install + + - name: Prepack the plugin + working-directory: ./packages/${{ matrix.plugin }} + run: npm run prepack - name: Debug environment run: | From ff14e95a3032ceb1de392e5ee48703b4c6086d68 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 16:29:00 +0530 Subject: [PATCH 11/22] fix --- .github/workflows/unit-test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4d80813101..b329b6ba00 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies for all plugins run: | - npm install + npm run setup-repo-old # Test plugins dynamically test-plugins: @@ -40,13 +40,13 @@ jobs: with: node-version: '22.x' - - name: Install dependencies for the plugin - working-directory: ./packages/${{ matrix.plugin }} - run: npm install + # - name: Install dependencies for the plugin + # working-directory: ./packages/${{ matrix.plugin }} + # run: npm install - - name: Prepack the plugin - working-directory: ./packages/${{ matrix.plugin }} - run: npm run prepack + # - name: Prepack the plugin + # working-directory: ./packages/${{ matrix.plugin }} + # run: npm run prepack - name: Debug environment run: | From 95c7cee62be051daf6b12c7641091f4f69f95c42 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 28 Mar 2025 17:26:28 +0530 Subject: [PATCH 12/22] fix --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index b329b6ba00..383479eccc 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -54,7 +54,7 @@ jobs: echo "Node version: $(node -v)" echo "NPM version: $(npm -v)" echo "Installed packages:" - npm ls @contentstack/cli-utilities + npm ls - name: Run tests for the plugin From d6f2a0c91ba38f80b7d631d560894d106b4780d4 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 10:46:26 +0530 Subject: [PATCH 13/22] fix --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 383479eccc..c6fc10321d 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -58,5 +58,5 @@ jobs: - name: Run tests for the plugin - working-directory: ./packages/${{ matrix.plugin }} + working-directory: /home/runner/work/cli/cli/packages/${{ matrix.plugin }} run: npm run test:unit From a9850b9bff21f8fcc415f31dcaedf63e71db3bc0 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 10:49:45 +0530 Subject: [PATCH 14/22] refactor: removed debug step from workflow --- .github/workflows/unit-test.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index c6fc10321d..12aa45eb57 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -48,14 +48,6 @@ jobs: # working-directory: ./packages/${{ matrix.plugin }} # run: npm run prepack - - name: Debug environment - run: | - echo "Current directory: $(pwd)" - echo "Node version: $(node -v)" - echo "NPM version: $(npm -v)" - echo "Installed packages:" - npm ls - - name: Run tests for the plugin working-directory: /home/runner/work/cli/cli/packages/${{ matrix.plugin }} From 95e481a42165823aefdf2e8b020f82cb983aee4b Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 10:53:18 +0530 Subject: [PATCH 15/22] refactor: uncomment install dependencies step --- .github/workflows/unit-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 12aa45eb57..6132dd98b5 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -40,9 +40,9 @@ jobs: with: node-version: '22.x' - # - name: Install dependencies for the plugin - # working-directory: ./packages/${{ matrix.plugin }} - # run: npm install + - name: Install dependencies for the plugin + working-directory: /home/runner/work/cli/cli/packages/${{ matrix.plugin }} + run: npm install # - name: Prepack the plugin # working-directory: ./packages/${{ matrix.plugin }} From a07b3b95a0206c3df80c2e8cd40f7d9c1a9a4fec Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 13:29:03 +0530 Subject: [PATCH 16/22] fix --- .github/workflows/unit-test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 6132dd98b5..c0089d19cd 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -44,9 +44,11 @@ jobs: working-directory: /home/runner/work/cli/cli/packages/${{ matrix.plugin }} run: npm install - # - name: Prepack the plugin - # working-directory: ./packages/${{ matrix.plugin }} - # run: npm run prepack + - name: Check current directory + run: pwd + + - name: List files in plugin directory + run: ls -R /home/runner/work/cli/cli/packages/${{ matrix.plugin }} - name: Run tests for the plugin From 15fa57b57d09b2fe63cd6806652e241ae46c5329 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 13:41:07 +0530 Subject: [PATCH 17/22] fix --- .github/workflows/unit-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index c0089d19cd..d8f0ec05ed 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -28,8 +28,8 @@ jobs: strategy: matrix: plugin: - - contentstack-audit - - contentstack-export-to-csv + - cli-audit + - cli-cm-export-to-csv steps: - name: Checkout code @@ -41,14 +41,14 @@ jobs: node-version: '22.x' - name: Install dependencies for the plugin - working-directory: /home/runner/work/cli/cli/packages/${{ matrix.plugin }} + working-directory: /home/runner/work/cli/cli/node_modules/@contentstack/${{ matrix.plugin }} run: npm install - name: Check current directory run: pwd - name: List files in plugin directory - run: ls -R /home/runner/work/cli/cli/packages/${{ matrix.plugin }} + run: ls -R /home/runner/work/cli/cli - name: Run tests for the plugin From 75da0f3ca7fab4611f4eadd236d61989ed94f296 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 13:44:22 +0530 Subject: [PATCH 18/22] fix --- .github/workflows/unit-test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index d8f0ec05ed..85341bdcd9 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -39,10 +39,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: '22.x' - - - name: Install dependencies for the plugin - working-directory: /home/runner/work/cli/cli/node_modules/@contentstack/${{ matrix.plugin }} - run: npm install - name: Check current directory run: pwd From 658acca3716352bbe5becbb0f7d96d73337c9c8a Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 13:48:21 +0530 Subject: [PATCH 19/22] fix --- .github/workflows/unit-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 85341bdcd9..78026d4e72 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -44,9 +44,9 @@ jobs: run: pwd - name: List files in plugin directory - run: ls -R /home/runner/work/cli/cli + run: ls -R /home/runner/work/cli/node_modules/@contentstack - name: Run tests for the plugin - working-directory: /home/runner/work/cli/cli/packages/${{ matrix.plugin }} + working-directory: /home/runner/work/cli/node_modules/@contentstack/${{ matrix.plugin }} run: npm run test:unit From 6925efb84320cb668324c48bf039d86a180593ac Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 13:50:52 +0530 Subject: [PATCH 20/22] fix --- .github/workflows/unit-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 78026d4e72..88343f5359 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -44,9 +44,9 @@ jobs: run: pwd - name: List files in plugin directory - run: ls -R /home/runner/work/cli/node_modules/@contentstack + run: ls -R /home/runner/work/cli/cli/node_modules/@contentstack - name: Run tests for the plugin - working-directory: /home/runner/work/cli/node_modules/@contentstack/${{ matrix.plugin }} + working-directory: /home/runner/work/cli/cli/node_modules/@contentstack/${{ matrix.plugin }} run: npm run test:unit From 247b6f269b7a86b9c08e23d41d00aabbd889afa3 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 13:53:57 +0530 Subject: [PATCH 21/22] fix --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 88343f5359..952b6b2b7e 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -44,7 +44,7 @@ jobs: run: pwd - name: List files in plugin directory - run: ls -R /home/runner/work/cli/cli/node_modules/@contentstack + run: ls -R /home/runner/work/cli - name: Run tests for the plugin From 377cd818c73dbcd68ccc8fa9a16c78ca9e44cea2 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 1 Apr 2025 14:00:53 +0530 Subject: [PATCH 22/22] fix --- .github/workflows/unit-test.yml | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 952b6b2b7e..e3492d20b3 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -21,32 +21,32 @@ jobs: run: | npm run setup-repo-old - # Test plugins dynamically - test-plugins: - runs-on: ubuntu-latest - needs: install-dependencies # Ensures this job runs after dependencies are installed - strategy: - matrix: - plugin: - - cli-audit - - cli-cm-export-to-csv - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22.x' + # # Test plugins dynamically + # test-plugins: + # runs-on: ubuntu-latest + # needs: install-dependencies # Ensures this job runs after dependencies are installed + # strategy: + # matrix: + # plugin: + # - cli-audit + # - cli-cm-export-to-csv + + # steps: + # - name: Checkout code + # uses: actions/checkout@v4 + + # - name: Set up Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: '22.x' - - name: Check current directory - run: pwd + # - name: Check current directory + # run: pwd - name: List files in plugin directory run: ls -R /home/runner/work/cli - name: Run tests for the plugin - working-directory: /home/runner/work/cli/cli/node_modules/@contentstack/${{ matrix.plugin }} + working-directory: ./packages/contentstack-audit run: npm run test:unit