From e70bd4c0aedab7f60a33f8849762c71bf0bcb4ed Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 26 Jul 2026 22:56:29 +0000 Subject: [PATCH 1/3] ci: add golangci-lint and 65% coverage gate Match the quality bar used by prairie-server and the client repos. Co-authored-by: Jonah May --- .github/workflows/ci.yml | 87 ++++++++++++++++++++++++++++++--------- .golangci.yml | 29 +++++++++++++ scripts/check-coverage.sh | 21 ++++++++++ 3 files changed, 117 insertions(+), 20 deletions(-) create mode 100644 .golangci.yml create mode 100755 scripts/check-coverage.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9720b01..de69147 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,26 +1,73 @@ -name: CI + name: CI -on: - push: - branches: - - main - pull_request: + on: + push: + branches: [main] + pull_request: + workflow_dispatch: -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + permissions: + contents: read - - uses: actions/setup-go@v5 - with: - go-version: '1.26' + concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true - - name: Run tests - run: go test ./... + env: + COVER_MIN: "65" - - name: Build example plugin - run: go build ./examples/hello-scheduled-task + jobs: + lint: + name: Go lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + fetch-depth: 0 - - name: Build hello-runtime-host example - run: go build ./examples/hello-runtime-host + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: latest + only-new-issues: true + args: --timeout=5m + + test: + name: Go tests + coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Run tests with coverage + env: + GOWORK: off + run: go test $(go list ./pkg/pluginsdk/... | grep -v '/runtimedefault$') -count=1 -covermode=atomic -coverprofile=coverage.out + + - name: Enforce coverage floor + run: ./scripts/check-coverage.sh coverage.out + +- name: Build examples + run: | + go build ./examples/hello-scheduled-task + go build ./examples/hello-runtime-host + + - name: Upload coverage profile + if: always() + uses: actions/upload-artifact@v5 + with: + name: coverage-out + path: coverage.out + if-no-files-found: ignore diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..49619d5 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,29 @@ +version: "2" + +run: + timeout: 5m + +formatters: + enable: + - gofmt + - goimports + + settings: + goimports: + local-prefixes: + - github.com/prairie-server/prairie-plugin-sdk + +linters: + enable: + - errcheck + - govet + - ineffassign + - misspell + - staticcheck + - unused + + exclusions: + rules: + - path: _test\.go + linters: + - errcheck diff --git a/scripts/check-coverage.sh b/scripts/check-coverage.sh new file mode 100755 index 0000000..f83e065 --- /dev/null +++ b/scripts/check-coverage.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Fail if total statement coverage is below COVER_MIN (percent). +set -euo pipefail +COVER_MIN="${COVER_MIN:-70}" +PROFILE="${1:-coverage.out}" +if [[ ! -f "$PROFILE" ]]; then + echo "coverage profile missing: $PROFILE" >&2 + exit 1 +fi +total="$(go tool cover -func="$PROFILE" | awk '/^total:/{gsub(/%/,"",$3); print $3}')" +if [[ -z "$total" ]]; then + echo "could not parse total coverage from $PROFILE" >&2 + exit 1 +fi +awk -v total="$total" -v min="$COVER_MIN" 'BEGIN { + if (total+0 < min+0) { + printf "coverage %.1f%% is below required %.1f%%\n", total, min > "/dev/stderr" + exit 1 + } + printf "coverage %.1f%% (min %.1f%%)\n", total, min +}' From f64d7ad814c07b3c4b84e2c28e7f5b7aec6a0d1e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 26 Jul 2026 23:01:41 +0000 Subject: [PATCH 2/3] ci: fix workflow YAML indentation for lint and coverage jobs Co-authored-by: Jonah May --- .github/workflows/ci.yml | 113 +++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de69147..875b326 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,73 +1,72 @@ - name: CI +name: CI - on: - push: - branches: [main] - pull_request: - workflow_dispatch: +on: + push: + branches: [main] + pull_request: + workflow_dispatch: - permissions: - contents: read +permissions: + contents: read - concurrency: - group: ci-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true - env: - COVER_MIN: "65" +env: + COVER_MIN: "65" - jobs: - lint: - name: Go lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - with: - persist-credentials: false - fetch-depth: 0 +jobs: + lint: + name: Go lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + fetch-depth: 0 - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true - - name: golangci-lint - uses: golangci/golangci-lint-action@v8 - with: - version: latest - only-new-issues: true - args: --timeout=5m + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: latest + only-new-issues: true + args: --timeout=5m - test: - name: Go tests + coverage - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - with: - persist-credentials: false + test: + name: Go tests + coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true - - name: Run tests with coverage - env: - GOWORK: off - run: go test $(go list ./pkg/pluginsdk/... | grep -v '/runtimedefault$') -count=1 -covermode=atomic -coverprofile=coverage.out + - name: Run tests with coverage + env: + GOWORK: off + run: go test $(go list ./pkg/pluginsdk/... | grep -v '/runtimedefault$') -count=1 -covermode=atomic -coverprofile=coverage.out - - name: Enforce coverage floor - run: ./scripts/check-coverage.sh coverage.out + - name: Enforce coverage floor + run: ./scripts/check-coverage.sh coverage.out - name: Build examples run: | go build ./examples/hello-scheduled-task go build ./examples/hello-runtime-host - - - name: Upload coverage profile - if: always() - uses: actions/upload-artifact@v5 - with: - name: coverage-out - path: coverage.out - if-no-files-found: ignore + - name: Upload coverage profile + if: always() + uses: actions/upload-artifact@v5 + with: + name: coverage-out + path: coverage.out + if-no-files-found: ignore From d13f4d117ca3f88024d37c0163a84d668df23ff9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 26 Jul 2026 23:01:57 +0000 Subject: [PATCH 3/3] ci: fix workflow YAML indentation for lint and coverage jobs Co-authored-by: Jonah May --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 875b326..49a0bf5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,10 +59,11 @@ jobs: - name: Enforce coverage floor run: ./scripts/check-coverage.sh coverage.out -- name: Build examples - run: | - go build ./examples/hello-scheduled-task - go build ./examples/hello-runtime-host + - name: Build examples + run: | + go build ./examples/hello-scheduled-task + go build ./examples/hello-runtime-host + - name: Upload coverage profile if: always() uses: actions/upload-artifact@v5