diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2843360..7544bc9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -36,3 +36,17 @@ jobs: working-directory: ./tree-sitter-p4 - run: swift build - run: swift test + library-format-tests: + name: Library Format Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v4 + - uses: tree-sitter/setup-action@v2 + - uses: swift-actions/setup-swift@v2 + with: + swift-version: "6.2" + - run: tree-sitter generate + working-directory: ./tree-sitter-p4 + - run: ./ci/format.sh + diff --git a/README.md b/README.md index be46c95..82c2b0e 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,5 @@ For more information, see the [documentation for the Swift-DocC plugin](https:// To check the format: ```console -$ swift package plugin --allow-writing-to-package-directory swiftformat +$ swift-format --recursive -i Sources/ ``` \ No newline at end of file diff --git a/ci/format.sh b/ci/format.sh new file mode 100755 index 0000000..ef84845 --- /dev/null +++ b/ci/format.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Format +swift format --recursive -i Sources/ 2>&1 >/dev/null + +# Modified count +mc=`git status . | grep modified | wc -l | sed 's/ //g'` + +if [ ${mc} -ne 0 ]; then + exit 1 +fi + +exit 0 \ No newline at end of file