From aed20a9b626928c5d8b146ba1652d8a97b967fd2 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 21 Jun 2021 14:14:41 +0000 Subject: [PATCH] ci: Fix get_changed_files_output (#5944) * ci: Fix get_changed_files_output * Update project_tests.yml * ci: Fix presubmit checks * ci: Use fetch-depth:0 instead of --unshallow --- .github/workflows/infra_tests.yml | 5 +++-- .github/workflows/presubmit.yml | 5 +++-- .github/workflows/project_tests.yml | 5 +++-- infra/ci/build.py | 2 +- infra/presubmit.py | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/infra_tests.yml b/.github/workflows/infra_tests.yml index 5273adc45..a93b15304 100644 --- a/.github/workflows/infra_tests.yml +++ b/.github/workflows/infra_tests.yml @@ -15,8 +15,9 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - - run: | # Needed for git diff to work. - git fetch origin master --depth 1 + with: # Needed for git diff to work. (get_changed_files) + fetch-depth: 0 + - run: | git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master - name: Setup python environment diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 9a4b8d698..1e80301ab 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -16,8 +16,9 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - - run: | # Needed for git diff to work. - git fetch origin master --depth 1 + with: # Needed for git diff to work. (get_changed_files) + fetch-depth: 0 + - run: | git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master - name: Setup python environment diff --git a/.github/workflows/project_tests.yml b/.github/workflows/project_tests.yml index 55dfb7f39..4d5e4f02a 100644 --- a/.github/workflows/project_tests.yml +++ b/.github/workflows/project_tests.yml @@ -48,8 +48,9 @@ jobs: access_token: ${{ github.token }} - uses: actions/checkout@v2 - - run: | # Needed for git diff to work. - git fetch origin master --depth 1 + with: # Needed for git diff to work. (get_changed_files) + fetch-depth: 0 + - run: | git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master - name: Clear unnecessary files diff --git a/infra/ci/build.py b/infra/ci/build.py index bf8dca86c..8de73636f 100755 --- a/infra/ci/build.py +++ b/infra/ci/build.py @@ -38,7 +38,7 @@ LANGUAGES_WITH_COVERAGE_SUPPORT = ['c', 'c++', 'go', 'jvm', 'rust'] def get_changed_files_output(): """Returns the output of a git command that discovers changed files.""" branch_commit_hash = subprocess.check_output( - ['git', 'merge-base', 'FETCH_HEAD', 'origin/HEAD']).strip().decode() + ['git', 'merge-base', 'HEAD', 'origin/HEAD']).strip().decode() return subprocess.check_output( ['git', 'diff', '--name-only', branch_commit_hash + '..']).decode() diff --git a/infra/presubmit.py b/infra/presubmit.py index cae02a082..41f74e605 100755 --- a/infra/presubmit.py +++ b/infra/presubmit.py @@ -346,7 +346,7 @@ def yapf(paths, validate=True): def get_changed_files(): """Return a list of absolute paths of files changed in this git branch.""" branch_commit_hash = subprocess.check_output( - ['git', 'merge-base', 'FETCH_HEAD', 'origin/HEAD']).strip().decode() + ['git', 'merge-base', 'HEAD', 'origin/HEAD']).strip().decode() diff_commands = [ # Return list of modified files in the commits on this branch.