Skip to content

Commit

Permalink
Update formatting script and use GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Dec 19, 2021
1 parent 4e0c016 commit 1aff277
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
19 changes: 19 additions & 0 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 📊 Static Checks
on: [push, pull_request]

jobs:
format:
name: File formatting (file_format.sh)
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq dos2unix recode
- name: File formatting checks (file_format.sh)
run: |
bash ./file_format.sh
13 changes: 0 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ configuration: Release
environment:
APPVEYOR_YML_DISABLE_PS_LINUX: true

install:
- sh: |
if [ "$(uname)" != "Darwin" ]; then
sudo apt-get update -y
sudo apt-get install -y dos2unix recode
fi
build_script:
- ps: |
New-Item -Path . -Name "build" -ItemType "directory"
Expand All @@ -33,12 +26,6 @@ build_script:
cmake --build . --config ${CONFIGURATION}
cd ../
test_script:
- sh: |
if [ "$(uname)" != "Darwin" ]; then
bash ./format.sh
fi
artifacts:
# Linux
- path: bin/basisu
Expand Down
26 changes: 16 additions & 10 deletions format.sh → file_format.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash

# This script ensures proper POSIX text file formatting and a few other things.

set -uo pipefail
IFS=$'\n\t'

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

git diff > patch.patch
FILESIZE=$(stat -c%s patch.patch)
FILESIZE="$(stat -c%s patch.patch)"
MAXSIZE=5

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

0 comments on commit 1aff277

Please sign in to comment.