File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed
__tests__/cli/__snapshots__ Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -12,5 +12,10 @@ exports[`list - Non-Interactive Mode Should provide a list of available workflow
12
12
" name" : " upsert-github-repositories" ,
13
13
" workflow" : [Function ],
14
14
} ,
15
+ {
16
+ " description" : " Run all the compliance checks for the stored data." ,
17
+ " name" : " run-all-checks" ,
18
+ " workflow" : [Function ],
19
+ } ,
15
20
]
16
21
` ;
Original file line number Diff line number Diff line change 1
1
const inquirer = require ( 'inquirer' ) . default
2
2
const debug = require ( 'debug' ) ( 'cli:workflows' )
3
- const { updateGithubOrgs, upsertGithubRepositories } = require ( '../workflows' )
3
+ const { updateGithubOrgs, upsertGithubRepositories, runAllTheComplianceChecks } = require ( '../workflows' )
4
4
const { logger } = require ( '../utils' )
5
5
6
6
const commandList = [ {
@@ -11,6 +11,10 @@ const commandList = [{
11
11
name : 'upsert-github-repositories' ,
12
12
description : 'Check the organizations stored and update/create the information related to the repositories with the GitHub API.' ,
13
13
workflow : upsertGithubRepositories
14
+ } , {
15
+ name : 'run-all-checks' ,
16
+ description : 'Run all the compliance checks for the stored data.' ,
17
+ workflow : runAllTheComplianceChecks
14
18
} ]
15
19
16
20
const validCommandNames = commandList . map ( ( { name } ) => name )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const { github } = require('../providers')
3
3
const { initializeStore } = require ( '../store' )
4
4
const { logger } = require ( '../utils' )
5
5
const { validateGithubOrg, validateGithubListOrgRepos, validateGithubRepository } = require ( '../schemas' )
6
+ const checks = require ( '../checks' )
6
7
7
8
const updateGithubOrgs = async ( knex ) => {
8
9
const { getAllGithubOrganizations, updateGithubOrganization } = initializeStore ( knex )
@@ -57,7 +58,21 @@ const upsertGithubRepositories = async (knex) => {
57
58
} ) )
58
59
}
59
60
61
+ const runAllTheComplianceChecks = async ( knex ) => {
62
+ const { getAllComplianceChecks } = initializeStore ( knex )
63
+ debug ( 'Fetching all compliance checks' )
64
+ const complianceChecks = await getAllComplianceChecks ( )
65
+ const implementedChecks = complianceChecks . filter ( check => check . implementation_status === 'completed' )
66
+ logger . log ( 'Running all implemented checks sequentially' )
67
+ for ( const check of implementedChecks ) {
68
+ logger . log ( `Running check (${ check . code_name } )` )
69
+ await checks [ check . code_name ] ( knex )
70
+ }
71
+ logger . log ( 'All checks ran successfully' )
72
+ }
73
+
60
74
module . exports = {
61
75
updateGithubOrgs,
62
- upsertGithubRepositories
76
+ upsertGithubRepositories,
77
+ runAllTheComplianceChecks
63
78
}
You can’t perform that action at this time.
0 commit comments