Bump lodash from 4.17.21 to 4.17.23 #4993
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: JavaScript Unit Tests | |
| on: [ push, pull_request ] # Run on all pushes and PRs | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| JSUnitTests: | |
| name: JavaScript unit tests | |
| runs-on: ubuntu-latest | |
| env: | |
| NODE_ENV: test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version-file: 'package.json' | |
| cache: 'npm' | |
| - name: Prepare package.json for Linux | |
| id: prepare | |
| run: | | |
| # Create a .npmrc file to ignore fsevents | |
| echo "optional=false" > .npmrc | |
| echo "omit=optional" >> .npmrc | |
| # Create a backup of the original package.json | |
| cp package.json package.json.bak | |
| # Remove fsevents from package.json if it exists | |
| if grep -q "fsevents" package.json; then | |
| # Use jq to remove fsevents from dependencies and devDependencies | |
| jq 'del(.dependencies.fsevents) | del(.devDependencies.fsevents) | del(.optionalDependencies.fsevents)' package.json > package.json.tmp | |
| mv package.json.tmp package.json | |
| fi | |
| echo "Package.json prepared for Linux environment" | |
| - name: Install dependencies | |
| id: install | |
| continue-on-error: true | |
| run: | | |
| # Try to install dependencies with multiple fallback options | |
| npm install --no-optional || npm install --legacy-peer-deps --no-optional || npm ci --no-optional || echo "::warning::Dependency installation failed, tests may be skipped" | |
| # Check if node_modules exists and has content | |
| if [ -d "node_modules" ] && [ "$(ls -A node_modules)" ]; then | |
| echo "dependencies_installed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "dependencies_installed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Verify Node and npm versions | |
| run: | | |
| node --version | |
| npm --version | |
| - name: Run JavaScript unit tests with coverage | |
| id: jest | |
| if: steps.install.outputs.dependencies_installed == 'true' | |
| run: | | |
| # Run Jest using npm script to ensure proper configuration | |
| npm run test:js -- --coverage --coverageReporters=json-summary --coverageReporters=lcov --coverageReporters=html | |
| # Extract coverage summary from JSON | |
| COVERAGE=$(node -e " | |
| const fs = require('fs'); | |
| const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8')); | |
| console.log(coverage.total.lines.pct); | |
| ") | |
| echo "coverage_summary=$COVERAGE" >> $GITHUB_OUTPUT | |
| echo "📊 JS Coverage: $COVERAGE%" | |
| echo "✅ JavaScript unit tests completed successfully" | |
| - name: Upload coverage reports | |
| if: steps.install.outputs.dependencies_installed == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: js-coverage-report | |
| path: coverage/coverage-summary.json | |
| retention-days: 30 | |
| - name: Check JS coverage threshold | |
| if: steps.install.outputs.dependencies_installed == 'true' | |
| continue-on-error: true | |
| run: | | |
| COVERAGE="${{ steps.jest.outputs.coverage_summary }}" | |
| MIN_THRESHOLD=30 | |
| echo "📈 JS Coverage: $COVERAGE%" | |
| echo "🎯 JS Threshold: $MIN_THRESHOLD%" | |
| if (( $(echo "$COVERAGE $MIN_THRESHOLD" | awk '{print ($1 >= $2)}') )); then | |
| echo "✅ JS Coverage check passed!" | |
| else | |
| echo "❌ JS Coverage too low. Need $MIN_THRESHOLD%, got $COVERAGE%" | |
| exit 1 | |
| fi | |
| - name: Skip tests notification | |
| if: steps.install.outputs.dependencies_installed != 'true' | |
| run: echo "::warning::Skipping tests due to dependency installation issues" | |
| - name: Restore original package.json | |
| if: always() | |
| run: | | |
| if [ -f package.json.bak ]; then | |
| mv package.json.bak package.json | |
| rm -f .npmrc | |
| fi |