diff --git a/.github/config/chromium_diffing.json b/.github/config/chromium_diffing.json new file mode 100644 index 0000000000000..029f84060a22b --- /dev/null +++ b/.github/config/chromium_diffing.json @@ -0,0 +1,95 @@ +{ + "diff_label_prefix": "diff-", + "stable_branches": [ + { + "milestone": "m114", + "branch_num": 5735 + }, + { + "milestone": "m120", + "branch_num": 6099 + }, + { + "milestone": "m126", + "branch_num": 6478 + } + ], + "code_ownership": { + "ours": [ + ".github/", + "cobalt/", + "media/starboard/", + "media/mojo/clients/starboard/", + "media/mojo/services/starboard/", + "media/base/starboard/", + "starboard/", + "third_party/blink/renderer/modules/cobalt/", + "third_party/blink/renderer/core/cobalt/", + "third_party/blink/web_tests/wpt_internal/cobalt/", + "components/viz/service/display/starboard/", + "ui/ozone/platform/starboard/", + ".pre-commit-config.yaml", + ".pylintrc", + "docker-compose.yaml" + ], + "our_files": [ + "base/base_paths_starboard.cc", + "base/base_paths_starboard.h", + "base/message_loop/message_pump_ui_starboard.cc", + "base/message_loop/message_pump_ui_starboard.h", + "base/system/sys_info_starboard_unittest.cc", + "base/system/sys_info_starboard.cc", + "base/system/sys_info_starboard.h", + "base/test/test_support_starboard.cc", + "base/test/test_support_starboard.h", + "base/time/time_now_starboard.cc", + "base/time/time_starboard.cc", + "net/base/network_change_notifier_starboard.h", + "net/base/network_interfaces_starboard.cc", + "net/base/platform_mime_util_starboard.cc", + "media/formats/mp4/ac3_unittest.cc", + "media/formats/mp4/eac3_unittest.cc", + "third_party/blink/renderer/core/frame/csp/local_ip.cc", + "third_party/blink/renderer/core/frame/csp/local_ip.h", + "third_party/blink/renderer/platform/media/web_content_decryption_module_impl_unittest.cc", + "third_party/blink/web_tests/external/wpt/media-source/SourceBuffer-writeHead.html", + "third_party/blink/web_tests/media/encrypted-media/encrypted-media-getmetrics.html" + ], + "our_owned_dep": [ + "third_party/boringssl/src", + "third_party/googletest/src" + ], + "our_added_dep": [ + "third_party/android_deps/libs/com_google_android_gms_play_services_ads_identifier", + "third_party/de265_includes", + "third_party/ffmpeg_includes", + "third_party/libfdkaac", + "third_party/llvm-project", + "third_party/lz4_lib", + "third_party/musl", + "third_party/openh264/include", + "third_party/pulseaudio_includes" + ], + "our_deleted_dep": [ + "third_party/google_input_tools", + "third_party/rust/atty", + "third_party/rust/camino", + "third_party/rust/cargo_metadata", + "third_party/rust/cargo_platform", + "third_party/rust/fastrand", + "third_party/rust/hashbrown", + "third_party/rust/indexmap", + "third_party/rust/once_cell", + "third_party/rust/remove_dir_all", + "third_party/rust/tempfile", + "third_party/rust/toml", + "tools/stats_viewer", + "tools/win/ChromeDebug" + ], + "updated": [ + "third_party/crashpad/crashpad/third_party/cpp-httplib", + "third_party/rust/rstest/v0_12/crate/docs/head", + "ui/file_manager/image_loader/piex/package-lock.json" + ] + } +} \ No newline at end of file diff --git a/.github/workflows/diff_chromium_branches.yaml b/.github/workflows/diff_chromium_branches.yaml new file mode 100644 index 0000000000000..8ef68ab91fdf1 --- /dev/null +++ b/.github/workflows/diff_chromium_branches.yaml @@ -0,0 +1,141 @@ +name: Diff from Chromium branches +permissions: + contents: read +on: + workflow_dispatch: + inputs: + upstream_branches: + description: 'List of Chromium branches to diff from (comma separated).' + required: true + type: string + downstream_branch: + description: 'Name of the branch to perform the diff with.' + required: true + type: string + pull_request: + types: + - labeled + - synchronize +jobs: + initialize: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Set upstream branches + id: set-upstream-branches + env: + PR_LABELS: ${{ toJson(github.event.pull_request.labels) }} + EVENT_ACTION: ${{ github.event.action }} + UPSTREAM_BRANCHES: ${{ inputs.upstream_branches }} + shell: bash + run: | + set -x + if [[ $EVENT_ACTION == "workflow_dispatch" ]]; then + # If manually triggered, get branches from comma-separated branches from inputs + export DIFF_LABELS=$(echo "$UPSTREAM_BRANCHES" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + else + # If label or synchronize Get the upstream branches from labels prefixed with $DIFF_PREFIX + DIFF_PREFIX=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq -r '.diff_label_prefix') + export DIFF_LABELS=$(echo "$PR_LABELS" | jq -r --arg prefix "$DIFF_PREFIX" '.[] | select(.name | startswith($prefix)) | .name | sub($prefix; "")') + fi + # # Convert into regex needed for filtering with jq + SELECTED_BRANCHES=$(echo "$DIFF_LABELS" | tr '\n' '|' | sed 's/|$/\n/') + JQ_QUERY="[.stable_branches[] | select(.milestone | test(\"^($SELECTED_BRANCHES)$\"))]" + UPSTREAM_BRANCHES=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq "${JQ_QUERY}") + echo 'upstream_branches<> $GITHUB_OUTPUT + echo "${UPSTREAM_BRANCHES}" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + - name: Set downstream branch + id: set-downstream-branch + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + shell: bash + run: | + set -x + if [[ $EVENT_ACTION == "workflow_dispatch" ]]; then + # Get the trimmed downstream branch directly from inputs + DOWNSTREAM_BRANCH=$(echo ${{ inputs.downstream_branch }} | sed 's/^[[:space:]]*//;s/[[:space:]]*$//)') + else + # Get the downstream branch from the labelled PR + DOWNSTREAM_BRANCH="refs/pull/$PR_NUMBER/head" + fi + echo "downstream_branch=${DOWNSTREAM_BRANCH}" >> $GITHUB_OUTPUT + - name: Set code ownership + id: set-code-ownership + shell: bash + run: | + set -x + CODE_OWNERSHIP=$(cat ${GITHUB_WORKSPACE}/.github/config/chromium_diffing.json | jq .code_ownership) + echo 'code_ownership<> $GITHUB_OUTPUT + echo "${CODE_OWNERSHIP}" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + outputs: + upstream_branches: ${{ steps.set-upstream-branches.outputs.upstream_branches }} + downstream_branch: ${{ steps.set-downstream-branch.outputs.downstream_branch }} + code_ownership: ${{ steps.set-code-ownership.outputs.code_ownership }} + calculate_diffs: + needs: [initialize] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + upstream_branch: ${{ fromJson(needs.initialize.outputs.upstream_branches) }} + steps: + - uses: actions/checkout@v4 + with: + ref: chromium/${{ matrix.upstream_branch.milestone }} + - name: Calculate main diff (excluding downstream-owned folders) + env: + DOWNSTREAM_REF: ${{ needs.initialize.outputs.downstream_branch }} + CODE_OWNERSHIP: ${{ needs.initialize.outputs.code_ownership }} + run: | + set -x + git fetch origin "$DOWNSTREAM_REF" + git config set diff.renameLimit 100000 + EXCLUDE_PATHS_FOR_MAIN_DIFF=$(echo "$CODE_OWNERSHIP" | jq -r ' + .ours + + .our_files + + .our_owned_dep + + .our_added_dep + + .our_deleted_dep + + .updated + | map(":(exclude)" + .) | .[] + ') + # Diff downstream to checked out branch (upstream) + readarray -t EXCLUDE_PATHS_ARRAY <<< "$EXCLUDE_PATHS_FOR_MAIN_DIFF" + git diff HEAD..FETCH_HEAD -- . "${EXCLUDE_PATHS_ARRAY[@]}" > main_diff.diff + - name: Check for downstream deletions in excluded folders + env: + DOWNSTREAM_REF: ${{ needs.initialize.outputs.downstream_branch }} + CODE_OWNERSHIP: ${{ needs.initialize.outputs.code_ownership }} + run: | + set -x + DOWNSTREAM_OWNED_FOLDER_TO_CHECK=$(echo "$CODE_OWNERSHIP" | jq -r ' + .ours + + .our_files + + .our_owned_dep + + .our_added_dep + + .updated + | .[] + ') + readarray -t PATHS_TO_CHECK_ARRAY <<< "$DOWNSTREAM_OWNED_FOLDER_TO_CHECK" + git diff --diff-filter=D HEAD..FETCH_HEAD -- ${PATHS_TO_CHECK_ARRAY[@]} > downstream_removal.diff + - name: Report Diffs + run: | + sudo apt-get update + sudo apt-get install -y diffstat + echo "This is will be replaced with proper logging later" + echo "--------------------------------------------------" + echo "SUMMARY OF MAIN DIFFS" + echo "--------------------------------------------------" + echo "" + diffstat main_diff.diff + echo "" + echo "--------------------------------------------------" + echo "SUMMARY OF ADDED DIFFS" + echo "--------------------------------------------------" + echo "" + diffstat downstream_removal.diff diff --git a/.github/workflows/sync_chromium_branches.yaml b/.github/workflows/sync_chromium_branches.yaml index 5d21f2c1731c7..057bf9c25409b 100644 --- a/.github/workflows/sync_chromium_branches.yaml +++ b/.github/workflows/sync_chromium_branches.yaml @@ -1,10 +1,9 @@ name: Sync Chromium branches on: workflow_dispatch: - # Runs everyday at midnight UTC. + # Runs everyday. schedule: - cron: '0 0 * * *' -permissions: read-all jobs: sync: runs-on: [self-hosted, chrobalt-linux-runner] @@ -13,26 +12,46 @@ jobs: strategy: fail-fast: false matrix: - # Found here: https://chromiumdash.appspot.com/branches branch: [ - {milestone: m114, branch_num: 5735}, - {milestone: m120, branch_num: 6099}, + {milestone: m114, branch_num: 5735}, + {milestone: m120, branch_num: 6099}, {milestone: m126, branch_num: 6478}, + {milestone: m131, branch_num: 6778}, ] + outputs: + output1: ${{ steps.diff_step.outputs.diff_present }} steps: + # Attempt to checkout our chromium reference, if missing we will create a new branch - uses: actions/checkout@v4 + id: checkout + continue-on-error: true with: ref: chromium/${{ matrix.branch.milestone }} + - name: Fallback to main branch + uses: actions/checkout@v4 + if: steps.checkout.outcome == 'failure' + with: + ref: main - name: Setup Git run: | git config --global user.name "GitHub Release Automation" git config --global user.email "github@google.com" - - name: Pull ${{ matrix.branch.milestone }} from upstream and apply diffs - id: diff_step - run: | # Add Chromium remote and pull the upstream branch. git remote add upstream https://chromium.googlesource.com/chromium/src git fetch --depth=1 upstream refs/branch-heads/${{ matrix.branch.branch_num }}:refs/remotes/branch/${{ matrix.branch.branch_num }} + - name: Create new branch if missing chromium branch + if: steps.checkout.outcome == 'failure' + run: | + git checkout refs/remotes/branch/${{ matrix.branch.branch_num }} + ORIGINAL_TREE_HASH=$(git rev-parse HEAD^{tree}) + ORIGINAL_COMMIT_HASH=$(git rev-parse HEAD) + NEW_ROOT_COMMIT_HASH=$(git commit-tree "$ORIGINAL_TREE_HASH" -m "First commit for ${{ matrix.branch.milestone }}.") + git checkout -b chromium/${{ matrix.branch.milestone }} $NEW_ROOT_COMMIT_HASH + git commit --amend --not-edit -c ORIGINAL_COMMIT_HASH + git push --set-upstream origin chromium/${{ matrix.branch.milestone }} + - name: Pull ${{ matrix.branch.milestone }} from upstream and apply diffs + id: diff_step + run: | git diff HEAD branch/${{ matrix.branch.branch_num }} --binary > chromium_diff.patch - name: Apply and push diffs run: | diff --git a/upstream_additions.diff b/upstream_additions.diff new file mode 100644 index 0000000000000..e69de29bb2d1d