Skip to content

Commit fe72215

Browse files
committed
Update formatting script and use GitHub Actions
1 parent 5337227 commit fe72215

File tree

5 files changed

+43
-23
lines changed

5 files changed

+43
-23
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Normalize EOL for all files that Git considers text files.
2+
* text=auto eol=lf

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/static_checks.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 📊 Static Checks
2+
on: [push, pull_request]
3+
4+
jobs:
5+
format:
6+
name: File formatting (file_format.sh)
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
12+
- name: Install dependencies
13+
run: |
14+
sudo apt-get update -qq
15+
sudo apt-get install -qq dos2unix recode
16+
17+
- name: File formatting checks (file_format.sh)
18+
run: |
19+
bash ./file_format.sh

appveyor.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ configuration: Release
1010
environment:
1111
APPVEYOR_YML_DISABLE_PS_LINUX: true
1212

13-
install:
14-
- sh: |
15-
if [ "$(uname)" != "Darwin" ]; then
16-
sudo apt-get update -y
17-
sudo apt-get install -y dos2unix recode
18-
fi
19-
2013
build_script:
2114
- ps: |
2215
New-Item -Path . -Name "build" -ItemType "directory"
@@ -33,12 +26,6 @@ build_script:
3326
cmake --build . --config ${CONFIGURATION}
3427
cd ../
3528
36-
test_script:
37-
- sh: |
38-
if [ "$(uname)" != "Darwin" ]; then
39-
bash ./format.sh
40-
fi
41-
4229
artifacts:
4330
# Linux
4431
- path: bin/basisu

format.sh renamed to file_format.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
3+
# This script ensures proper POSIX text file formatting and a few other things.
4+
5+
set -uo pipefail
6+
IFS=$'\n\t'
27

38
# Loops through all text files tracked by Git.
49
git grep -zIl '' |
@@ -15,18 +20,19 @@ while IFS= read -rd '' f; do
1520
elif [[ $f == *"min.js" ]]; then
1621
continue
1722
fi
18-
# Ensures that files are UTF-8 formatted.
19-
recode UTF-8 $f 2> /dev/null
20-
# Ensures that files have LF line endings.
21-
dos2unix $f 2> /dev/null
22-
# Ensures that files do not contain a BOM.
23-
sed -i '1s/^\xEF\xBB\xBF//' "$f"
24-
# Ensures that files end with newline characters.
25-
tail -c1 < "$f" | read -r _ || echo >> "$f";
23+
# Ensure that files are UTF-8 formatted.
24+
recode UTF-8 "$f" 2> /dev/null
25+
# Ensure that files have LF line endings and do not contain a BOM.
26+
dos2unix "$f" 2> /dev/null
27+
# Remove trailing space characters and ensures that files end
28+
# with newline characters. -l option handles newlines conveniently.
29+
perl -i -ple 's/\s*$//g' "$f"
30+
# Remove the character sequence "== true" if it has a leading space.
31+
perl -i -pe 's/\x20== true//g' "$f"
2632
done
2733

2834
git diff > patch.patch
29-
FILESIZE=$(stat -c%s patch.patch)
35+
FILESIZE="$(stat -c%s patch.patch)"
3036
MAXSIZE=5
3137

3238
# If no patch has been generated all is OK, clean up, and exit.

0 commit comments

Comments
 (0)