Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run Unit Tests

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
run-tests:
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

- name: Fetch latest references
run: |
git fetch --prune

- name: Identify Changed Plugins
id: changes
run: |
echo "Finding changed files..."
# Ensure both commit references are valid
if [[ -z "${{ github.event.before }}" || -z "${{ github.sha }}" ]]; then
echo "Error: Missing commit references"
exit 1
fi

CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
echo "Changed files:"
echo "$CHANGED_FILES"

# Identify affected plugins
AFFECTED_PLUGINS=$(echo "$CHANGED_FILES" | grep -oP '(?<=^packages/)([^/]+)' | sort -u | tr '\n' ' ')
echo "Affected plugins: $AFFECTED_PLUGINS"

# Set output for the next step
echo "::set-output name=affected_plugins::$AFFECTED_PLUGINS"

- name: Run Unit Tests for Affected Plugins
run: |
for plugin in ${{ steps.changes.outputs.affected_plugins }}; do
echo "Running tests for $plugin..."
npm run test:unit --prefix ./packages/$plugin
done
213 changes: 73 additions & 140 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Audit command', () => {
filename!: string;
} as FileTransportInstance;

describe('Audit run method', () => {
describe('Audit run method:', () => {
fancy
.stdout({ print: process.env.PRINT === 'true' || false })
.stub(winston.transports, 'File', () => fsTransport)
Expand Down
Loading
Loading