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
10 changes: 10 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm run format:check)",
"Bash(npm run format:fix)"
]
}
}
23 changes: 0 additions & 23 deletions .eslintrc.js

This file was deleted.

150 changes: 34 additions & 116 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

jobs:
unit-tests:
format-check:
runs-on: ubuntu-latest

steps:
Expand All @@ -17,130 +17,48 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '24'
cache: npm

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test
- name: Run prettier
run: npm run format:check

lint:
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: '24'
cache: npm

test-coverage-action:
- name: Install dependencies
run: npm ci

- name: Run lint
run: npm run lint

unit-tests:
runs-on: ubuntu-latest
needs: unit-tests

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Verify coverage-xml exists
run: |
if [ ! -d php-files/coverage-xml ]; then
echo "Error: coverage-xml directory was not created"
exit 1
fi
if [ ! -f php-files/coverage-xml/index.xml ]; then
echo "Error: coverage-xml/index.xml was not generated"
exit 1
fi
echo "✓ coverage-xml directory exists"
echo "✓ coverage-xml/index.xml exists"
echo "Coverage index file size: $(wc -c < php-files/coverage-xml/index.xml) bytes"

- name: Display coverage index file snippet
run: |
echo "First 50 lines of coverage-xml/index.xml:"
head -n 50 php-files/coverage-xml/index.xml

- name: Test PR Coverage Action
id: coverage
uses: ./
- name: Set up Node.js
uses: actions/setup-node@v4
with:
coverage-xml-dir: php-files/coverage-xml
github-token: ${{ secrets.GITHUB_TOKEN }}
all-files-minimum-coverage: 0
changed-files-minimum-coverage: 0
update-comment: true

- name: Verify action outputs
run: |
echo "=== Coverage Report Outputs ==="
echo "All files coverage: ${{ steps.coverage.outputs.all-files-coverage }}%"
echo "Changed files coverage: ${{ steps.coverage.outputs.changed-files-coverage }}%"
echo "All files lines: ${{ steps.coverage.outputs.all-files-lines-hit }}/${{ steps.coverage.outputs.all-files-lines-total }}"
echo "Changed files lines: ${{ steps.coverage.outputs.changed-files-lines-hit }}/${{ steps.coverage.outputs.changed-files-lines-total }}"
echo ""

# Expected values based on test data
# All files: index.php (6/12) + service1.php (5/15) + service2.php (12/48) = 23/75 = 30.67%
# Changed files detected by GitHub: index.php (6/12) + service2.php (12/48) = 18/60 = 30.00%
# Note: service1.php appears in coverage but not detected as changed by GitHub in PR context
EXPECTED_ALL_FILES_COVERAGE="30.67"
EXPECTED_ALL_FILES_LINES_HIT="23"
EXPECTED_ALL_FILES_LINES_TOTAL="75"
EXPECTED_CHANGED_FILES_COVERAGE="30.00"
EXPECTED_CHANGED_FILES_LINES_HIT="18"
EXPECTED_CHANGED_FILES_LINES_TOTAL="60"

# Verify all-files-coverage
ACTUAL_ALL_FILES_COVERAGE="${{ steps.coverage.outputs.all-files-coverage }}"
if [ "$ACTUAL_ALL_FILES_COVERAGE" != "$EXPECTED_ALL_FILES_COVERAGE" ]; then
echo "❌ Error: all-files-coverage mismatch"
echo " Expected: $EXPECTED_ALL_FILES_COVERAGE"
echo " Actual: $ACTUAL_ALL_FILES_COVERAGE"
exit 1
fi
echo "✓ all-files-coverage: $ACTUAL_ALL_FILES_COVERAGE (matches expected)"

# Verify all-files-lines-hit
ACTUAL_ALL_FILES_LINES_HIT="${{ steps.coverage.outputs.all-files-lines-hit }}"
if [ "$ACTUAL_ALL_FILES_LINES_HIT" != "$EXPECTED_ALL_FILES_LINES_HIT" ]; then
echo "❌ Error: all-files-lines-hit mismatch"
echo " Expected: $EXPECTED_ALL_FILES_LINES_HIT"
echo " Actual: $ACTUAL_ALL_FILES_LINES_HIT"
exit 1
fi
echo "✓ all-files-lines-hit: $ACTUAL_ALL_FILES_LINES_HIT (matches expected)"

# Verify all-files-lines-total
ACTUAL_ALL_FILES_LINES_TOTAL="${{ steps.coverage.outputs.all-files-lines-total }}"
if [ "$ACTUAL_ALL_FILES_LINES_TOTAL" != "$EXPECTED_ALL_FILES_LINES_TOTAL" ]; then
echo "❌ Error: all-files-lines-total mismatch"
echo " Expected: $EXPECTED_ALL_FILES_LINES_TOTAL"
echo " Actual: $ACTUAL_ALL_FILES_LINES_TOTAL"
exit 1
fi
echo "✓ all-files-lines-total: $ACTUAL_ALL_FILES_LINES_TOTAL (matches expected)"

# Verify changed-files-coverage
ACTUAL_CHANGED_FILES_COVERAGE="${{ steps.coverage.outputs.changed-files-coverage }}"
if [ "$ACTUAL_CHANGED_FILES_COVERAGE" != "$EXPECTED_CHANGED_FILES_COVERAGE" ]; then
echo "❌ Error: changed-files-coverage mismatch"
echo " Expected: $EXPECTED_CHANGED_FILES_COVERAGE"
echo " Actual: $ACTUAL_CHANGED_FILES_COVERAGE"
exit 1
fi
echo "✓ changed-files-coverage: $ACTUAL_CHANGED_FILES_COVERAGE (matches expected)"

# Verify changed-files-lines-hit
ACTUAL_CHANGED_FILES_LINES_HIT="${{ steps.coverage.outputs.changed-files-lines-hit }}"
if [ "$ACTUAL_CHANGED_FILES_LINES_HIT" != "$EXPECTED_CHANGED_FILES_LINES_HIT" ]; then
echo "❌ Error: changed-files-lines-hit mismatch"
echo " Expected: $EXPECTED_CHANGED_FILES_LINES_HIT"
echo " Actual: $ACTUAL_CHANGED_FILES_LINES_HIT"
exit 1
fi
echo "✓ changed-files-lines-hit: $ACTUAL_CHANGED_FILES_LINES_HIT (matches expected)"

# Verify changed-files-lines-total
ACTUAL_CHANGED_FILES_LINES_TOTAL="${{ steps.coverage.outputs.changed-files-lines-total }}"
if [ "$ACTUAL_CHANGED_FILES_LINES_TOTAL" != "$EXPECTED_CHANGED_FILES_LINES_TOTAL" ]; then
echo "❌ Error: changed-files-lines-total mismatch"
echo " Expected: $EXPECTED_CHANGED_FILES_LINES_TOTAL"
echo " Actual: $ACTUAL_CHANGED_FILES_LINES_TOTAL"
exit 1
fi
echo "✓ changed-files-lines-total: $ACTUAL_CHANGED_FILES_LINES_TOTAL (matches expected)"

echo ""
echo "✅ All coverage outputs match expected values!"
echo "✅ PR Test Coverage action completed successfully"
node-version: '24'
cache: npm

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test
222 changes: 109 additions & 113 deletions dist/index.js

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const tseslint = require('typescript-eslint')
const js = require('@eslint/js')
const globals = require('globals')

module.exports = tseslint.config(
{
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
},
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
ecmaVersion: 2024,
sourceType: 'module',
globals: {
...globals.node,
...globals.es2024,
},
},
rules: {
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/explicit-function-return-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'prefer-const': 'error',
'no-var': 'error',
},
},
)
Loading
Loading