Skip to content

Commit

Permalink
:closes: #143 add process to rename and push test files to git
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Nov 21, 2024
1 parent 2f39a0c commit ce911d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"test:lrc": "$npm_package_config_testCommand --tags @lrc",
"test:performancehints": "$npm_package_config_testCommand --tags @performancehints",
"healthcheck": "ts-node healthcheck.ts",
"push-report": "ts-node report.ts",
"wp-env": "wp-env"
},
"repository": {
Expand Down
39 changes: 39 additions & 0 deletions report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import fs from 'fs';
import path from "path";
import {exec} from "child_process";


const testResults = path.join(__dirname, 'test-results');

const args = process.argv.slice(2);
if(args.length < 1) {
console.error('Please provide the new naming for test folder')
}
const newTestDir = args[0];

const gitCommands = `git add . && git commit -m "Add test report" && git push origin test`;

// Rename test folder and push
fs.rename(testResults, newTestDir, (err) => {
if (err) {
console.error('Error renaming/moving file:', err);
} else {
exec(gitCommands, { cwd: newTestDir }, (err, stdout, stderr) => {
if (err) {
console.error('Error executing git commands:', err);
}

if (stderr) {
console.error('Git stderr output:', stderr);
return;
}

//Revert the renaming of test folder to avoid tracking it in e2e
fs.rename(newTestDir, testResults, (err) => {
if (err) {
console.error('Error reverting the directory name:', err);
}
});
});
}
});

0 comments on commit ce911d6

Please sign in to comment.