Skip to content

Commit b16f68a

Browse files
committed
refactor: run unit tests only for affected plugins
1 parent 7c41306 commit b16f68a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.github/workflows/unit-test.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ jobs:
2020
run: |
2121
npm run setup-repo-old
2222
23-
- name: Run tests for Audit plugin
24-
working-directory: ./packages/contentstack-audit
25-
run: npm run test:unit
23+
- name: Identify Changed Plugins
24+
id: changes
25+
run: |
26+
echo "Finding changed files..."
27+
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
28+
echo "Changed files:"
29+
echo "$CHANGED_FILES"
30+
31+
# Identify affected plugins
32+
AFFECTED_PLUGINS=$(echo "$CHANGED_FILES" | grep -oP '(?<=^packages/)([^/]+)' | sort -u | tr '\n' ' ')
33+
echo "Affected plugins: $AFFECTED_PLUGINS"
34+
35+
# Set output for the next step
36+
echo "::set-output name=affected_plugins::$AFFECTED_PLUGINS"
37+
38+
- name: Run Unit Tests for Affected Plugins
39+
run: |
40+
for plugin in ${{ steps.changes.outputs.affected_plugins }}; do
41+
echo "Running tests for $plugin..."
42+
npm run test:unit --prefix ./packages/$plugin
43+
done

0 commit comments

Comments
 (0)