From 104579f3418ef9041b8e80376b02e40383ffee2c Mon Sep 17 00:00:00 2001 From: Yidi Date: Thu, 10 Oct 2024 15:01:11 -0400 Subject: [PATCH] feat(ci): add complexity check workflow using gocyclo This commit adds a GitHub Actions workflow to check for code complexity in the Go codebase. It triggers on pushes and pull requests to the main branch. The workflow uses gocyclo to identify functions with a complexity greater than 20, ensuring maintainable code and reducing technical debt. --- .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..f964321 --- /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 ./internal/... || exit 1 + + - name: Fail on high complexity + if: failure() + run: echo "One or more functions exceed the permissible complexity threshold of 20."