Skip to content
Closed
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
4 changes: 3 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ jobs:
pip install isort
pip install black
- name: Run Lint
run: scripts/lint.sh
run: |
git config --global url."https://${{ secrets.GITHUB_TOKEN }}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
scripts/lint.sh
15 changes: 7 additions & 8 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/sh
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -e

if [ ! "$(black --version)" ]
then
echo "Please install black."
Expand All @@ -19,10 +21,10 @@ fi
# cd to the project directory
cd "$(dirname "$0")/.." || exit 1

GIT_URL_1="git@github.com:pytorch/torchx.git"
GIT_URL_1="https://github.com/pytorch/torchx.git"
GIT_URL_2="git@github.com:pytorch/torchx.git"

UPSTREAM_URL="$(git config remote.upstream.url)"
UPSTREAM_URL="$(git config remote.upstream.url)" || true

if [ -z "$UPSTREAM_URL" ]
then
Expand All @@ -36,10 +38,8 @@ then
exit 1
fi

# fetch upstream
git fetch upstream


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

if [ "$CHANGED_FILES" != "" ]
Expand All @@ -50,10 +50,9 @@ then
for file in $CHANGED_FILES
do
echo "Checking $file"
set -e isort "$file" --recursive --multi-line 3 --trailing-comma --force-grid-wrap 0 \
isort "$file" --recursive --multi-line 3 --trailing-comma --force-grid-wrap 0 \
--line-width 88 --lines-after-imports 2 --combine-as --section-default THIRDPARTY

set -e black "$file"
black "$file"
done
else
echo "No changes made to any Python files. Nothing to do."
Expand Down