-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): enable shellcheck and integrate check-status workflow (#1579…
- Loading branch information
Showing
3 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: check-status | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
- dev-[2-9][0-9].[0-9][0-9].x | ||
- master | ||
- "[2-9][0-9].[0-9][0-9].x" | ||
- hotfix-* | ||
- release-* | ||
|
||
jobs: | ||
check-status: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Check workflow statuses and display token usage | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "current rest api rate usage:" | ||
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .rate | ||
echo "" | ||
echo "" | ||
echo "current graphql rate usage:" | ||
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .resources.graphql | ||
echo "" | ||
echo "" | ||
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
with: | ||
script: | | ||
await exec.exec("sleep 20s"); | ||
for (let i = 0; i < 60; i++) { | ||
const failure = []; | ||
const cancelled = []; | ||
const pending = []; | ||
const result = await github.rest.checks.listSuitesForRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
}); | ||
result.data.check_suites.forEach(({ app: { slug }, conclusion, id}) => { | ||
if (slug === 'github-actions') { | ||
if (conclusion === 'failure' || conclusion === 'cancelled') { | ||
failure.push(id); | ||
} else if (conclusion === null) { | ||
pending.push(id); | ||
} | ||
console.log(`check suite ${id} => ${conclusion === null ? 'pending' : conclusion}`); | ||
} | ||
}); | ||
if (pending.length === 0) { | ||
core.setFailed("Cannot get pull request check status"); | ||
return; | ||
} | ||
if (failure.length > 0) { | ||
let failureMessage = ''; | ||
const failedCheckRuns = []; | ||
for await (const suite_id of failure) { | ||
const resultCheckRuns = await github.rest.checks.listForSuite({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
check_suite_id: suite_id | ||
}); | ||
resultCheckRuns.data.check_runs.forEach(({ conclusion, name, html_url }) => { | ||
if (conclusion === 'failure' || conclusion === 'cancelled') { | ||
failedCheckRuns.push(`<a href="${html_url}">${name} (${conclusion})</a>`); | ||
} | ||
}); | ||
} | ||
core.summary.addRaw(`${failedCheckRuns.length} job(s) failed:`, true) | ||
core.summary.addList(failedCheckRuns); | ||
core.summary.write() | ||
core.setFailed(`${failure.length} workflow(s) failed`); | ||
return; | ||
} | ||
if (pending.length === 1) { | ||
core.info("All workflows are ok"); | ||
return; | ||
} | ||
core.info(`${pending.length} workflows in progress`); | ||
await exec.exec("sleep 30s"); | ||
} | ||
core.setFailed("Timeout: some jobs are still in progress"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ gorgone: | |
- name: audit | ||
package: "gorgone::modules::centreon::audit::hooks" | ||
enable: true | ||
|