From 3752dd01ab28b4cdca2ccd306cb7a6e3169b4f75 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Tue, 24 Feb 2026 01:00:32 -0500 Subject: [PATCH] Add Formatting To CI/CD Signed-off-by: Will Hawkins --- .github/workflows/main.yaml | 14 ++++++++++++++ README.md | 2 +- ci/format.sh | 13 +++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 ci/format.sh 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