Skip to content

Commit 640ed90

Browse files
seismanweiji14
andauthored
Check files for UNIX-style line breaks and 644 permission (#736)
* 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. * Run dos2unix on all ASCII files * Change files mode to 644 * Improve contributing guide Co-authored-by: Wei Ji <[email protected]>
1 parent e269abf commit 640ed90

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.github/workflows/ci_tests.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,22 @@ jobs:
3131
python-version: 3.8
3232

3333
- name: Install packages
34-
run: pip install black blackdoc flake8 pylint
34+
run: |
35+
pip install black blackdoc flake8 pylint
36+
sudo apt-get install dos2unix
3537
3638
- name: Formatting check (black and flake8)
3739
run: make check
3840

3941
- name: Linting (pylint)
4042
run: make lint
4143

44+
- name: Ensure files use UNIX line breaks and have 644 permission
45+
run: |
46+
find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix --quiet {} \;
47+
find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec chmod 644 {} \;
48+
if [[ $(git ls-files -m) ]]; then git --no-pager diff HEAD; exit 1; fi
49+
4250
test:
4351
name: ${{ matrix.os }} - Python ${{ matrix.python-version }}
4452
runs-on: ${{ matrix.os }}

.github/workflows/format-command.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ jobs:
2525

2626
# Install formatting tools
2727
- name: Install formatting tools
28-
run: pip install black blackdoc flake8
28+
run: |
29+
pip install black blackdoc flake8
30+
sudo apt-get install dos2unix
2931
3032
# Run "make format" and commit the change to the PR branch
3133
- name: Commit to the PR branch if any changes
3234
run: |
3335
make format
36+
find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec dos2unix {} \;
37+
find . -type f -not -path '*/\.git/*' -exec grep -Iq . {} \; -exec chmod 644 {} \;
3438
if [[ $(git ls-files -m) ]]; then
3539
git config --global user.name 'actions-bot'
3640
git config --global user.email '[email protected]'

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ Before committing, run it to automatically format your code:
255255
make format
256256
```
257257

258+
For consistency, we also use UNIX-style line endings (`\n`) and file permission
259+
644 (`-rw-r--r--`) throughout the whole project.
258260
Don't worry if you forget to do it. Our continuous integration systems will
259261
warn us and you can make a new commit with the formatted code.
260262
Even better, you can just write `/format` in the first line of any comment in a

0 commit comments

Comments
 (0)