|
8 | 8 | jobs: |
9 | 9 | lint-urls: |
10 | 10 | if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-url-lint') }} |
11 | | - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main |
12 | | - with: |
13 | | - runner: linux.2xlarge |
14 | | - docker-image: ci-image:executorch-ubuntu-22.04-linter |
15 | | - submodules: false |
16 | | - fetch-depth: 0 |
17 | | - ref: ${{ inputs.ref }} |
18 | | - timeout: 120 |
19 | | - script: | |
20 | | - ./scripts/lint_urls.sh $( |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + timeout-minutes: 120 |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + ref: ${{ inputs.ref }} |
| 19 | + - name: Fetch base ref |
| 20 | + run: | |
21 | 21 | if [ "${{ github.event_name }}" = "pull_request" ]; then |
22 | | - echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" |
| 22 | + git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}" |
23 | 23 | else |
24 | | - echo "${{ github.event.before }}" "${{ github.sha }}" |
| 24 | + git fetch --no-tags --depth=1 origin "${{ github.event.before }}" |
25 | 25 | fi |
26 | | - ) || { |
27 | | - echo |
28 | | - echo "URL lint failed." |
29 | | - echo "If this is a transient outage, you can bypass it by adding the \`skip-url-lint\` label to your PR." |
30 | | - echo "Or add \`@lint-ignore\` somewhere on the same line as the URL you want to skip checking." |
31 | | - exit 1 |
32 | | - } |
| 26 | + - name: Lint URLs |
| 27 | + run: | |
| 28 | + ./scripts/lint_urls.sh $( |
| 29 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 30 | + echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" |
| 31 | + else |
| 32 | + echo "${{ github.event.before }}" "${{ github.sha }}" |
| 33 | + fi |
| 34 | + ) || { |
| 35 | + echo |
| 36 | + echo "URL lint failed." |
| 37 | + echo "If this is a transient outage, you can bypass it by adding the \`skip-url-lint\` label to your PR." |
| 38 | + echo "Or add \`@lint-ignore\` somewhere on the same line as the URL you want to skip checking." |
| 39 | + exit 1 |
| 40 | + } |
33 | 41 |
|
34 | 42 | lint-xrefs: |
35 | 43 | if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-xref-lint') }} |
36 | | - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main |
37 | | - with: |
38 | | - runner: linux.2xlarge |
39 | | - docker-image: ci-image:executorch-ubuntu-22.04-linter |
40 | | - submodules: false |
41 | | - fetch-depth: 0 |
42 | | - ref: ${{ inputs.ref }} |
43 | | - timeout: 60 |
44 | | - script: | |
45 | | - ./scripts/lint_xrefs.sh $( |
| 44 | + runs-on: ubuntu-latest |
| 45 | + permissions: |
| 46 | + contents: read |
| 47 | + timeout-minutes: 60 |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + ref: ${{ inputs.ref }} |
| 52 | + - name: Fetch base ref |
| 53 | + run: | |
46 | 54 | if [ "${{ github.event_name }}" = "pull_request" ]; then |
47 | | - echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" |
| 55 | + git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}" |
48 | 56 | else |
49 | | - echo "${{ github.event.before }}" "${{ github.sha }}" |
| 57 | + git fetch --no-tags --depth=1 origin "${{ github.event.before }}" |
50 | 58 | fi |
51 | | - ) || { |
52 | | - echo |
53 | | - echo "Xref lint failed." |
54 | | - echo "If this is a transient outage, you can bypass it by adding the \`skip-xref-lint\` label to your PR." |
55 | | - echo "Or add \`@lint-ignore\` somewhere on the same line as the reference you want to skip checking." |
56 | | - exit 1 |
57 | | - } |
| 59 | + - name: Lint cross-references |
| 60 | + run: | |
| 61 | + ./scripts/lint_xrefs.sh $( |
| 62 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 63 | + echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" |
| 64 | + else |
| 65 | + echo "${{ github.event.before }}" "${{ github.sha }}" |
| 66 | + fi |
| 67 | + ) || { |
| 68 | + echo |
| 69 | + echo "Xref lint failed." |
| 70 | + echo "If this is a transient outage, you can bypass it by adding the \`skip-xref-lint\` label to your PR." |
| 71 | + echo "Or add \`@lint-ignore\` somewhere on the same line as the reference you want to skip checking." |
| 72 | + exit 1 |
| 73 | + } |
58 | 74 |
|
59 | 75 | lint-file-size: |
60 | 76 | if: ${{ github.event_name == 'pull_request' }} |
61 | | - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main |
62 | | - with: |
63 | | - runner: linux.2xlarge |
64 | | - docker-image: ci-image:executorch-ubuntu-22.04-linter |
65 | | - submodules: false |
66 | | - fetch-depth: 0 |
67 | | - ref: ${{ inputs.ref }} |
68 | | - timeout: 30 |
69 | | - script: | |
70 | | - chmod +x ./scripts/lint_file_size.sh |
71 | | - ./scripts/lint_file_size.sh $( |
| 77 | + runs-on: ubuntu-latest |
| 78 | + permissions: |
| 79 | + contents: read |
| 80 | + timeout-minutes: 30 |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@v4 |
| 83 | + with: |
| 84 | + ref: ${{ inputs.ref }} |
| 85 | + - name: Fetch base ref |
| 86 | + run: | |
72 | 87 | if [ "${{ github.event_name }}" = "pull_request" ]; then |
73 | | - echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" |
| 88 | + git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.sha }}" |
74 | 89 | else |
75 | | - echo "${{ github.event.before }}" "${{ github.sha }}" |
| 90 | + git fetch --no-tags --depth=1 origin "${{ github.event.before }}" |
76 | 91 | fi |
77 | | - ) || { |
78 | | - echo |
79 | | - echo "File size lint failed: some files exceed the 1 MB limit." |
80 | | - echo "If you really need large files, consider using Git LFS or storing them elsewhere." |
81 | | - 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." |
82 | | - exit 1 |
83 | | - } |
| 92 | + - name: Lint file sizes |
| 93 | + run: | |
| 94 | + chmod +x ./scripts/lint_file_size.sh |
| 95 | + ./scripts/lint_file_size.sh $( |
| 96 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 97 | + echo "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" |
| 98 | + else |
| 99 | + echo "${{ github.event.before }}" "${{ github.sha }}" |
| 100 | + fi |
| 101 | + ) || { |
| 102 | + echo |
| 103 | + echo "File size lint failed: some files exceed the 1 MB limit." |
| 104 | + echo "If you really need large files, consider using Git LFS or storing them elsewhere." |
| 105 | + 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." |
| 106 | + exit 1 |
| 107 | + } |
0 commit comments