Skip to content

Commit f8cc5e9

Browse files
committed
Create lintrunner-mypy so main lintrunner job doesn't have to build
lintrunner is required to land, but it takes 10-15 minutes. Can we cut that down if we split out MYPY? ghstack-source-id: 00a3261 ghstack-comment-id: 3282934023 Pull-Request: #14240
1 parent b23f883 commit f8cc5e9

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

.github/workflows/lint.yml

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
lintrunner:
18+
lintrunner-mypy:
1919
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
2020
permissions:
2121
id-token: write
@@ -45,14 +45,57 @@ jobs:
4545
cp -r "${CACHE_DIRECTORY}" . || true
4646
fi
4747
48-
# This has already been cached in the docker image
49-
lintrunner init
48+
RC=0
49+
# Run lintrunner on all files
50+
if ! lintrunner --force-color --all-files --take MYPY --tee-json=lint.json 2> /dev/null; then
51+
echo ""
52+
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner --take MYPY\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
53+
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
54+
RC=1
55+
fi
56+
57+
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
58+
jq --raw-output \
59+
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
60+
lint.json || true
61+
62+
exit $RC
63+
64+
lintrunner:
65+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
66+
permissions:
67+
id-token: write
68+
contents: read
69+
with:
70+
runner: linux.2xlarge
71+
docker-image: ci-image:executorch-ubuntu-22.04-linter
72+
submodules: 'recursive'
73+
fetch-depth: 0
74+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
75+
timeout: 90
76+
script: |
77+
# The generic Linux job chooses to use base env, not the one setup by the image
78+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
79+
conda activate "${CONDA_ENV}"
80+
81+
# Not sure why this isn't set up in the docker
82+
# image. lintrunner-mypy seems to work becaus setup-linux.sh
83+
# does this as part of install_executorch.
84+
pip install -r requirements-dev.txt
85+
86+
CACHE_DIRECTORY="/tmp/.lintbin"
87+
# Try to recover the cached binaries
88+
if [[ -d "${CACHE_DIRECTORY}" ]]; then
89+
# It's ok to fail this as lintrunner init would download these binaries
90+
# again if they do not exist
91+
cp -r "${CACHE_DIRECTORY}" . || true
92+
fi
5093
5194
RC=0
5295
# Run lintrunner on all files
53-
if ! lintrunner --force-color --all-files --tee-json=lint.json 2> /dev/null; then
96+
if ! lintrunner --force-color --all-files --skip MYPY --tee-json=lint.json 2> /dev/null; then
5497
echo ""
55-
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
98+
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner --skip MYPY\`. (If you don't get the same results, run \'lintrunner init\' to update your local linter)\e[0m"
5699
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
57100
RC=1
58101
fi

0 commit comments

Comments
 (0)