Skip to content

Commit 1e32e2e

Browse files
Prepare for initial release (#12)
* fix: update action usage to correct repository path in examples * test: add fallback handling for unknown XML and JSON formats in file-finder tests * feat: enhance file format detection with error handling for unreadable files * feat: add tests for detecting Cobertura XML files with and without line-rate * feat: add retry logic for transient axios errors in uploadCoverageFiles test * test: enhance uploadCoverageFiles tests with error handling and context variations * format and build
1 parent 043e1a2 commit 1e32e2e

9 files changed

Lines changed: 805 additions & 391 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The official `datadog-ci` CLI requires installing a large npm package with many
1717

1818
```yaml
1919
- name: Upload coverage to Datadog
20-
uses: your-org/datadog-upload-code-coverage-action@v1
20+
uses: python-build-tools/datadog-upload-code-coverage-action@v1
2121
with:
2222
api-key: ${{ secrets.DD_API_KEY }}
2323
files: '**/coverage/*.xml'
@@ -40,7 +40,7 @@ jobs:
4040
run: npm test -- --coverage
4141

4242
- name: Upload coverage to Datadog
43-
uses: your-org/datadog-upload-code-coverage-action@v1
43+
uses: python-build-tools/datadog-upload-code-coverage-action@v1
4444
with:
4545
api-key: ${{ secrets.DD_API_KEY }}
4646
site: 'datadoghq.com'

dist/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44341,7 +44341,14 @@ function glob_hashFiles(patterns_1) {
4434144341

4434244342

4434344343

44344-
// Coverage format detection based on file patterns and content
44344+
class FileFinder {
44345+
/**
44346+
* Reads file content for format detection. Extracted for testability.
44347+
*/
44348+
static sampleFileContent(filePath) {
44349+
return external_fs_.readFileSync(filePath, 'utf-8').slice(0, 2000); // Read first 2KB for detection
44350+
}
44351+
}
4434544352
const FORMAT_PATTERNS = [
4434644353
// JaCoCo - XML format with jacoco in root element
4434744354
{
@@ -44405,7 +44412,7 @@ function detectFormat(filePath, content) {
4440544412
// Second pass: need to check content for files that require content checking
4440644413
if (!content && (filePath.endsWith('.xml') || filePath.endsWith('.json') || filePath.endsWith('.out'))) {
4440744414
try {
44408-
content = external_fs_.readFileSync(filePath, 'utf-8').slice(0, 2000); // Read first 2KB for detection
44415+
content = FileFinder.sampleFileContent(filePath);
4440944416
}
4441044417
catch {
4441144418
return null;

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@vercel/ncc": "^0.38.1",
4040
"eslint": "^9.39.2",
4141
"jest": "^30.2.0",
42+
"prettier": "^3.8.1",
4243
"ts-jest": "^29.1.2",
4344
"typescript": "^5.3.3",
4445
"typescript-eslint": "^8.54.0"

0 commit comments

Comments
 (0)