Skip to content

Commit

Permalink
Handling erroneous case with issue #11
Browse files Browse the repository at this point in the history
  • Loading branch information
rajbos committed Nov 26, 2021
1 parent b693c07 commit 094353b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/get-codeql-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ module.exports = async ({github, owner, repo}) => {

console.log(`Found owner [${owner}] and repo [${repo}] to check the code scanning alerts for`)

const recentScansData = await github.rest.codeScanning.listRecentAnalyses({
owner,
repo,
})
let recentScansData
try {
recentScansData = await github.rest.codeScanning.listRecentAnalyses({
owner,
repo,
})
} catch (error) {
console.log(`Error getting recent scans: [${error}]`)
}

let scanResult = {
created_at: null,
Expand All @@ -14,6 +19,7 @@ module.exports = async ({github, owner, repo}) => {
error: null,
environment: null
}

if (recentScansData === undefined) {
console.log(`recentScansData is undefined`)
}
Expand Down
8 changes: 8 additions & 0 deletions src/start-and-wait-codeql.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ module.exports = async ({github, owner, repo, path, ref}) => {
})

// check each job
let successfullJobs = 0
console.log(`Job results:`)
for (const job of data.jobs) {
console.log(` - Job [${job.name}] status [${job.status}] conclusion [${job.conclusion}]`)
if (job.status === 'completed' && job.conclusion === 'success') {
successfullJobs++
}
}

if (successfullJobs === 0) {
// post this information back into the request issue
}

return 1
Expand Down

0 comments on commit 094353b

Please sign in to comment.