Skip to content

Commit

Permalink
fix(CI): account for weird LF configuration bug in GitHub Actions (#19)
Browse files Browse the repository at this point in the history
* fix(CI): account for weird LF configuration bug in GitHub Actions

* fix(CI): weird ordering issue

* fix(CI): regex bug

* fix(CI): actually send CRLF to grep
  • Loading branch information
bliutech authored Nov 6, 2023
1 parent 24c3d41 commit edb1e2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ on:
branches: [ "main" ]

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
# Fixes: https://github.com/actions/checkout/issues/135
- name: Set git to use LF.
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
- name: Install dependencies.
run: sudo apt-get install -y clang-format
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ dockerun:
$(QEMU) -drive format=raw,file=$(BUILD_DIR)/os_image

check:
# For some reason, GitHub Actions seems to add carriage returns?
# @grep -RE "\r" source/ && echo "Found carriage returns in source files. Please run 'make format' to fix them." && exit 1 || exit 0
find source/ -type f -name '*.c' -or -name '*.h' | xargs $(FORMAT) --dry-run --Werror
@grep -RE $$'\r' source/ && echo "Found carriage returns in source files. Please run 'make format' to fix them." && exit 1 || exit 0
@find source/ -type f -name '*.c' -or -name '*.h' | xargs $(FORMAT) --dry-run --Werror && echo "All files are formatted correctly." || echo "Some files are not formatted correctly. Please run 'make format' to fix them."

format:
find source -type f -name '*.c' -or -name '*.h' -or -name '*.asm' | xargs dos2unix
find source/ -type f -name '*.c' -or -name '*.h' | xargs $(FORMAT)
@find source -type f -name '*.c' -or -name '*.h' -or -name '*.asm' | xargs dos2unix > /dev/null 2>&1 && echo "Converted carriage returns to line feeds."
@find source/ -type f -name '*.c' -or -name '*.h' | xargs $(FORMAT) && echo "Formatted all files."

clean:
rm -rf $(BUILD_DIR)
Expand Down

0 comments on commit edb1e2f

Please sign in to comment.