From a711a675413f000e323031148e42a3baec2dcf27 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 15 Dec 2020 10:16:00 -0500 Subject: [PATCH 1/7] Check line break styles Running `dos2unix` and check if there are any changes to make sure that we don't include any files with DOS-style line breaks. --- .github/workflows/ci_tests.yaml | 9 ++++++++- .github/workflows/format-command.yml | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 7a0003c5985..fb87004b995 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -31,7 +31,9 @@ jobs: python-version: 3.8 - name: Install packages - run: pip install black blackdoc flake8 pylint + run: | + pip install black blackdoc flake8 pylint + sudo apt-get install dos2unix - name: Formatting check (black and flake8) run: make check @@ -39,6 +41,11 @@ jobs: - name: Linting (pylint) run: make lint + - name: Line breaks check (dos2unix) + run: | + find . -name "*.py" -exec dos2unix {} + + if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi + test: name: ${{ matrix.os }} - Python ${{ matrix.python-version }} runs-on: ${{ matrix.os }} diff --git a/.github/workflows/format-command.yml b/.github/workflows/format-command.yml index c0a320ec204..af54c1a6733 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -25,12 +25,15 @@ jobs: # Install formatting tools - name: Install formatting tools - run: pip install black blackdoc flake8 + run: | + pip install black blackdoc flake8 + sudo apt-get install dos2unix # Run "make format" and commit the change to the PR branch - name: Commit to the PR branch if any changes run: | make format + find . -name "*.py" -exec dos2unix {} + if [[ $(git ls-files -m) ]]; then git config --global user.name 'actions-bot' git config --global user.email '58130806+actions-bot@users.noreply.github.com' From 03d780d3a7b1351f3f18ab7924ef7ad2d7fd6a94 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 15 Dec 2020 15:42:25 -0500 Subject: [PATCH 2/7] Run dos2unix on all ASCII files --- .github/workflows/ci_tests.yaml | 2 +- .github/workflows/format-command.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index fb87004b995..b1721ba615b 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -43,7 +43,7 @@ jobs: - name: Line breaks check (dos2unix) run: | - find . -name "*.py" -exec dos2unix {} + + find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix {} \; if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi test: diff --git a/.github/workflows/format-command.yml b/.github/workflows/format-command.yml index af54c1a6733..1d3c9cb41ab 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -33,7 +33,7 @@ jobs: - name: Commit to the PR branch if any changes run: | make format - find . -name "*.py" -exec dos2unix {} + + find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix {} \; if [[ $(git ls-files -m) ]]; then git config --global user.name 'actions-bot' git config --global user.email '58130806+actions-bot@users.noreply.github.com' From 229edc82f17be082d44570b234275ecdee4ba608 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 15 Dec 2020 16:05:16 -0500 Subject: [PATCH 3/7] Update .github/workflows/ci_tests.yaml Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- .github/workflows/ci_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index b1721ba615b..0bed92434f5 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -43,7 +43,7 @@ jobs: - name: Line breaks check (dos2unix) run: | - find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix {} \; + find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix --quiet {} \; if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi test: From aa9564c9efac765476604053b35880bad5954f1a Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 15 Dec 2020 20:26:57 -0500 Subject: [PATCH 4/7] Change files mode to 644 --- .github/workflows/ci_tests.yaml | 1 + .github/workflows/format-command.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 0bed92434f5..054cac15d7d 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -44,6 +44,7 @@ jobs: - name: Line breaks check (dos2unix) run: | find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix --quiet {} \; + find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec chmod 644 {} \; if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi test: diff --git a/.github/workflows/format-command.yml b/.github/workflows/format-command.yml index 1d3c9cb41ab..d1618ce08f9 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -34,6 +34,7 @@ jobs: run: | make format find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix {} \; + find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec chmod 644 {} \; if [[ $(git ls-files -m) ]]; then git config --global user.name 'actions-bot' git config --global user.email '58130806+actions-bot@users.noreply.github.com' From 377ffb2c6d31a50c47a4f0f642272b3ce6dc0feb Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 15 Dec 2020 20:29:59 -0500 Subject: [PATCH 5/7] Update .github/workflows/ci_tests.yaml Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- .github/workflows/ci_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 054cac15d7d..68b6aa7abec 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -41,7 +41,7 @@ jobs: - name: Linting (pylint) run: make lint - - name: Line breaks check (dos2unix) + - name: Ensure files use UNIX line breaks and have 644 permission run: | find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix --quiet {} \; find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec chmod 644 {} \; From 1dfc9aedeaa82f754c41050ea48fb3fbf70c8061 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Tue, 15 Dec 2020 20:44:09 -0500 Subject: [PATCH 6/7] Improve contributing guide --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6ebc260e97..42ff271fd16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -255,6 +255,9 @@ Before committing, run it to automatically format your code: make format ``` +We also consistently use UNIX-style line endings (`\n`) and file permission +644 (`-rw-r--r--`) throughout the whole project. + Don't worry if you forget to do it. Our continuous integration systems will warn us and you can make a new commit with the formatted code. Even better, you can just write `/format` in the first line of any comment in a From eeeb42af3c0a33e7e7b60686206c3942f734b560 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 16 Dec 2020 04:58:11 -0500 Subject: [PATCH 7/7] Update CONTRIBUTING.md Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42ff271fd16..6ba63225274 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -255,9 +255,8 @@ Before committing, run it to automatically format your code: make format ``` -We also consistently use UNIX-style line endings (`\n`) and file permission +For consistency, we also use UNIX-style line endings (`\n`) and file permission 644 (`-rw-r--r--`) throughout the whole project. - Don't worry if you forget to do it. Our continuous integration systems will warn us and you can make a new commit with the formatted code. Even better, you can just write `/format` in the first line of any comment in a