Skip to content

Commit ce95916

Browse files
committed
implement diff workflow
Change-Id: Ib894b3ac877afe5471d24c663945149a668183e1
1 parent 019ae9d commit ce95916

3 files changed

Lines changed: 236 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"diff_label_prefix": "diff-",
3+
"stable_branches": [
4+
{
5+
"milestone": "m114",
6+
"branch_num": 5735
7+
},
8+
{
9+
"milestone": "m120",
10+
"branch_num": 6099
11+
},
12+
{
13+
"milestone": "m126",
14+
"branch_num": 6478
15+
}
16+
],
17+
"code_ownership": {
18+
"ours": [
19+
".github/",
20+
"cobalt/",
21+
"media/starboard/",
22+
"media/mojo/clients/starboard/",
23+
"media/mojo/services/starboard/",
24+
"media/base/starboard/",
25+
"starboard/",
26+
"third_party/blink/renderer/modules/cobalt/",
27+
"third_party/blink/renderer/core/cobalt/",
28+
"third_party/blink/web_tests/wpt_internal/cobalt/",
29+
"components/viz/service/display/starboard/",
30+
"ui/ozone/platform/starboard/",
31+
".pre-commit-config.yaml",
32+
".pylintrc",
33+
"docker-compose.yaml"
34+
],
35+
"our_files": [
36+
"base/base_paths_starboard.cc",
37+
"base/base_paths_starboard.h",
38+
"base/message_loop/message_pump_ui_starboard.cc",
39+
"base/message_loop/message_pump_ui_starboard.h",
40+
"base/system/sys_info_starboard_unittest.cc",
41+
"base/system/sys_info_starboard.cc",
42+
"base/system/sys_info_starboard.h",
43+
"base/test/test_support_starboard.cc",
44+
"base/test/test_support_starboard.h",
45+
"base/time/time_now_starboard.cc",
46+
"base/time/time_starboard.cc",
47+
"net/base/network_change_notifier_starboard.h",
48+
"net/base/network_interfaces_starboard.cc",
49+
"net/base/platform_mime_util_starboard.cc",
50+
"media/formats/mp4/ac3_unittest.cc",
51+
"media/formats/mp4/eac3_unittest.cc",
52+
"third_party/blink/renderer/core/frame/csp/local_ip.cc",
53+
"third_party/blink/renderer/core/frame/csp/local_ip.h",
54+
"third_party/blink/renderer/platform/media/web_content_decryption_module_impl_unittest.cc",
55+
"third_party/blink/web_tests/external/wpt/media-source/SourceBuffer-writeHead.html",
56+
"third_party/blink/web_tests/media/encrypted-media/encrypted-media-getmetrics.html"
57+
],
58+
"our_owned_dep": [
59+
"third_party/boringssl/src",
60+
"third_party/googletest/src"
61+
],
62+
"our_added_dep": [
63+
"third_party/android_deps/libs/com_google_android_gms_play_services_ads_identifier",
64+
"third_party/de265_includes",
65+
"third_party/ffmpeg_includes",
66+
"third_party/libfdkaac",
67+
"third_party/llvm-project",
68+
"third_party/lz4_lib",
69+
"third_party/musl",
70+
"third_party/openh264/include",
71+
"third_party/pulseaudio_includes"
72+
],
73+
"our_deleted_dep": [
74+
"third_party/google_input_tools",
75+
"third_party/rust/atty",
76+
"third_party/rust/camino",
77+
"third_party/rust/cargo_metadata",
78+
"third_party/rust/cargo_platform",
79+
"third_party/rust/fastrand",
80+
"third_party/rust/hashbrown",
81+
"third_party/rust/indexmap",
82+
"third_party/rust/once_cell",
83+
"third_party/rust/remove_dir_all",
84+
"third_party/rust/tempfile",
85+
"third_party/rust/toml",
86+
"tools/stats_viewer",
87+
"tools/win/ChromeDebug"
88+
],
89+
"updated": [
90+
"third_party/crashpad/crashpad/third_party/cpp-httplib",
91+
"third_party/rust/rstest/v0_12/crate/docs/head",
92+
"ui/file_manager/image_loader/piex/package-lock.json"
93+
]
94+
}
95+
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Diff from Chromium branches
2+
permissions:
3+
contents: read
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
upstream_branches:
8+
description: 'List of Chromium branches to diff from (comma separated).'
9+
required: true
10+
type: string
11+
downstream_branch:
12+
description: 'Name of the branch to perform the diff with.'
13+
required: true
14+
type: string
15+
pull_request:
16+
types:
17+
- labeled
18+
- synchronize
19+
jobs:
20+
initialize:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 1
27+
- name: Set upstream branches
28+
id: set-upstream-branches
29+
env:
30+
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
31+
EVENT_ACTION: ${{ github.event.action }}
32+
UPSTREAM_BRANCHES: ${{ inputs.upstream_branches }}
33+
shell: bash
34+
run: |
35+
set -x
36+
if [[ $EVENT_ACTION == "workflow_dispatch" ]]; then
37+
# If manually triggered, get branches from comma-separated branches from inputs
38+
export DIFF_LABELS=$(echo "$UPSTREAM_BRANCHES" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
39+
else
40+
# If label or synchronize Get the upstream branches from labels prefixed with $DIFF_PREFIX
41+
DIFF_PREFIX=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq -r '.diff_label_prefix')
42+
export DIFF_LABELS=$(echo "$PR_LABELS" | jq -r --arg prefix "$DIFF_PREFIX" '.[] | select(.name | startswith($prefix)) | .name | sub($prefix; "")')
43+
fi
44+
# # Convert into regex needed for filtering with jq
45+
SELECTED_BRANCHES=$(echo "$DIFF_LABELS" | tr '\n' '|' | sed 's/|$/\n/')
46+
JQ_QUERY="[.stable_branches[] | select(.milestone | test(\"^($SELECTED_BRANCHES)$\"))]"
47+
UPSTREAM_BRANCHES=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq "${JQ_QUERY}")
48+
echo 'upstream_branches<<EOF' >> $GITHUB_OUTPUT
49+
echo "${UPSTREAM_BRANCHES}" >> $GITHUB_OUTPUT
50+
echo 'EOF' >> $GITHUB_OUTPUT
51+
- name: Set downstream branch
52+
id: set-downstream-branch
53+
env:
54+
PR_NUMBER: ${{ github.event.pull_request.number }}
55+
shell: bash
56+
run: |
57+
set -x
58+
if [[ $EVENT_ACTION == "workflow_dispatch" ]]; then
59+
# Get the trimmed downstream branch directly from inputs
60+
DOWNSTREAM_BRANCH=$(echo ${{ inputs.downstream_branch }} | sed 's/^[[:space:]]*//;s/[[:space:]]*$//)')
61+
else
62+
# Get the downstream branch from the labelled PR
63+
DOWNSTREAM_BRANCH="refs/pull/$PR_NUMBER/head"
64+
fi
65+
echo "downstream_branch=${DOWNSTREAM_BRANCH}" >> $GITHUB_OUTPUT
66+
- name: Set code ownership
67+
id: set-code-ownership
68+
shell: bash
69+
run: |
70+
set -x
71+
CODE_OWNERSHIP=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq .code_ownership)
72+
echo 'code_ownership<<EOF' >> $GITHUB_OUTPUT
73+
echo "${CODE_OWNERSHIP}" >> $GITHUB_OUTPUT
74+
echo 'EOF' >> $GITHUB_OUTPUT
75+
outputs:
76+
upstream_branches: ${{ steps.set-upstream-branches.outputs.upstream_branches }}
77+
downstream_branch: ${{ steps.set-downstream-branch.outputs.downstream_branch }}
78+
code_ownership: ${{ steps.set-code-ownership.outputs.code_ownership }}
79+
calculate_diffs:
80+
needs: [initialize]
81+
runs-on: ubuntu-latest
82+
strategy:
83+
fail-fast: false
84+
matrix:
85+
upstream_branch: ${{ fromJson(needs.initialize.outputs.upstream_branches) }}
86+
steps:
87+
- uses: actions/checkout@v4
88+
with:
89+
ref: chromium/${{ matrix.upstream_branch.milestone }}
90+
- name: Calculate main diff (excluding downstream-owned folders)
91+
env:
92+
DOWNSTREAM_REF: ${{ needs.initialize.outputs.downstream_branch }}
93+
CODE_OWNERSHIP: ${{ needs.initialize.outputs.code_ownership }}
94+
run: |
95+
set -x
96+
git fetch origin "$DOWNSTREAM_REF"
97+
git config set diff.renameLimit 100000
98+
EXCLUDE_PATHS_FOR_MAIN_DIFF=$(echo "$CODE_OWNERSHIP" | jq -r '
99+
.ours +
100+
.our_files +
101+
.our_owned_dep +
102+
.our_added_dep +
103+
.our_deleted_dep +
104+
.updated
105+
| map(":(exclude)" + .) | .[]
106+
')
107+
# Diff downstream to checked out branch (upstream)
108+
readarray -t EXCLUDE_PATHS_ARRAY <<< "$EXCLUDE_PATHS_FOR_MAIN_DIFF"
109+
git diff HEAD..FETCH_HEAD -- . "${EXCLUDE_PATHS_ARRAY[@]}" > main_diff.diff
110+
- name: Check for upstream addtions in excluded folders
111+
env:
112+
DOWNSTREAM_REF: ${{ needs.initialize.outputs.downstream_branch }}
113+
CODE_OWNERSHIP: ${{ needs.initialize.outputs.code_ownership }}
114+
run: |
115+
set -x
116+
DOWNSTREAM_OWNED_FOLDER_TO_CHECK=$(echo "$CODE_OWNERSHIP" | jq -r '
117+
.ours +
118+
.our_files +
119+
.our_owned_dep +
120+
.our_added_dep +
121+
.updated
122+
| .[]
123+
')
124+
readarray -t PATHS_TO_CHECK_ARRAY <<< "$DOWNSTREAM_OWNED_FOLDER_TO_CHECK"
125+
git diff --diff-filter=A FETCH_HEAD..HEAD -- ${PATHS_TO_CHECK_ARRAY[@]} > upstream_additions.diff
126+
- name: Report Diffs
127+
run: |
128+
sudo apt-get update
129+
sudo apt-get install -y diffstat
130+
echo "This is will be replaced with proper logging later"
131+
echo "--------------------------------------------------"
132+
echo "SUMMARY OF MAIN DIFFS"
133+
echo "--------------------------------------------------"
134+
echo ""
135+
echo $(diffstat main_diff.diff)
136+
echo ""
137+
echo "--------------------------------------------------"
138+
echo "SUMMARY OF ADDED DIFFS"
139+
echo "--------------------------------------------------"
140+
echo ""
141+
echo $(diffstat upstream_additions.diff)

upstream_additions.diff

Whitespace-only changes.

0 commit comments

Comments
 (0)