Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .ci/scripts/check_c10_sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -eux
ls pytorch/.git || git clone https://github.com/pytorch/pytorch.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: --depth 1? or will the commit checkout not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure --depth 1 will break checking out specific commit. also checked and there's no way to clone just a specific commit

pytorch_pin="$(< .ci/docker/ci_commit_pins/pytorch.txt)"
pushd pytorch
git checkout "$pytorch_pin"
popd
"$(dirname "${BASH_SOURCE[0]}")"/compare_dirs.sh runtime/core/portable_type/c10/c10 pytorch/c10
54 changes: 54 additions & 0 deletions .ci/scripts/compare_dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -eux

# Check if dir1's files are also found in dir2 with the same
# contents. Exempt files named BUCK, CMakeLists.txt, TARGETS, or
# targets.bzl.

if [ $# -ne 2 ]; then
echo "Usage: $0 dir1 dir2" >&2
exit 1
fi
dir1="$1"
dir2="$2"

if [ ! -d "$dir1" ] || [ ! -d "$dir2" ]; then
echo "Error: Both directories must exist" >&2
exit 1
fi

exit_status=0
while IFS= read -r -d '' file; do
base=$(basename "$file")
case "$base" in
"BUCK"|"CMakeLists.txt"|"TARGETS"|"targets.bzl")
continue
;;
esac
# Construct the corresponding path in the second directory
file2="$dir2/${file#$dir1/}"
# Check if the corresponding file exists in the second directory
if [ ! -f "$file2" ]; then
echo "Error: File '$file' found in '$dir1' but not found in '$dir2'" >&2
exit 1
fi
# Compare the contents of the two files using diff
set +ex
differences=$(diff -u -p "$file" "$file2")
set -e # leave x off
# If there are any differences, print an error message and exit with failure status
if [ -n "$differences" ]; then
echo "Error: Mismatch detected in file '$file':" >&2
echo "$differences" >&2
exit_status=1
fi
set -x
done < <(find "$dir1" -type f -print0)

exit $exit_status
27 changes: 27 additions & 0 deletions .github/workflows/check-c10-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: check-c10-sync

on:
pull_request:
paths:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add runtime/core/portable_type/c10 to this list

- .ci/docker/ci_commit_pins/pytorch.txt
- .ci/scripts/compare_dirs.sh
- runtime/core/portable_type/c10/**

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
cancel-in-progress: true

jobs:
check-c10-sync:
permissions:
id-token: write
contents: read
name: check-c10-sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Clone PyTorch
run: |
.ci/scripts/check_c10_sync.sh
Loading