From ac1643b07a87c484509a89393ea2280034d0b257 Mon Sep 17 00:00:00 2001 From: AIRONAX Developer Date: Sat, 5 Sep 2026 04:47:11 +0530 Subject: [PATCH 1/2] ci: add GitHub Actions for build, test, lint, and vuln checks Checkout sibling ProjectMeru/sumeru for the go.mod replace, run on main/dev, and surface a CI badge in the README. --- .github/dependabot.yml | 12 +++ .github/workflows/ci.yml | 172 +++++++++++++++++++++++++++++++++++++++ .golangci.yml | 30 +++++++ README.md | 3 +- 4 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .golangci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9a06d80 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d236666 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,172 @@ +name: CI + +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + - dev + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + # Match the PR base or push branch so addons track the same sumeru line. + SUMERU_REF: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }} + +jobs: + go-build: + name: Go build + runs-on: ubuntu-latest + defaults: + run: + working-directory: sumeru_addons + steps: + - name: Checkout sumeru_addons + uses: actions/checkout@v7 + with: + path: sumeru_addons + + - name: Checkout sumeru (replace sibling) + uses: actions/checkout@v7 + with: + repository: ProjectMeru/sumeru + ref: ${{ env.SUMERU_REF }} + path: sumeru + + - uses: actions/setup-go@v7 + with: + go-version: "1.26.6" + cache: true + cache-dependency-path: sumeru_addons/go.sum + + - name: Build all packages + env: + GOFLAGS: -mod=readonly + run: go build ./... + + - name: Job summary + if: always() + run: | + echo "## Go build" >> "$GITHUB_STEP_SUMMARY" + echo "Command: \`go build ./...\` (replace sumeru => ../sumeru @ \`${{ env.SUMERU_REF }}\`)" >> "$GITHUB_STEP_SUMMARY" + + go-test: + name: Go test + runs-on: ubuntu-latest + defaults: + run: + working-directory: sumeru_addons + steps: + - name: Checkout sumeru_addons + uses: actions/checkout@v7 + with: + path: sumeru_addons + + - name: Checkout sumeru (replace sibling) + uses: actions/checkout@v7 + with: + repository: ProjectMeru/sumeru + ref: ${{ env.SUMERU_REF }} + path: sumeru + + - uses: actions/setup-go@v7 + with: + go-version: "1.26.6" + cache: true + cache-dependency-path: sumeru_addons/go.sum + + - name: Run unit tests + env: + GOFLAGS: -mod=readonly + run: go test ./... -count=1 -timeout 15m + + - name: Job summary + if: always() + run: | + echo "## Go test" >> "$GITHUB_STEP_SUMMARY" + echo "Command: \`go test ./...\` (replace sumeru => ../sumeru @ \`${{ env.SUMERU_REF }}\`)" >> "$GITHUB_STEP_SUMMARY" + + go-lint: + name: Go lint + runs-on: ubuntu-latest + defaults: + run: + working-directory: sumeru_addons + steps: + - name: Checkout sumeru_addons + uses: actions/checkout@v7 + with: + path: sumeru_addons + fetch-depth: 0 + + - name: Checkout sumeru (replace sibling) + uses: actions/checkout@v7 + with: + repository: ProjectMeru/sumeru + ref: ${{ env.SUMERU_REF }} + path: sumeru + + - uses: actions/setup-go@v7 + with: + go-version: "1.26.6" + cache: true + cache-dependency-path: sumeru_addons/go.sum + + - name: go vet + run: go vet ./... + + - name: golangci-lint + uses: golangci/golangci-lint-action@v9 + with: + version: latest + working-directory: sumeru_addons + args: --timeout=10m + only-new-issues: ${{ github.event_name == 'pull_request' }} + + - name: Job summary + if: always() + run: | + echo "## Go lint" >> "$GITHUB_STEP_SUMMARY" + echo "Commands: \`go vet ./...\`, \`golangci-lint run\`" >> "$GITHUB_STEP_SUMMARY" + + go-vuln: + name: Go vulnerabilities + runs-on: ubuntu-latest + defaults: + run: + working-directory: sumeru_addons + steps: + - name: Checkout sumeru_addons + uses: actions/checkout@v7 + with: + path: sumeru_addons + + - name: Checkout sumeru (replace sibling) + uses: actions/checkout@v7 + with: + repository: ProjectMeru/sumeru + ref: ${{ env.SUMERU_REF }} + path: sumeru + + - uses: actions/setup-go@v7 + with: + go-version: "1.26.6" + cache: true + cache-dependency-path: sumeru_addons/go.sum + + - name: govulncheck + run: go run golang.org/x/vuln/cmd/govulncheck@latest ./... + + - name: Job summary + if: always() + run: | + echo "## Go vulnerabilities" >> "$GITHUB_STEP_SUMMARY" + echo "Command: \`govulncheck ./...\`" >> "$GITHUB_STEP_SUMMARY" diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..f5bd04c --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,30 @@ +version: "2" + +linters: + default: none + enable: + - errcheck + - govet + - ineffassign + - staticcheck + - unused + settings: + errcheck: + # Deferred Close errors are rarely actionable; keep errcheck for real ignored returns. + exclude-functions: + - (io.Closer).Close + - (*database/sql.Rows).Close + - (*database/sql.DB).Close + - (*os.File).Close + - (*compress/gzip.Reader).Close + - (*mime/multipart.FileHeader).Open + - (net/smtp.Client).Close + - (*net/smtp.Client).Close + - (*github.com/gorilla/websocket.Conn).Close + +run: + timeout: 10m + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 diff --git a/README.md b/README.md index 202ecec..47a6bdc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # sumeru_addons -[![Go](https://img.shields.io/badge/Go-1.26.2+-00ADD8?logo=go&logoColor=white)](https://go.dev/dl/) +[![CI](https://github.com/ProjectMeru/sumeru_addons/actions/workflows/ci.yml/badge.svg)](https://github.com/ProjectMeru/sumeru_addons/actions/workflows/ci.yml) +[![Go](https://img.shields.io/badge/Go-1.26.6+-00ADD8?logo=go&logoColor=white)](https://go.dev/dl/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) [![Pre-Alpha](https://img.shields.io/badge/Status-Pre--Alpha-critical?style=for-the-badge)](https://github.com/ProjectMeru/sumeru) From 9f1ad70095872c4236fb0d95f0aa47d1b3988094 Mon Sep 17 00:00:00 2001 From: AIRONAX Developer Date: Sat, 5 Sep 2026 04:47:21 +0530 Subject: [PATCH 2/2] chore: align Go deps with sumeru and clear golangci findings Bump the module to Go 1.26.6 / current indirect deps and fix ineffassign/staticcheck issues so CI lint stays green. --- account/services/actions.go | 7 ++++--- account/services/bank_reconcile.go | 2 +- account/services/reconcile.go | 13 +++++-------- account/services/reporting.go | 9 +-------- go.mod | 6 +++--- go.sum | 8 ++++---- sale_crm/services/quotation.go | 2 +- 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/account/services/actions.go b/account/services/actions.go index d9c8f74..1226c08 100644 --- a/account/services/actions.go +++ b/account/services/actions.go @@ -236,13 +236,14 @@ func actionReverseMoves(ctx context.Context, model string, id int, vals map[stri reason := orm.AsString(wiz["reason"]) seqCode := "account.move.out_refund" prefix := "RINV" - if revType == "in_refund" { + switch revType { + case "in_refund": seqCode = "account.move.in_refund" prefix = "RBILL" - } else if revType == "out_invoice" { + case "out_invoice": seqCode = "account.move.out_invoice" prefix = "INV" - } else if revType == "in_invoice" { + case "in_invoice": seqCode = "account.move.in_invoice" prefix = "BILL" } diff --git a/account/services/bank_reconcile.go b/account/services/bank_reconcile.go index 9faa9e6..92b9fa8 100644 --- a/account/services/bank_reconcile.go +++ b/account/services/bank_reconcile.go @@ -27,7 +27,7 @@ func ReconcileStatementLine(ctx context.Context, moveLineID int, amount float64) if math.Abs(res) <= balanceEpsilon { return nil } - newRes := res + var newRes float64 if res > 0 { newRes = res - math.Abs(amount) } else { diff --git a/account/services/reconcile.go b/account/services/reconcile.go index d8ad7ad..8755694 100644 --- a/account/services/reconcile.go +++ b/account/services/reconcile.go @@ -19,6 +19,7 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int {"display_type", "=", "entry"}, }) var invLine map[string]interface{} +findInvLine: for _, ln := range lines { res := numericFloat(ln["amount_residual"]) if math.Abs(res) < balanceEpsilon { @@ -31,12 +32,12 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int case "out_invoice", "out_refund": if atype == "asset_receivable" { invLine = ln - break + break findInvLine } case "in_invoice", "in_refund": if atype == "liability_payable" { invLine = ln - break + break findInvLine } } if invLine == nil && math.Abs(res) > balanceEpsilon { @@ -59,10 +60,7 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int return nil } - debitID, creditID := int(invLineID), paymentLineID - if invRes < 0 { - debitID, creditID = paymentLineID, int(invLineID) - } + var debitID, creditID int if numericFloat(invLine["debit"]) > 0 || invRes > 0 { debitID, creditID = int(invLineID), paymentLineID } else { @@ -82,8 +80,7 @@ func reconcilePaymentToInvoice(ctx context.Context, invoiceID, paymentLineID int return err } - newInvRes := invRes - newPayRes := payRes + var newInvRes, newPayRes float64 if invRes > 0 { newInvRes = invRes - reconcileAmt } else { diff --git a/account/services/reporting.go b/account/services/reporting.go index 8ec3259..0e55016 100644 --- a/account/services/reporting.go +++ b/account/services/reporting.go @@ -143,17 +143,10 @@ func BalanceSheet(ctx context.Context, dateFrom, dateTo string) (*ReportResult, if retained != 0 { lines = append(lines, ReportLine{Name: "Current Year Earnings", Balance: round2(retained)}) } - assetTotal, liabEq := 0.0, 0.0 + assetTotal := 0.0 for _, v := range assets { assetTotal += v } - for _, v := range liabilities { - liabEq += -v - } - for _, v := range equity { - liabEq += -v - } - liabEq += retained return &ReportResult{ Title: "Balance Sheet", DateFrom: dateFrom, diff --git a/go.mod b/go.mod index e2ce09c..bc91833 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module sumeru_addons -go 1.26.2 +go 1.26.6 replace sumeru => ../sumeru @@ -8,8 +8,8 @@ require sumeru v0.0.0-00010101000000-000000000000 require ( github.com/gorilla/websocket v1.5.3 // indirect - github.com/gpdf-dev/gpdf v1.0.11 // indirect + github.com/gpdf-dev/gpdf v1.0.12 // indirect github.com/lib/pq v1.12.3 // indirect - golang.org/x/crypto v0.55.0 // indirect + golang.org/x/crypto v0.56.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect ) diff --git a/go.sum b/go.sum index b248943..bfa804e 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gpdf-dev/gpdf v1.0.11 h1:IPtcb+/6COykKtenZ3CXexOoStdyNepiE7DHqnvyyew= -github.com/gpdf-dev/gpdf v1.0.11/go.mod h1:QTnE2q2L+q9E1neWCZen/V/x9iLOuJ1jWHBtylimfAw= +github.com/gpdf-dev/gpdf v1.0.12 h1:KAqoXq6iN+I99YbHrNIQqP77rnn2rRFq9pMoi2Ccroo= +github.com/gpdf-dev/gpdf v1.0.12/go.mod h1:QTnE2q2L+q9E1neWCZen/V/x9iLOuJ1jWHBtylimfAw= github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ= github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA= -golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= -golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/crypto v0.56.0 h1:GUh5Ii4J5jtcseSMiRqr1jXCNHoxjeV9Fmekc2oLy6Y= +golang.org/x/crypto v0.56.0/go.mod h1:OMW5y6CY9l38uPLmxU6l6pwcXp1obtLo3e6gT7gQR2I= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= diff --git a/sale_crm/services/quotation.go b/sale_crm/services/quotation.go index b69f703..e2aa574 100644 --- a/sale_crm/services/quotation.go +++ b/sale_crm/services/quotation.go @@ -138,7 +138,7 @@ func refreshQuotationCount(ctx context.Context, leadID int64) error { } func onLeadWonCreateQuotation(ctx context.Context, ev event.Event) error { - if orm.ConfigParamBool(ctx, "sale_crm.auto_quotation", true) == false { + if !orm.ConfigParamBool(ctx, "sale_crm.auto_quotation", true) { return nil } model, _ := ev.Payload["model"].(string)