| Total Complexity | 7 |
| Complexity/F | 3.5 |
| Lines of Code | 42 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | const findTestWorkflow = async function ({ |
||
| 2 | boost, git, libs, repository, tools |
||
| 3 | }) { |
||
| 4 | boost.log('finding tests workflow...'); |
||
| 5 | |||
| 6 | if (typeof boost.state.testWorkflowFile === 'string' && boost.state.testWorkflowFile.length > 0) { |
||
| 7 | boost.log('found tests workflow'); |
||
| 8 | return boost.state.testWorkflowFile; |
||
| 9 | } |
||
| 10 | |||
| 11 | boost.state.testWorkflowFile = ''; |
||
| 12 | |||
| 13 | for (const file of libs.fs.readdirSync(repository.path + '/.github/workflows', { encoding: 'utf-8', withFileTypes: true })) { |
||
| 14 | if (file.isDirectory()) { |
||
| 15 | continue; |
||
| 16 | } |
||
| 17 | |||
| 18 | if (file.name.endsWith('.yml') || file.name.endsWith('.yaml')) { |
||
| 19 | const data = tools.readfile(repository.path + '/.github/workflows/' + file.name); |
||
| 20 | if (data.includes('test') && (data.includes('phpunit') || data.includes('pest'))) { |
||
| 21 | boost.log('found tests workflow ' + file.name); |
||
| 22 | boost.state.testWorkflowFile = repository.path + '/.github/workflows/' + file.name; |
||
| 23 | return boost.state.testWorkflowFile; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | boost.log('could not find tests workflow'); |
||
| 29 | return false; |
||
| 30 | }; |
||
| 31 | |||
| 32 | /** @type {import('@/lib/Boost').BoostScriptHandler} */ |
||
| 33 | module.exports.handler = async function (params) { |
||
| 34 | params.boost.log('initializing boost...'); |
||
| 35 | |||
| 36 | params.boost.state.testWorkflowFile = ''; |
||
| 37 | params.boost.state.updatedComposerJson = false; |
||
| 38 | |||
| 39 | await findTestWorkflow(params); |
||
| 40 | |||
| 41 | params.boost.log('finished initializing boost'); |
||
| 42 | }; |
||
| 43 |