From 98adf1f9a40a2bdec17be68d9aec4cb433ed30aa Mon Sep 17 00:00:00 2001 From: Yidi Date: Thu, 10 Oct 2024 15:06:43 -0400 Subject: [PATCH] feat(workflow): add complexity check for Go codebase This commit introduces a new GitHub Actions workflow to automatically check the complexity of Go functions using gocyclo. The workflow triggers on pushes and pull requests to the main branch. It ensures that any function exceeding a complexity threshold of 20 is flagged, helping maintain code quality and readability. --- .github/workflows/complecity-check.yml | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/complecity-check.yml diff --git a/.github/workflows/complecity-check.yml b/.github/workflows/complecity-check.yml new file mode 100644 index 0000000..91c202e --- /dev/null +++ b/.github/workflows/complecity-check.yml @@ -0,0 +1,28 @@ +name: Complexity Check + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + complexity: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + + - name: Install gocyclo + run: go install github.com/fzipp/gocyclo/cmd/gocyclo@latest + + - name: Run gocyclo + run: gocyclo -over 20 . || exit 1 + + - name: Fail on high complexity + if: failure() + run: echo "One or more functions exceed the permissible complexity threshold of 20."