Swift: autopep8 all python files

Additionally set up a pre-commit hook and a CI check for that.
This commit is contained in:
Paolo Tranquilli
2022-06-23 17:05:21 +02:00
parent 43d449f1f7
commit 7334b4e03a
9 changed files with 157 additions and 146 deletions

View File

@@ -15,14 +15,18 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/fetch-codeql
- uses: bazelbuild/setup-bazelisk@v2
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
name: Check that python code is properly formatted
with:
extra_args: autopep8 --all-files
- name: Run unit tests
run: |
bazel test //swift/codegen/test --test_output=errors
- name: Check that QL generated code was checked in
run: |
bazel run //swift/codegen
git add swift
git diff --exit-code HEAD
- uses: pre-commit/action@v3.0.0
name: Check that QL generated code was checked in
with:
extra_args: swift-codegen --all-files
- name: Generate C++ files
run: |
bazel run //swift/codegen:codegen -- --generate=trap,cpp --cpp-output=$PWD/swift-generated-headers

View File

@@ -15,6 +15,12 @@ repos:
- id: clang-format
files: ^swift/.*\.(h|c|cpp)$
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.6.0
hooks:
- id: autopep8
files: ^swift/codegen/.*\.py
- repo: local
hooks:
- id: codeql-format

2
swift/codegen/.pep8 Normal file
View File

@@ -0,0 +1,2 @@
[pep8]
max_line_length = 120

View File

@@ -266,7 +266,6 @@ A:
""")
def test_class_with_pragmas(load):
ret = load("""
A:

View File

@@ -125,6 +125,7 @@ def test_one_table_overridden_underscore_named_field(generate_traps):
cpp.Trap("foos", name="Foos", fields=[cpp.Field("whatever", "bar")]),
]
def test_one_table_no_tags(generate_tags):
assert generate_tags([
dbscheme.Table(name="foos", columns=[dbscheme.Column("bla", "int")]),

View File

@@ -4,4 +4,3 @@ run_codeql_database_create([
'swift package clean',
'swift build'
], lang='swift')