Skip to content

Commit 1dc902c

Browse files
committed
feat: add upstream sysroot_script monitoring
1 parent fd0abf8 commit 1dc902c

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Check Upstream Sysroot Updates
2+
3+
description: |
4+
This workflow checks our sysroot scripts against Chromium's sysroot scripts
5+
at build/linux/sysroot_scripts and opens an issue if there are any new changes.
6+
7+
on:
8+
pull_request:
9+
schedule:
10+
- cron: "0 0 1,15 * *"
11+
workflow_dispatch:
12+
inputs:
13+
current-sha:
14+
type: string
15+
description: 'Current SHA for build/linux/sysroot_scripts'
16+
required: true
17+
upstream-sha:
18+
type: string
19+
description: 'Upstream SHA for build/linux/sysroot_scripts'
20+
required: true
21+
22+
jobs:
23+
check-upstream-sysroot:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Fetch Current SHA
27+
shell: bash
28+
run: |
29+
if [ -n "${{ github.event.inputs.current-sha }}" ]; then
30+
CURRENT_SHA="${{ github.event.inputs.current-sha }}"
31+
else
32+
if [ -f current-sha.json ]; then
33+
CURRENT_SHA=$(jq -r '.sha' current-sha.json)
34+
else
35+
echo "No current SHA provided and current-sha.json not found."
36+
exit 1
37+
fi
38+
fi
39+
echo "CURRENT_SHA=${CURRENT_SHA}" >> $GITHUB_ENV
40+
- name: Fetch latest upstream SHA
41+
shell: bash
42+
run: |
43+
if [ -n "${{ github.event.inputs.upstream-sha }}" ]; then
44+
UPSTREAM_SHA="${{ github.event.inputs.upstream-sha }}"
45+
else
46+
UPSTREAM_SHA=$(curl -s "https://api.github.com/repos/chromium/chromium/commits?path=build/linux/sysroot_scripts&per_page=1" | jq -r '.[0].sha')
47+
fi
48+
echo "UPSTREAM_SHA=${UPSTREAM_SHA}" >> $GITHUB_ENV
49+
- name: Compare current SHA with upstream SHA
50+
shell: bash
51+
run: |
52+
if [ "$CURRENT_SHA" == "$UPSTREAM_SHA" ]; then
53+
echo "No changes found - sysroot scripts are up to date!"
54+
else
55+
$(curl -s "https://api.github.com/repos/chromium/chromium/commits?path=build/linux/sysroot_scripts&per_page=20" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}") > commits.json
56+
57+
COMMITS=$(
58+
jq -r --arg base_sha "$CURRENT_SHA" '
59+
([.[].sha] | index($base_sha) // length) as $idx |
60+
.[0:$idx] | .[] |
61+
"- [`\(.sha[0:7])`](\(.html_url)) \(.commit.message | split("\n")[0])"
62+
' commits.json
63+
)
64+
65+
ISSUE_BODY=$(cat <<EOF
66+
### Upstream sysroot scripts have been updated
67+
68+
Commits between ${CURRENT_SHA} and ${UPSTREAM_SHA}:
69+
70+
${COMMITS}
71+
72+
Please review these changes and update our scripts accordingly.
73+
EOF
74+
)
75+
76+
BODY_JSON=$(jq -n --arg body "$ISSUE_BODY" --arg title "Upstream sysroot scripts have changed" '{title: $title, body: $body}')
77+
78+
curl -X POST \
79+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
80+
-H "Accept: application/vnd.github.v3+json" \
81+
-H "Content-Type: application/json" \
82+
-d "$BODY_JSON" \
83+
"https://api.github.com/repos/${{ github.repository }}/issues"
84+
fi

current-sha.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"sha": "082a46c99411023b97fae0476b526b54ff98aa3d"
3+
}

0 commit comments

Comments
 (0)