Skip to content

Commit d5620fa

Browse files
d4l3kfacebook-github-bot
authored andcommitted
scripts/lint.sh: run the linters (#9)
Summary: There was a bug in the lint.sh script such that the linters weren't actually being run. `set -e <cmd>` just silently ignores the `<cmd>` part. Instead we should use `set -e` at the top of the file and call the linters normally. It also adds GITHUB_TOKEN support so the linter script can actually checkout upstream to do a diff. Pull Request resolved: #9 Test Plan: CI and modify random .py file with import and whitespace changes ``` scripts/lint.sh ``` Reviewed By: tierex Differential Revision: D28657047 Pulled By: d4l3k fbshipit-source-id: ea5f5bc1693bff3b7e0f2bc2eba9816f97035532
1 parent 37cad8a commit d5620fa

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ jobs:
2323
pip install isort
2424
pip install black
2525
- name: Run Lint
26-
run: scripts/lint.sh
26+
run: |
27+
git config --global url."https://${{ secrets.GITHUB_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
28+
scripts/lint.sh

scripts/lint.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Copyright (c) Facebook, Inc. and its affiliates.
33
# All rights reserved.
44
#
55
# This source code is licensed under the BSD-style license found in the
66
# LICENSE file in the root directory of this source tree.
77

8+
set -e
9+
810
if [ ! "$(black --version)" ]
911
then
1012
echo "Please install black."
@@ -19,10 +21,10 @@ fi
1921
# cd to the project directory
2022
cd "$(dirname "$0")/.." || exit 1
2123

22-
GIT_URL_1="git@github.com:pytorch/torchx.git"
24+
GIT_URL_1="https://github.com/pytorch/torchx.git"
2325
GIT_URL_2="[email protected]:pytorch/torchx.git"
2426

25-
UPSTREAM_URL="$(git config remote.upstream.url)"
27+
UPSTREAM_URL="$(git config remote.upstream.url)" || true
2628

2729
if [ -z "$UPSTREAM_URL" ]
2830
then
@@ -36,10 +38,8 @@ then
3638
exit 1
3739
fi
3840

39-
# fetch upstream
4041
git fetch upstream
4142

42-
4343
CHANGED_FILES="$(git diff --diff-filter=ACMRT --name-only upstream/master | grep '\.py$' | tr '\n' ' ')"
4444

4545
if [ "$CHANGED_FILES" != "" ]
@@ -50,10 +50,9 @@ then
5050
for file in $CHANGED_FILES
5151
do
5252
echo "Checking $file"
53-
set -e isort "$file" --recursive --multi-line 3 --trailing-comma --force-grid-wrap 0 \
53+
isort "$file" --recursive --multi-line 3 --trailing-comma --force-grid-wrap 0 \
5454
--line-width 88 --lines-after-imports 2 --combine-as --section-default THIRDPARTY
55-
56-
set -e black "$file"
55+
black "$file"
5756
done
5857
else
5958
echo "No changes made to any Python files. Nothing to do."

0 commit comments

Comments
 (0)