-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added github action workflow for test stats
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Schedule Test Stats | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 1' # Every Monday at 06:00 AM UTC | ||
|
||
jobs: | ||
run-script: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Execute stats | ||
run: node bin/gather-test-stats.js |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* (c) Copyright IBM Corp. 2024 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const packagesFolder = path.join(__dirname, '..', 'packages'); | ||
let noOfTestFiles = 0; | ||
let noOfTestCases = 0; | ||
|
||
function walkSync(dir, list = []) { | ||
const files = fs.readdirSync(dir); | ||
|
||
files.forEach(file => { | ||
const currentPath = path.join(dir, file); | ||
|
||
if (fs.statSync(currentPath).isDirectory()) { | ||
if (file === 'node_modules') { | ||
return; | ||
} | ||
|
||
list = walkSync(currentPath, list); | ||
} else if (currentPath.endsWith('test.js')) { | ||
list.push(currentPath); | ||
} | ||
}); | ||
|
||
return list; | ||
} | ||
|
||
const packages = fs.readdirSync(packagesFolder); | ||
packages.forEach(pkg => { | ||
const packageTestFolder = path.join(packagesFolder, pkg, 'test'); | ||
const files = walkSync(packageTestFolder); | ||
|
||
noOfTestFiles += files.length; | ||
|
||
files.forEach(file => { | ||
const content = fs.readFileSync(file, 'utf8'); | ||
const match = content.match(/it\('/g); | ||
|
||
if (match) { | ||
noOfTestCases += match.length; | ||
} | ||
}); | ||
}); | ||
|
||
console.log(`TOTAL NUMBER OF TEST FILES: ${noOfTestFiles}`); | ||
console.log(`TOTAL NUMBER OF TEST CASES: ${noOfTestCases}`); |