Skip to content

Commit

Permalink
chore: added github action workflow for test stats
Browse files Browse the repository at this point in the history
  • Loading branch information
kirrg001 committed May 13, 2024
1 parent d830a10 commit 3b1b9cd
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/schedule-test-stats.yaml
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
52 changes: 52 additions & 0 deletions bin/gather-test-stats.js
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}`);

0 comments on commit 3b1b9cd

Please sign in to comment.