-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
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
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,29 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_run: | ||
# Use a workflow as a trigger of scheduled builds. Forked repositories can disable scheduled builds by disabling | ||
# "scheduled" workflow, while maintaining ability to perform local CI builds. | ||
workflows: | ||
- scheduled | ||
branches: | ||
- main | ||
- test_actions | ||
types: | ||
- requested | ||
|
||
jobs: | ||
cpp-formatting-check: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
git submodule update --init | ||
- name: Check formatting | ||
run: | | ||
python tools/format.py |
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,57 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse, os, subprocess, shutil | ||
|
||
# if ! command -v clang-format &> /dev/null ; then | ||
# echo "clang-format is not available. Please install version 14 " | ||
# echo "and make sure that it is accessible from PATH." | ||
# exit | ||
# fi | ||
|
||
# cfversion=`clang-format --version | grep -Eo '[0-9]+' | head -1` | ||
# if [ "$cfversion" != "14" ]; then | ||
# echo "Warning: Invalid clang-format version: ${cfversion} (should be 14)" | ||
# fi | ||
|
||
# clang-format -i *.cc *.h boxpack/*.cc boxpack/*.h | ||
|
||
|
||
def verify_clang_format(): | ||
if shutil.which('clang-format') is None: | ||
print('clang-format is missing') | ||
exit(1) | ||
result = subprocess.run(['clang-format', '--version'], stdout=subprocess.PIPE) | ||
tokens = result.stdout.decode("utf-8").split() | ||
while len(tokens) > 0 and tokens[0] != 'clang-format': | ||
tokens.pop(0) | ||
if result.returncode != 0 or len(tokens) < 3 or tokens[0] != 'clang-format' or tokens[1] != 'version': | ||
print('error while checking clang-format version') | ||
exit(1) | ||
version = tokens[2].split('.', 2) | ||
print(f"clang-format version: {version[0]}.{version[1]}.{version[2]}") | ||
|
||
|
||
def format_cpp(check: bool): | ||
print("meh") | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
prog='libfwk-format', | ||
description='Tool for code formatting and format verification', | ||
) | ||
parser.add_argument('-c', '--check', action='store_true') | ||
args = parser.parse_args() | ||
|
||
libfwk_path = os.path.join(__file__, '..') | ||
|
||
if args.check: | ||
print('Checking mode') | ||
else: | ||
print('Formatting mode') | ||
|
||
verify_clang_format() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |