diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b68c7e9..968a0ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,26 +1,13 @@ -name: auto-format -on: pull_request +name: clang-format Check +on: [push, pull_request] jobs: - format: - # Check if the PR is not from a fork - if: github.event.pull_request.head.repo.full_name == github.repository + formatting-check: + name: Formatting Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - ref: ${{ github.head_ref }} - - name: autopep8 - uses: peter-evans/autopep8@v1 - with: - args: --exit-code --recursive --in-place --aggressive --aggressive . - - name: Check for modified files - id: git-check - run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) - - name: Push changes - if: steps.git-check.outputs.modified == 'true' - run: | - git config --global user.name 'Peter Evans' - git config --global user.email 'peter-evans@users.noreply.github.com' - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} - git commit -am "Automated changes" - git push + - uses: actions/checkout@v2 + - name: Run clang-format style check for C/C++ programs. + uses: jidicula/clang-format-action@v3.1.0 + with: + clang-format-version: '11' + check-path: 'src' diff --git a/README.md b/README.md index 8308198..9043efc 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ This course will walk you through writing your first action and using it with a workflow file. -**Ready to get started? Navigate to the first issue.** \ No newline at end of file +Testing + +**Ready to get started? Navigate to the first issue.** diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..0590c3f --- /dev/null +++ b/test.cpp @@ -0,0 +1 @@ +int x = 1; diff --git a/test.py b/test.py new file mode 100644 index 0000000..b04a9a1 --- /dev/null +++ b/test.py @@ -0,0 +1,21 @@ +import math, sys; + +def example1(): + ####This is a long comment. This should be wrapped to fit within 72 characters. + some_tuple=( 1,2, 3,'a' ); + some_variable={'long':'Long code lines should be wrapped within 79 characters.', + 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'], + 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1, + 20,300,40000,500000000,60000000000000000]}} + return (some_tuple, some_variable) +def example2(): return {'has_key() is deprecated':True}.has_key({'f':2}.has_key('')); +class Example3( object ): + def __init__ ( self, bar ): + #Comments should have a space after the hash. + if bar : bar+=1; bar=bar* bar ; return bar + else: + some_string = """ + Indentation in multiline strings should not be touched. +Only actual code should be reindented. +""" + return (sys.path, some_string)