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
140 changes: 82 additions & 58 deletions .github/workflows/_link_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,100 @@ on:
jobs:
lint-urls:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-url-lint') }}
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-linter
submodules: false
fetch-depth: 0
ref: ${{ inputs.ref }}
timeout: 120
script: |
./scripts/lint_urls.sh $(
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Fetch base ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
git fetch --no-tags --depth=1 origin "${{ github.event.before }}"
fi
) || {
echo
echo "URL lint failed."
echo "If this is a transient outage, you can bypass it by adding the \`skip-url-lint\` label to your PR."
echo "Or add \`@lint-ignore\` somewhere on the same line as the URL you want to skip checking."
exit 1
}
- name: Lint URLs
run: |
./scripts/lint_urls.sh $(
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
fi
) || {
echo
echo "URL lint failed."
echo "If this is a transient outage, you can bypass it by adding the \`skip-url-lint\` label to your PR."
echo "Or add \`@lint-ignore\` somewhere on the same line as the URL you want to skip checking."
exit 1
}

lint-xrefs:
if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-xref-lint') }}
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-linter
submodules: false
fetch-depth: 0
ref: ${{ inputs.ref }}
timeout: 60
script: |
./scripts/lint_xrefs.sh $(
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Fetch base ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
git fetch --no-tags --depth=1 origin "${{ github.event.before }}"
fi
) || {
echo
echo "Xref lint failed."
echo "If this is a transient outage, you can bypass it by adding the \`skip-xref-lint\` label to your PR."
echo "Or add \`@lint-ignore\` somewhere on the same line as the reference you want to skip checking."
exit 1
}
- name: Lint cross-references
run: |
./scripts/lint_xrefs.sh $(
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
fi
) || {
echo
echo "Xref lint failed."
echo "If this is a transient outage, you can bypass it by adding the \`skip-xref-lint\` label to your PR."
echo "Or add \`@lint-ignore\` somewhere on the same line as the reference you want to skip checking."
exit 1
}

lint-file-size:
if: ${{ github.event_name == 'pull_request' }}
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
with:
runner: linux.2xlarge
docker-image: ci-image:executorch-ubuntu-22.04-linter
submodules: false
fetch-depth: 0
ref: ${{ inputs.ref }}
timeout: 30
script: |
chmod +x ./scripts/lint_file_size.sh
./scripts/lint_file_size.sh $(
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Fetch base ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
git fetch --no-tags --depth=1 origin "${{ github.event.before }}"
fi
) || {
echo
echo "File size lint failed: some files exceed the 1 MB limit."
echo "If you really need large files, consider using Git LFS or storing them elsewhere."
echo "If you really need to get unblocked and check in the file, can add it to the EXCEPTIONS list in scripts/lint_file_size.sh."
exit 1
}
- name: Lint file sizes
run: |
chmod +x ./scripts/lint_file_size.sh
./scripts/lint_file_size.sh $(
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}"
else
echo "${{ github.event.before }}" "${{ github.sha }}"
fi
) || {
echo
echo "File size lint failed: some files exceed the 1 MB limit."
echo "If you really need large files, consider using Git LFS or storing them elsewhere."
echo "If you really need to get unblocked and check in the file, can add it to the EXCEPTIONS list in scripts/lint_file_size.sh."
exit 1
}
4 changes: 2 additions & 2 deletions scripts/lint_file_size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ is_exception() {
if [ $# -eq 2 ]; then
base=$1
head=$2
echo "Checking changed files between $base...$head"
files=$(git diff --name-only "$base...$head")
echo "Checking changed files between $base..$head"
files=$(git diff --name-only "$base..$head")
else
echo "Checking all files in repository"
files=$(git ls-files)
Expand Down
4 changes: 2 additions & 2 deletions scripts/lint_urls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ done < <(
':(exclude,glob)**/third_party/**'
)
if [ $# -eq 2 ]; then
for filename in $(git diff --name-only --unified=0 "$1...$2"); do
git diff --unified=0 "$1...$2" -- "$filename" "${excludes[@]}" \
for filename in $(git diff --name-only --unified=0 "$1..$2"); do
git diff --unified=0 "$1..$2" -- "$filename" "${excludes[@]}" \
| grep -E '^\+' \
| grep -Ev '^\+\+\+' \
| perl -nle 'print for m#'"$pattern"'#g' \
Expand Down
4 changes: 2 additions & 2 deletions scripts/lint_xrefs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ done < <(
':(exclude,glob)**/third_party/**'
)
if [ $# -eq 2 ]; then
for filename in $(git diff --name-only --unified=0 "$1...$2"); do
git diff --unified=0 "$1...$2" -- "$filename" "${excludes[@]}" \
for filename in $(git diff --name-only --unified=0 "$1..$2"); do
git diff --unified=0 "$1..$2" -- "$filename" "${excludes[@]}" \
| grep -E '^\+' \
| grep -Ev '^\+\+\+' \
| perl -nle 'print for m#'"$pattern"'#g' \
Expand Down
Loading