diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000000..e3492d20b3 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,52 @@ +name: Run Unit Tests + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + # 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.x' + + - 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: + # - 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: List files in plugin directory + run: ls -R /home/runner/work/cli + + + - name: Run tests for the plugin + working-directory: ./packages/contentstack-audit + run: npm run test:unit 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"