Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
files: ./coverage/e2e/lcov.info
flags: e2e
slug: WordPress/secure-custom-fields
name: e2e-coverage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ jobs:
composer install --no-progress --prefer-dist --no-interaction

- name: Run PHPUnit with coverage
run: vendor/bin/phpunit --coverage-clover=coverage.xml
run: mkdir -p coverage/phpunit && vendor/bin/phpunit --coverage-clover=coverage/phpunit/coverage.xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: WordPress/secure-custom-fields
files: ./coverage.xml
files: ./coverage/phpunit/coverage.xml
flags: phpunit
name: phpunit-php-${{ matrix.php }}
65 changes: 65 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: JavaScript Unit Tests

on:
pull_request:
branches: [trunk]
push:
branches: [trunk]
# Allow manually triggering the workflow
workflow_dispatch:

# Cancels all previous workflow runs for pull requests that have not completed
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# Disable permissions for all available scopes by default
permissions: {}

jobs:
unit-js:
name: Node.js ${{ matrix.node }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
event: ['${{ github.event_name }}']
node: ['20', '22', '24']
exclude:
# On PRs: only test minimum supported version
- event: 'pull_request'
node: '22'
- event: 'pull_request'
node: '24'

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
persist-credentials: false

- name: Setup Node.js and install dependencies
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit -- --ci --coverage

- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/unit/lcov.info
flags: javascript
slug: WordPress/secure-custom-fields
name: unit-js-node-${{ matrix.node }}
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tempDir": ".nyc_output",
"reportDir": "./coverage",
"reportDir": "./coverage/e2e",
"reporter": [ "html", "lcov", "text" ],
"include": [ "assets/src/**/*.js", "assets/src/**/*.jsx" ],
"exclude": [
Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ module.exports = {
'!**/node_modules/**',
'!**/vendor/**',
],
coverageDirectory: 'coverage/unit',
coverageReporters: [ 'lcov', 'text', 'html' ],
transformIgnorePatterns: [ 'node_modules/(?!(react-jsx-parser)/)' ],
};
Loading