forked from ros/rosdistro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup CI to explicitly fetch upstream not just use master which may b…
…e out of date on forks. Fixes ros#24377 Signed-off-by: Tully Foote <[email protected]>
- Loading branch information
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,10 @@ jobs: | |
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Fetch master (to enable diff) | ||
- name: Fetch upstream (to enable diff) | ||
run: | | ||
git fetch --no-tags --depth=1 origin master | ||
git remote add unittest_upstream_comparision [email protected]:ros/rosdistro.git || git remote set-url unittest_upstream_comparision [email protected]:ros/rosdistro.git | ||
git fetch --no-tags --depth=1 unittest_upstream_comparision master | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip setuptools wheel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ | |
# for commented debugging code below | ||
# import pprint | ||
|
||
DIFF_TARGET = 'origin/master' | ||
UPSTREAM_NAME = 'unittest_upstream_comparision' | ||
DIFF_BRANCH = 'master' | ||
DIFF_REPO = '[email protected]:ros/rosdistro.git' | ||
|
||
|
||
TARGET_FILE_BLACKLIST = [] | ||
|
@@ -277,14 +279,36 @@ def isolate_yaml_snippets_from_line_numbers(yaml_dict, line_numbers): | |
|
||
|
||
def main(): | ||
cmd = ('git diff --unified=0 %s' % DIFF_TARGET).split() | ||
diff = subprocess.check_output(cmd).decode('utf-8') | ||
detected_errors = [] | ||
|
||
# See if UPSTREAM_NAME remote is available and use it as it's expected to be setup by CI | ||
# Otherwise fall back to origin/master | ||
try: | ||
cmd = ('git config --get remote.%s.url' % UPSTREAM_NAME).split() | ||
try: | ||
remote_url = subprocess.check_output(cmd).decode('utf-8').strip() | ||
# Remote exists | ||
# Check url | ||
if remote_url != DIFF_REPO: | ||
detected_errors.append('%s remote url [%s] is different than %s' % (UPSTREAM_NAME, remote_url, DIFF_REPO)) | ||
return detected_errors | ||
|
||
target_branch = '%s/%s' % (UPSTREAM_NAME, DIFF_BRANCH) | ||
except subprocess.CalledProcessError: | ||
# No remote so fall back to origin/master | ||
print('WARNING: No remote %s detected, falling back to origin master. Make sure it is up to date.' % UPSTREAM_NAME) | ||
target_branch = 'origin/master' | ||
|
||
cmd = ('git diff --unified=0 %s' % target_branch).split() | ||
diff = subprocess.check_output(cmd).decode('utf-8') | ||
except subprocess.CalledProcessError as ex: | ||
detected_errors.append('%s' % ex) | ||
return detected_errors | ||
# print("output", diff) | ||
|
||
diffed_lines = detect_lines(diff) | ||
# print("Diff lines %s" % diffed_lines) | ||
|
||
detected_errors = [] | ||
|
||
for path, lines in diffed_lines.items(): | ||
directory = os.path.join(os.path.dirname(__file__), '..') | ||
|