Skip to content

Commit

Permalink
Commit the reports into repo and only use summary in issues (#950)
Browse files Browse the repository at this point in the history
To avoid failures due to issue body being too long.
  • Loading branch information
joyeecheung authored Aug 30, 2024
1 parent b38b277 commit 70cf85a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 19 deletions.
61 changes: 42 additions & 19 deletions .github/workflows/reliability_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,54 @@

name: Update CI reliability

permissions:
contents: write

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

jobs:
create-report:
name: Create and update the report
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: npm i -g @node-core/utils
- run: ncu-config --global set jenkins_token ${{ secrets.JENKINS_TOKEN }}
- run: ncu-config --global set token ${{ secrets.USER_TOKEN }}
- run: ncu-config --global set username ${{ secrets.USER_NAME }}
- run: ncu-ci walk pr --stats=true --markdown $PWD/results.md
- run: cat $PWD/results.md >> $GITHUB_STEP_SUMMARY
- run: |
title_date=$(date +%Y-%m-%d)
echo "{ \"title\": \"CI Reliability ${title_date}\", \"body\": " >> body.json
cat results.md | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' >> body.json
echo "}" >> body.json
curl --request POST \
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/issues \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data @body.json
- name: Clone reliability
uses: actions/checkout@v4
with:
path: reliability
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install @node-core/utils
run: npm install -g @node-core/utils

- name: Configure @node-core/utils
run: |
ncu-config --global set jenkins_token ${{ secrets.JENKINS_TOKEN }}
ncu-config --global set token ${{ secrets.USER_TOKEN }}
ncu-config --global set username ${{ secrets.USER_NAME }}
- name: Generate reports
run: |
cd reliability
./generate-report.sh
cat ./progress.md >> $GITHUB_STEP_SUMMARY
cat ./reports/$(date +%Y-%m-%d).md >> $GITHUB_STEP_SUMMARY
- name: Create issue
run: |
title_date=$(date +%Y-%m-%d)
echo "{ \"title\": \"CI Reliability ${title_date}\", \"body\": " >> body.json
cat reliability/progress.md | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' >> body.json
echo "}" >> body.json
curl --request POST \
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/issues \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data @body.json
17 changes: 17 additions & 0 deletions generate-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

mkdir -p reports
DATENAME=$(date +"%Y-%m-%d")
REPORT=reports/$DATENAME.md
ncu-ci walk pr --stats=true --markdown $REPORT
awk '/^### / {exit} {print}' $REPORT > progress.md
echo "Open https://github.com/$GITHUB_REPOSITORY/blob/main/$REPORT to see failure details" >> progress.md
echo -en "\n" >> progress.md

awk '/^### Progress/ {found=1} found' $REPORT >> progress.md
echo -en "\n" >> progress.md

sed -i '/^### Progress/,$d' $REPORT
git add ./reports
git commit -m "Add report for $DATENAME"
git push

0 comments on commit 70cf85a

Please sign in to comment.