-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* scripts/stylize.sh: by default, checks if stylization is required. enforces the stylization by -f flag. * code-style ci test. must fail now since some files needs stylization. * minor fix for scripts/stylize.sh * returns error only when not enforced. * astyle option file * ran stylization * some manual edits.
- Loading branch information
1 parent
0edcb6f
commit 740f38b
Showing
14 changed files
with
326 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--max-code-length=80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,25 @@ on: | |
jobs: | ||
docker-image: | ||
uses: ./.github/workflows/docker.yml | ||
code-style: | ||
runs-on: ubuntu-latest | ||
needs: [docker-image] | ||
container: | ||
image: ghcr.io/llnl/librom/librom_env:latest | ||
options: --user 1001 --privileged | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Check out libROM | ||
uses: actions/checkout@v3 | ||
- name: Artistic Style version (for information) | ||
run: astyle --version | ||
- name: Check Stylization | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/scripts | ||
./stylize.sh astyle | ||
linux: | ||
runs-on: ubuntu-latest | ||
needs: [docker-image] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,70 @@ | ||
if [ "$1" == "" ] || [ $# -gt 1 ]; then | ||
echo "Usage: ./stylize.sh /path/to/astyle/executable" | ||
exit 0 | ||
#!/bin/bash | ||
if [ "$1" == "" ] || [ $# -gt 2 ]; then | ||
echo "Usage: ./stylize.sh [-f] /path/to/astyle/executable" | ||
echo "Checks if stylization is required." | ||
echo " -f: enforce stylization. By default, only the check is executed." | ||
exit 1 | ||
fi | ||
ASTYLE_BIN=$1 | ||
enforce=false | ||
|
||
# parse the flags. | ||
while getopts f: flag | ||
do | ||
case "${flag}" in | ||
f) | ||
enforce=true | ||
ASTYLE_BIN=$2 | ||
;; | ||
*) | ||
echo "Unknown option." | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# astyle version check | ||
ASTYLE_VER="Artistic Style Version 3.1" | ||
astyle_version="$($ASTYLE_BIN --version)" | ||
if [ "$astyle_version" != "$ASTYLE_VER" ]; then | ||
printf "%s\n" "Invalid astyle version: '$astyle_version'"\ | ||
"Please use: '$ASTYLE_VER'" | ||
exit 1 | ||
fi | ||
|
||
# astyle dry-run if not enforced. | ||
if [ $enforce != true ]; then | ||
ASTYLE_BIN="$ASTYLE_BIN --dry-run" | ||
fi | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
DIR="$(dirname "$DIR")" | ||
|
||
$1 --recursive --max-code-length=80 "$DIR/lib/*.cpp" | ||
$1 --recursive --max-code-length=80 "$DIR/lib/*.h" | ||
$1 --recursive --max-code-length=80 "$DIR/lib/*.hpp" | ||
$1 --recursive --max-code-length=80 "$DIR/lib/*.c" | ||
$1 --recursive --max-code-length=80 "$DIR/lib/*h.in" | ||
$1 --recursive --max-code-length=80 "$DIR/tests/*.cpp" | ||
$1 --recursive --max-code-length=80 "$DIR/examples/*.cpp" | ||
$1 --recursive --max-code-length=80 "$DIR/examples/*.hpp" | ||
FILELIST=("lib/*.cpp" | ||
"lib/*.h" | ||
"lib/*.hpp" | ||
"lib/*.c" | ||
"lib/*h.in" | ||
"regression_tests/*.cpp" | ||
"unit_tests/*.cpp" | ||
"examples/*.cpp" | ||
"examples/*.hpp") | ||
|
||
ASTYLE_COMMAND="$ASTYLE_BIN --recursive --project=../.astylerc" | ||
|
||
result=false | ||
for files in ${FILELIST[@]} | ||
do | ||
echo $files | ||
if $ASTYLE_COMMAND "$DIR/$files" | grep "Formatted"; then | ||
result=true | ||
fi | ||
done | ||
|
||
if [ $enforce != true ] && [ $result = true ]; then | ||
echo "Files need stylization!" | ||
echo "Please run stylization before merging the pull-request." | ||
echo " 1. Install $ASTYLE_VER" | ||
echo " 2. cd scripts && ./stylize.sh -f /path/to/astyle" | ||
exit 1 | ||
fi |
Oops, something went wrong.