Skip to content

Commit c378026

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

2 files changed

Lines changed: 229 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: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Diff from Chromium branches
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
upstream_branches:
6+
description: 'List of Chromium branches to diff from (comma separated).'
7+
required: true
8+
type: string
9+
downstream_branch:
10+
description: 'Name of the branch to perform the diff with.'
11+
required: true
12+
type: string
13+
pull_request:
14+
types:
15+
- labeled
16+
- synchronize
17+
jobs:
18+
initialize:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1
25+
- name: Set upstream branches
26+
id: set-upstream-branches
27+
env:
28+
PR_LABELS: ${{ toJson(github.event.pull_request.labels) }}
29+
EVENT_ACTION: ${{ github.event.action }}
30+
UPSTREAM_BRANCHES: ${{ inputs.upstream_branches }}
31+
shell: bash
32+
run: |
33+
set -x
34+
if [[ $EVENT_ACTION == "workflow_dispatch" ]]; then
35+
# If manually triggered, get branches from comma-separated branches from inputs
36+
export DIFF_LABELS=$(echo "$UPSTREAM_BRANCHES" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
37+
else
38+
# If label or synchronize Get the upstream branches from labels prefixed with $DIFF_PREFIX
39+
DIFF_PREFIX=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq -r '.diff_label_prefix')
40+
export DIFF_LABELS=$(echo "$PR_LABELS" | jq -r --arg prefix "$DIFF_PREFIX" '.[] | select(.name | startswith($prefix)) | .name | sub($prefix; "")')
41+
fi
42+
# # Convert into regex needed for filtering with jq
43+
SELECTED_BRANCHES=$(echo "$DIFF_LABELS" | tr '\n' '|' | sed 's/|$/\n/')
44+
JQ_QUERY="[.stable_branches[] | select(.milestone | test(\"^($SELECTED_BRANCHES)$\"))]"
45+
UPSTREAM_BRANCHES=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq "${JQ_QUERY}")
46+
echo 'upstream_branches<<EOF' >> $GITHUB_OUTPUT
47+
echo "${UPSTREAM_BRANCHES}" >> $GITHUB_OUTPUT
48+
echo 'EOF' >> $GITHUB_OUTPUT
49+
- name: Set downstream branch
50+
id: set-downstream-branch
51+
shell: bash
52+
run: |
53+
set -x
54+
if [[ $EVENT_ACTION == "workflow_dispatch" ]]; then
55+
# Get the trimmed downstream branch directly from inputs
56+
DOWNSTREAM_BRANCH=$(echo ${{ inputs.downstream_branch }} | sed 's/^[[:space:]]*//;s/[[:space:]]*$//)')
57+
else
58+
# Get the downstream branch from the labelled PR
59+
DOWNSTREAM_BRANCH={{ github.ref_name}}
60+
fi
61+
echo "downstream_branch=${DOWNSTREAM_BRANCH}" >> $GITHUB_OUTPUT
62+
- name: Set code ownership
63+
id: set-code-ownership
64+
shell: bash
65+
run: |
66+
set -x
67+
CODE_OWNERSHIP=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq .code_ownership")
68+
echo 'code_ownership<<EOF' >> $GITHUB_OUTPUT
69+
echo "${CODE_OWNERSHIP}"" >> $GITHUB_OUTPUT
70+
echo 'EOF' >> $GITHUB_OUTPUT
71+
outputs:
72+
upstream_branches: ${{ steps.set-upstream-branches.outputs.upstream_branches }}
73+
downstream_branch: ${{ steps.set-downstream-branch.outputs.downstream_branch }}
74+
code_ownership: ${{ steps.set-code-ownership.outputs.code_ownership }}
75+
calculate_diffs:
76+
needs: [initialize]
77+
runs-on: ubuntu-latest
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
upstream_branch: ${{ fromJson(needs.initialize.outputs.upstream_branches) }}
82+
steps:
83+
- uses: actions/checkout@v4
84+
with:
85+
ref: chromium/${{ matrix.upstream_branch.milestone }}
86+
- name: Calculate main diff (excluding downstream-owned folders)
87+
env:
88+
DOWNSTREAM_REF: ${{ needs.initialize.outputs.downstream_branch }}
89+
CODE_OWNERSHIP: ${{ needs.initialize.outputs.code_ownership }}
90+
run: |
91+
set -x
92+
git config set diff.renameLimit 100000
93+
EXCLUDE_PATHS_FOR_MAIN_DIFF=$(echo "$CODE_OWNERSHIP" | jq -r '
94+
.ours +
95+
.our_files +
96+
.our_owned_dep +
97+
.our_added_dep +
98+
.our_deleted_dep +
99+
.updated
100+
| map(":(exclude)" + .) | .[]
101+
')
102+
# Diff downstream to checked out branch (upstream)
103+
readarray -t EXCLUDE_PATHS_ARRAY <<< "$EXCLUDE_PATHS_FOR_MAIN_DIFF"
104+
git diff HEAD..$DOWNSTREAM_REF -- . "${EXCLUDE_PATHS_ARRAY[@]}" > main_diff.diff
105+
- name: Check for upstream addtions in excluded folders
106+
env:
107+
DOWNSTREAM_REF: ${{ needs.initialize.outputs.downstream_branch }}
108+
CODE_OWNERSHIP: ${{ needs.initialize.outputs.code_ownership }}
109+
run: |
110+
set -x
111+
DOWNSTREAM_OWNED_FOLDER_TO_CHECK=$(echo "$CODE_OWNERSHIP" | jq -r '
112+
.ours +
113+
.our_files +
114+
.our_owned_dep +
115+
.our_added_dep +
116+
.updated
117+
| .[]
118+
')
119+
readarray -t PATHS_TO_CHECK_ARRAY <<< "$DOWNSTREAM_OWNED_FOLDER_TO_CHECK"
120+
$(git diff --diff-filter=A $DOWNSTREAM_REF..HEAD -- ${PATHS_TO_CHECK_ARRAY[@]}) > upstream_additions.diff
121+
- name: Report Diffs
122+
run: |
123+
echo "This is will be replaced with proper logging later"
124+
echo "--------------------------------------------------"
125+
echo "SUMMARY OF MAIN DIFFS"
126+
echo "--------------------------------------------------"
127+
echo ""
128+
echo $(diffstat main_diff.diff)
129+
echo ""
130+
echo "--------------------------------------------------"
131+
echo "SUMMARY OF ADDED DIFFS"
132+
echo "--------------------------------------------------"
133+
echo ""
134+
echo $(diffstat main_diff.diff)

0 commit comments

Comments
 (0)