Remove fetch-depth: 0 by running git fetch instead (#30953)

This commit is contained in:
Kevin Heis 2022-09-20 13:04:08 -07:00 коммит произвёл GitHub
Родитель 3d45346c34
Коммит 2e0f7a1133
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 28 добавлений и 14 удалений

25
.github/workflows/link-check-all.yml поставляемый
Просмотреть файл

@ -28,9 +28,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
# Get the branches so merge_group can make the comparison with git diff
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
@ -41,38 +38,46 @@ jobs:
- name: Install
run: npm ci
# Creates file "${{ env.HOME }}/files.json", among others
- name: Gather files changed
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
HEAD: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
run: |
# Find the file diff in the pull request or merge group
# If its a pull request, use the faster call to the GitHub API
# For push, workflow_dispatch, and merge_group, use git diff
if [ -n "$PR" ]
then
echo __ running gh pr diff __
DIFF=`gh pr diff $PR --name-only`
elif [ -n "$HEAD" ]
then
echo __ running git fetch main __
git fetch origin main --depth 1
echo __ running git diff __
DIFF=`git diff --name-only origin/main`
else
echo __ no head, empty diff __
DIFF=''
fi
# So we can inspect the output
echo __ DIFF found __
echo $DIFF
# Formats into single line JSON array, removing any empty strings
echo $DIFF | tr ' ' '\n' | jq --raw-input | jq --slurp --compact-output 'map(select(length > 0))' > $HOME/files.json
# For verification
- name: Show files changed
run: cat $HOME/files.json
echo __ format, write to files.json __
echo $DIFF | \
tr ' ' '\n' | \
jq --raw-input | \
jq --slurp --compact-output 'map(select(length > 0))' \
> $HOME/files.json
- name: Link check (warnings, changed files)
env:
# Don't care about CDN caching image URLs
DISABLE_REWRITE_ASSET_URLS: true
run: |
# Note as of Aug 2022, we *don't* check external links
# on the pages you touched in the PR. We could enable that
# but it has the added risk of false positives blocking CI.

17
.github/workflows/test.yml поставляемый
Просмотреть файл

@ -36,7 +36,6 @@ jobs:
strategy:
fail-fast: false
matrix:
# The same array lives in test-windows.yml, so make any updates there too.
test-group:
[
content,
@ -73,9 +72,9 @@ jobs:
# only for the test groups that we know need the files.
lfs: ${{ matrix.test-group == 'content' }}
# Enables cloning the Early Access repo later with the relevant PAT
persist-credentials: 'false'
# Get the branches so merge_group can make the comparison with git diff
fetch-depth: 0
# persist-credentials: 'false'
# ->> Do we really need this? actions/checkout doesn't use it for the nested example:
# https://github.com/actions/checkout#checkout-multiple-repos-nested
- name: Figure out which docs-early-access branch to checkout, if internal repo
if: ${{ github.repository == 'github/docs-internal' }}
@ -135,21 +134,31 @@ jobs:
PR: ${{ github.event.pull_request.number }}
HEAD: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
run: |
# Find the file diff in the pull request or merge group
# If its a pull request, use the faster call to the GitHub API
# For push, workflow_dispatch, and merge_group, use git diff
if [ -n "$PR" ]
then
echo __ running gh pr diff __
DIFF=`gh pr diff $PR --name-only`
elif [ -n "$HEAD" ]
then
echo __ running git fetch main __
git fetch origin main --depth 1
echo __ running git diff __
DIFF=`git diff --name-only origin/main`
else
echo __ no head, empty diff __
DIFF=''
fi
# So we can inspect the output
echo __ DIFF found __
echo $DIFF
# So that becomes a string like `foo.js path/bar.md`
# Must to do this because the list of files can be HUGE. Especially
# in a repo-sync when there are lots of translation files involved.
echo __ format, write to get_diff_files.txt __
echo $DIFF | tr '\n' ' ' > get_diff_files.txt
- name: Setup node