Skip to content

Commit 126e56a

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: fe28042 ghstack-comment-id: 3282934023 Pull-Request: #14240
1 parent b23f883 commit 126e56a

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

.github/workflows/lint.yml

Lines changed: 52 additions & 3 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
@@ -50,9 +50,58 @@ jobs:
5050
5151
RC=0
5252
# Run lintrunner on all files
53-
if ! lintrunner --force-color --all-files --tee-json=lint.json 2> /dev/null; then
53+
if ! lintrunner --force-color --all-files --take MYPY --tee-json=lint.json 2> /dev/null; then
54+
echo ""
55+
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"
56+
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
57+
RC=1
58+
fi
59+
60+
# Use jq to massage the JSON lint output into GitHub Actions workflow commands.
61+
jq --raw-output \
62+
'"::\(if .severity == "advice" or .severity == "disabled" then "warning" else .severity end) file=\(.path),line=\(.line),col=\(.char),title=\(.code) \(.name)::" + (.description | gsub("\\n"; "%0A"))' \
63+
lint.json || true
64+
65+
exit $RC
66+
67+
lintrunner:
68+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
69+
permissions:
70+
id-token: write
71+
contents: read
72+
with:
73+
runner: linux.2xlarge
74+
docker-image: ci-image:executorch-ubuntu-22.04-linter
75+
submodules: 'recursive'
76+
fetch-depth: 0
77+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
78+
timeout: 90
79+
script: |
80+
# The generic Linux job chooses to use base env, not the one setup by the image
81+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
82+
conda activate "${CONDA_ENV}"
83+
84+
# Not sure why this isn't set up in the docker
85+
# image. lintrunner-mypy seems to work becaus setup-linux.sh
86+
# does this as part of install_executorch.
87+
pip install -r requirements-dev.txt
88+
89+
CACHE_DIRECTORY="/tmp/.lintbin"
90+
# Try to recover the cached binaries
91+
if [[ -d "${CACHE_DIRECTORY}" ]]; then
92+
# It's ok to fail this as lintrunner init would download these binaries
93+
# again if they do not exist
94+
cp -r "${CACHE_DIRECTORY}" . || true
95+
fi
96+
97+
# This has already been cached in the docker image
98+
lintrunner init
99+
100+
RC=0
101+
# Run lintrunner on all files
102+
if ! lintrunner --force-color --all-files --skip MYPY --tee-json=lint.json 2> /dev/null; then
54103
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"
104+
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"
56105
echo -e "\e[1m\e[36mSee https://github.com/pytorch/pytorch/wiki/lintrunner for setup instructions.\e[0m"
57106
RC=1
58107
fi

0 commit comments

Comments
 (0)