mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add CI workflow to check line endings of all source files (#2082)
In addition, all found errors (formatting & line ending) have been fixed in this PR.
This commit is contained in:
parent
4199a01b96
commit
f191de2514
17 changed files with 959 additions and 934 deletions
13
.github/workflows/check-formatting.yml
vendored
13
.github/workflows/check-formatting.yml
vendored
|
@ -8,18 +8,19 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
container:
|
|
||||||
image: ubuntu:19.10
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.3.3
|
- uses: actions/checkout@v2.3.3
|
||||||
- name: apt-get update
|
- name: apt-get update
|
||||||
run: apt-get update
|
run: sudo apt-get update
|
||||||
|
|
||||||
- name: Install clang-format
|
- name: Install clang-format
|
||||||
run: apt-get -y install clang-format
|
run: sudo apt-get -y install clang-format dos2unix
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: ./tools/check-format.sh
|
run: ./tools/check-format.sh
|
||||||
|
|
||||||
|
- name: Check line-endings
|
||||||
|
run: ./tools/check-line-endings.sh
|
||||||
|
|
|
@ -41,7 +41,7 @@ git submodule update --init --recursive
|
||||||
The code is formatted using clang format in Qt Creator. [.clang-format](src/.clang-format) contains the style file for clang format.
|
The code is formatted using clang format in Qt Creator. [.clang-format](src/.clang-format) contains the style file for clang format.
|
||||||
|
|
||||||
### Get it automated with QT Creator + Beautifier + Clang Format
|
### Get it automated with QT Creator + Beautifier + Clang Format
|
||||||
1. Download LLVM: https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe
|
1. Download LLVM: https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/LLVM-11.0.0-win64.exe
|
||||||
2. During the installation, make sure to add it to your path
|
2. During the installation, make sure to add it to your path
|
||||||
3. In QT Creator, select `Help` > `About Plugins` > `C++` > `Beautifier` to enable the plugin
|
3. In QT Creator, select `Help` > `About Plugins` > `C++` > `Beautifier` to enable the plugin
|
||||||
4. Restart QT Creator
|
4. Restart QT Creator
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "IrcMessageHandler.hpp"
|
#include "IrcMessageHandler.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/Aliases.hpp"
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Outcome.hpp"
|
#include "common/Outcome.hpp"
|
||||||
|
|
|
@ -4,12 +4,14 @@ set -eu
|
||||||
|
|
||||||
fail="0"
|
fail="0"
|
||||||
|
|
||||||
|
clang-format --version
|
||||||
|
|
||||||
while read -r file; do
|
while read -r file; do
|
||||||
if ! diff -u <(cat "$file") <(clang-format "$file"); then
|
if ! diff -u <(cat "$file") <(clang-format "$file"); then
|
||||||
echo "$file differs!!!!!!!"
|
echo "$file differs!!!!!!!"
|
||||||
fail="1"
|
fail="1"
|
||||||
fi
|
fi
|
||||||
done < <(find src/ \( -iname "*.hpp" -o -iname "*.cpp" \))
|
done < <(find src/ -type f \( -iname "*.hpp" -o -iname "*.cpp" \))
|
||||||
|
|
||||||
if [ "$fail" = "1" ]; then
|
if [ "$fail" = "1" ]; then
|
||||||
echo "At least one file is poorly formatted - check the output above"
|
echo "At least one file is poorly formatted - check the output above"
|
||||||
|
|
22
tools/check-line-endings.sh
Executable file
22
tools/check-line-endings.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
fail="0"
|
||||||
|
|
||||||
|
dos2unix --version
|
||||||
|
|
||||||
|
while read -r file; do
|
||||||
|
num_dos_line_endings=$(dos2unix -id "$file" | awk '/[0-9]+/{print $(NF-1)}')
|
||||||
|
if [ "$num_dos_line_endings" -gt "0" ]; then
|
||||||
|
>&2 echo "File '$file' contains $num_dos_line_endings DOS line-endings, it should only be using unix line-endings!"
|
||||||
|
fail="1"
|
||||||
|
fi
|
||||||
|
done < <(find src/ -type f \( -iname "*.hpp" -o -iname "*.cpp" \))
|
||||||
|
|
||||||
|
if [ "$fail" = "1" ]; then
|
||||||
|
>&2 echo "At least one file is not using unix line-endings - check the output above"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
>&2 echo "Every file seems to be using unix line-endings. Good job!"
|
Loading…
Reference in a new issue