diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 7a0003c5985..68b6aa7abec 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,12 @@ jobs: - name: Linting (pylint) run: make lint + - 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 {} \; + 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..d1618ce08f9 100644 --- a/.github/workflows/format-command.yml +++ b/.github/workflows/format-command.yml @@ -25,12 +25,16 @@ 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 . -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' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6ebc260e97..6ba63225274 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -255,6 +255,8 @@ Before committing, run it to automatically format your code: make format ``` +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