Skip to content

Commit

Permalink
fix(CI): account for weird LF configuration bug in GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bliutech committed Nov 6, 2023
1 parent 24c3d41 commit 138b13b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# 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
- name: Install dependencies.
run: sudo apt-get install -y clang-format
- name: Lint
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 138b13b

Please sign in to comment.