1+ name : Run Unit Tests
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
6+
7+ jobs :
8+ run-tests :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Checkout code
12+ uses : actions/checkout@v4
13+
14+ - name : Set up Node.js
15+ uses : actions/setup-node@v4
16+ with :
17+ node-version : ' 22.x'
18+
19+ - name : Install dependencies for all plugins
20+ run : |
21+ npm run setup-repo-old
22+
23+ - name : Run tests for Audit plugin
24+ working-directory : ./packages/contentstack-audit
25+ run : npm run test:unit
26+
27+ # - name: Fetch latest references
28+ # run: |
29+ # git fetch --prune
30+
31+ # - name: Identify Changed Plugins
32+ # id: changes
33+ # run: |
34+ # echo "Finding changed files..."
35+ # # Ensure both commit references are valid
36+ # if [[ -z "${{ github.event.before }}" || -z "${{ github.sha }}" ]]; then
37+ # echo "Error: Missing commit references"
38+ # exit 1
39+ # fi
40+
41+ # CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
42+ # echo "Changed files:"
43+ # echo "$CHANGED_FILES"
44+
45+ # # Identify affected plugins
46+ # AFFECTED_PLUGINS=$(echo "$CHANGED_FILES" | grep -oP '(?<=^packages/)([^/]+)' | sort -u | tr '\n' ' ')
47+ # echo "Affected plugins: $AFFECTED_PLUGINS"
48+
49+ # # Set output for the next step
50+ # echo "::set-output name=affected_plugins::$AFFECTED_PLUGINS"
51+
52+ # - name: Run Unit Tests for Affected Plugins
53+ # run: |
54+ # for plugin in ${{ steps.changes.outputs.affected_plugins }}; do
55+ # echo "Checking if tests should run for $plugin..."
56+ # if [[ "$plugin" == "contentstack-audit" ]]; then
57+ # echo "Running tests for contentstack-audit..."
58+ # npm run test:unit --prefix ./packages/contentstack-audit
59+ # else
60+ # echo "contentstack-audit has not changed. Skipping tests."
61+ # fi
62+ # done
0 commit comments