Skip to content

Commit 70cf85a

Browse files
authored
Commit the reports into repo and only use summary in issues (#950)
To avoid failures due to issue body being too long.
1 parent b38b277 commit 70cf85a

File tree

2 files changed

+59
-19
lines changed

2 files changed

+59
-19
lines changed

.github/workflows/reliability_report.yml

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,54 @@
66

77
name: Update CI reliability
88

9+
permissions:
10+
contents: write
11+
912
on:
1013
schedule:
1114
- cron: '0 0 * * *'
1215
workflow_dispatch:
1316

1417
jobs:
1518
create-report:
19+
name: Create and update the report
1620
runs-on: ubuntu-latest
1721
steps:
18-
- uses: actions/setup-node@v4
19-
with:
20-
node-version: lts/*
21-
- run: npm i -g @node-core/utils
22-
- run: ncu-config --global set jenkins_token ${{ secrets.JENKINS_TOKEN }}
23-
- run: ncu-config --global set token ${{ secrets.USER_TOKEN }}
24-
- run: ncu-config --global set username ${{ secrets.USER_NAME }}
25-
- run: ncu-ci walk pr --stats=true --markdown $PWD/results.md
26-
- run: cat $PWD/results.md >> $GITHUB_STEP_SUMMARY
27-
- run: |
28-
title_date=$(date +%Y-%m-%d)
29-
echo "{ \"title\": \"CI Reliability ${title_date}\", \"body\": " >> body.json
30-
cat results.md | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' >> body.json
31-
echo "}" >> body.json
32-
curl --request POST \
33-
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/issues \
34-
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
35-
--header 'content-type: application/json' \
36-
--data @body.json
22+
- name: Clone reliability
23+
uses: actions/checkout@v4
24+
with:
25+
path: reliability
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Install Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: lts/*
32+
33+
- name: Install @node-core/utils
34+
run: npm install -g @node-core/utils
35+
36+
- name: Configure @node-core/utils
37+
run: |
38+
ncu-config --global set jenkins_token ${{ secrets.JENKINS_TOKEN }}
39+
ncu-config --global set token ${{ secrets.USER_TOKEN }}
40+
ncu-config --global set username ${{ secrets.USER_NAME }}
41+
42+
- name: Generate reports
43+
run: |
44+
cd reliability
45+
./generate-report.sh
46+
cat ./progress.md >> $GITHUB_STEP_SUMMARY
47+
cat ./reports/$(date +%Y-%m-%d).md >> $GITHUB_STEP_SUMMARY
48+
49+
- name: Create issue
50+
run: |
51+
title_date=$(date +%Y-%m-%d)
52+
echo "{ \"title\": \"CI Reliability ${title_date}\", \"body\": " >> body.json
53+
cat reliability/progress.md | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))' >> body.json
54+
echo "}" >> body.json
55+
curl --request POST \
56+
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/issues \
57+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
58+
--header 'content-type: application/json' \
59+
--data @body.json

generate-report.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir -p reports
4+
DATENAME=$(date +"%Y-%m-%d")
5+
REPORT=reports/$DATENAME.md
6+
ncu-ci walk pr --stats=true --markdown $REPORT
7+
awk '/^### / {exit} {print}' $REPORT > progress.md
8+
echo "Open https://github.com/$GITHUB_REPOSITORY/blob/main/$REPORT to see failure details" >> progress.md
9+
echo -en "\n" >> progress.md
10+
11+
awk '/^### Progress/ {found=1} found' $REPORT >> progress.md
12+
echo -en "\n" >> progress.md
13+
14+
sed -i '/^### Progress/,$d' $REPORT
15+
git add ./reports
16+
git commit -m "Add report for $DATENAME"
17+
git push

0 commit comments

Comments
 (0)