Added a script to list the last runs of all cgal's workflows (#7031)

## Summary of Changes

Addition of a script to list all the last runs of cgal workflows.
This commit is contained in:
Laurent Rineau 2023-03-08 09:38:52 +01:00 committed by GitHub
commit 52b5472aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 117 additions and 1 deletions

View File

@ -0,0 +1,43 @@
name: List workflow last run
on:
workflow_dispatch:
schedule:
- cron: "0 10 * * 1"
env:
GH_TOKEN: ${{ github.token }}
jobs:
list_workflow:
runs-on: ubuntu-latest
outputs:
messages: ${{ steps.cat_output.outputs.message }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: run script
run: |
chmod +x ./Scripts/developer_scripts/list_cgal_workflows_last_run.sh
./Scripts/developer_scripts/list_cgal_workflows_last_run.sh > output.md
- name: convert markdown to html
run: |
sudo apt-get update && sudo apt-get install -y pandoc
pandoc -f markdown -t html -o output.html output.md
- name: set_output
id: cat_output
run: |
delimiter="$(openssl rand -hex 8)"
echo "message<<${delimiter}" >> "${GITHUB_OUTPUT}"
echo "Subject:List workflow run \nContent-Type: text/html\n" >> "${GITHUB_OUTPUT}"
echo "<html><body>" >> "${GITHUB_OUTPUT}"
cat output.html >> "${GITHUB_OUTPUT}"
echo "</body></html>" >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
call_send_email:
needs: list_workflow
uses: ./.github/workflows/send_email.yml
with:
message: ${{needs.list_workflow.outputs.messages}}
secrets:
email: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_TO }}
private_key: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_SSH_PRIVATE_KEY }}
user: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_SSH_USER }}
host: ${{ secrets.CGAL_SEND_WORKFLOW_LIST_EMAIL_SSH_HOST }}

View File

@ -28,4 +28,4 @@ jobs:
ssh-keyscan -H ${{ secrets.host }} > ~/.ssh/known_hosts
- name: send email via ssh
run: |
echo "${{ inputs.message }}" | ssh ${{ secrets.user }}@${{ secrets.host }} "/sbin/sendmail -t ${{ secrets.email }}"
echo -e '${{ inputs.message }}' | ssh ${{ secrets.user }}@${{ secrets.host }} "/sbin/sendmail -t ${{ secrets.email }}"

View File

@ -0,0 +1,73 @@
#!/bin/bash
echo "| repo | workflow | branch | event | runs on | status of last run | state | annotation | date | date since last runs | file |"
echo "| :--: | :--------: | :----: | :---: | :------: | :------------------: | :---: | :--------: | :----: | :------------------: | :----: |"
actualdate=$EPOCHSECONDS
for repo in $(gh api orgs/CGAL/repos --jq '.[].full_name' | grep -v dev )
do
if [ "$repo" != "CGAL/CNRS" ] && [ "$repo" != "CGAL/GeometryFactory" ]
then
default_branch=$(gh api repos/$repo --jq '.default_branch')
workflows=$(gh api repos/$repo/actions/workflows)
workflows_count=$(jq '.total_count' <<< "$workflows")
for ((i=0;i<workflows_count;i++))
do
workflow_id=$(jq '.workflows['$i'].id' <<< "$workflows")
workflows_state=$(jq '.workflows['$i'].state' <<< "$workflows")
workflow_runs=$(gh api repos/$repo/actions/workflows/$workflow_id/runs)
workflows_name=$(jq -e '.workflow_runs[0].name' <<< "$workflow_runs")
if [ $? -eq 0 ]
then
workflows_status=$(jq -r '.workflow_runs[0].status' <<< "$workflow_runs")
workflows_conclusion=$(jq -r '.workflow_runs[0].conclusion' <<< "$workflow_runs")
workflows_start=$(jq -r '.workflow_runs[0].run_started_at' <<< "$workflow_runs")
workflows_date=$( date --date="$workflows_start" +%s )
workflows_on=$(jq -r '.workflow_runs[0].event' <<< "$workflow_runs")
workflows_path=$(jq -r '.workflow_runs[0].path' <<< "$workflow_runs")
workflows_branch=$(jq -r '.workflow_runs[0].head_branch' <<< "$workflow_runs")
workflows_checksuite_id=$(jq -r '.workflow_runs[0].check_suite_id' <<< "$workflow_runs")
workflows_check_runs=$(gh api repos/$repo/check-suites/$workflows_checksuite_id/check-runs)
workflows_check_runs_id=$(jq -r '.check_runs[0].id' <<< "$workflows_check_runs")
workflows_check_runs_annotation=$(gh api repos/$repo/check-runs/$workflows_check_runs_id/annotations)
worfklows_annotation_level=$(jq -r '.[].annotation_level' <<< "$workflows_check_runs_annotation")
if [ "$worfklows_annotation_level" == "" ]
then
worfklows_annotation_level+="-"
fi
workflows_event=""
for trigger in $(curl --silent https://raw.githubusercontent.com/$repo/$default_branch/$workflows_path | yq '.on' | grep -v ' .*'); do
if [ "${trigger}" != "-" ]
then
workflows_event+=${trigger}
workflows_event+="<br/>"
fi
done
echo "| $repo | $workflows_name | $workflows_branch | $workflows_event | $workflows_on | $workflows_status - $workflows_conclusion | $workflows_state | ***$worfklows_annotation_level*** | $workflows_start | $(((actualdate - workflows_date) / 86400 )) days | $repo/$workflows_path"
fi
done
fi
done
echo ""
echo "| repo | dependabot |"
echo "| :--: | :--------: |"
for repo in $(gh api orgs/CGAL/repos --jq '.[].full_name' | grep -v dev )
do
if [ "$repo" != "CGAL/CNRS" ] && [ "$repo" != "CGAL/GeometryFactory" ]
then
default_branch=$(gh api repos/$repo --jq '.default_branch')
workflows=$(gh api repos/$repo/actions/workflows)
workflows_count=$(jq '.total_count' <<< "$workflows")
if [ $workflows_count != 0 ]
then
dependabot=$(curl --silent https://raw.githubusercontent.com/$repo/$default_branch/.github/dependabot.yml)
dependabotexist=""
if [ "$dependabot" != "404: Not Found" ]
then
dependabotexist="yes"
else
dependabotexist="no"
fi
echo "| $repo | $dependabotexist |"
fi
fi
done