Skip to content

Commit

Permalink
Add script to format code in a CI container
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Wilson <[email protected]>
  • Loading branch information
SWilson4 committed Jul 25, 2024
1 parent 2f02bf4 commit 1a91e22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions scripts/format_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# SPDX-License-Identifier: MIT

if [ ! -d "$LIBOQS_DIR" ]
then
echo Must set environment variable LIBOQS_DIR
exit 1
fi

docker run --rm -v"$LIBOQS_DIR":/root/liboqs -w /root/liboqs openquantumsafe/ci-ubuntu-focal-x86_64:latest ./tests/run_astyle.sh --no-dry-run
8 changes: 7 additions & 1 deletion tests/run_astyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

rv=0

if [ "$1" = "--no-dry-run" ]; then
dryrun=""
else
dryrun="--dry-run"
fi

# check style of non-external code:
find src tests -name '*.[ch]' | grep -v '/external/' | grep -v 'kem/.*/.*/.*' | grep -v 'sig/.*/.*/.*' | xargs astyle --dry-run --options=.astylerc | grep Format
find src tests -name '*.[ch]' | grep -v '/external/' | grep -v 'kem/.*/.*/.*' | grep -v 'sig/.*/.*/.*' | xargs astyle $dryrun --options=.astylerc | grep Format
if [ $? -ne 1 ]; then
echo "Error: Some files need reformatting. Check output above."
rv=-1
Expand Down

0 comments on commit 1a91e22

Please sign in to comment.