Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/swagger-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Swagger Check

on:
pull_request:
paths:
- "proto/**"
- "client/docs/**"
- "x/**/query.go"
- "x/**/tx.go"
Comment on lines +8 to +9
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow runs on changes to x//query.go and x//tx.go, but make proto-swagger-gen only scans *.proto files (and dependency protos via go.mod) during generation. This will trigger an expensive docker/go-mod step on handler-only changes that can’t affect Swagger output; consider removing these path patterns to reduce CI time, or document why they’re required.

Suggested change
- "x/**/query.go"
- "x/**/tx.go"

Copilot uses AI. Check for mistakes.
- ".github/workflows/swagger-check.yml"
push:
branches:
- main
paths:
- "proto/**"
- "client/docs/**"
Comment on lines +14 to +16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

push path filters miss module handler changes that can affect Swagger output.

On Line 14-16, pushes to main only trigger for proto/** and client/docs/**. A direct push changing x/**/query.go or x/**/tx.go will skip this check and can let stale Swagger artifacts land.

Suggested patch
   push:
     branches:
       - main
     paths:
       - "proto/**"
       - "client/docs/**"
+      - "x/**/query.go"
+      - "x/**/tx.go"
+      - ".github/workflows/swagger-check.yml"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
paths:
- "proto/**"
- "client/docs/**"
paths:
- "proto/**"
- "client/docs/**"
- "x/**/query.go"
- "x/**/tx.go"
- ".github/workflows/swagger-check.yml"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/swagger-check.yml around lines 14 - 16, push path filters
in swagger-check.yml only include "proto/**" and "client/docs/**", so changes to
module handler files (e.g., query.go and tx.go under x/**/) can skip the Swagger
check; update the workflow's push.paths configuration to also match module
handler sources by adding patterns that include x/**/query.go and x/**/tx.go
(and any other handler/source patterns your modules use) so commits touching
those files trigger the Swagger artifact validation.

Comment on lines +6 to +16
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow path filters don’t include inputs that can change the generated Swagger output (e.g., go.mod/go.sum dependency updates and the generator logic in Makefile / proto/scripts). As-is, Swagger can become stale without this check running. Consider adding go.mod, go.sum, Makefile, and proto/scripts/** to the pull_request/push path lists (or otherwise ensuring the workflow runs when generation inputs change).

Suggested change
- "proto/**"
- "client/docs/**"
- "x/**/query.go"
- "x/**/tx.go"
- ".github/workflows/swagger-check.yml"
push:
branches:
- main
paths:
- "proto/**"
- "client/docs/**"
- "proto/**"
- "proto/scripts/**"
- "client/docs/**"
- "x/**/query.go"
- "x/**/tx.go"
- "go.mod"
- "go.sum"
- "Makefile"
- ".github/workflows/swagger-check.yml"
push:
branches:
- main
paths:
- "proto/**"
- "proto/scripts/**"
- "client/docs/**"
- "go.mod"
- "go.sum"
- "Makefile"

Copilot uses AI. Check for mistakes.

Comment on lines +11 to +17
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says pushes to main should also trigger on x//query.go and x//tx.go changes, but the push.paths list only includes proto/** and client/docs/**. Please align the workflow triggers with the documented behavior (either expand push.paths accordingly or update the PR description).

Copilot uses AI. Check for mistakes.
permissions:
contents: read

jobs:
swagger-diff:
name: Check Swagger is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.24"

- name: Regenerate Swagger
run: |
# Override protoImage so the Docker container runs as the runner user,
# avoiding "permission denied" on the mounted workspace volume.
# Set HOME to /tmp so buf can write its cache (default /.cache is root-only).
PROTO_VER=$(grep '^protoVer=' Makefile | cut -d= -f2)
make proto-swagger-gen \
"protoImage=docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v $(pwd):/workspace --workdir /workspace ghcr.io/cosmos/proto-builder:${PROTO_VER}"

- name: Check for uncommitted changes
run: |
if ! git diff --quiet --exit-code client/docs/swagger-ui/swagger.yaml client/docs/swagger-ui/swagger.json; then
echo "::error::Swagger files are out of date. Please run 'make proto-swagger-gen' and commit the changes."
echo ""
echo "Changed files:"
git diff --stat client/docs/swagger-ui/swagger.yaml client/docs/swagger-ui/swagger.json
echo ""
echo "Diff:"
git diff client/docs/swagger-ui/swagger.yaml client/docs/swagger-ui/swagger.json
exit 1
fi
echo "Swagger files are up to date."
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Added

- Add CI workflow to verify Swagger files are up to date after `make proto-swagger-gen`; fails PR if generated files differ from committed ones ([#66](https://github.com/KiiChain/kiichain/issues/66))

### Fixed

- Fix division-by-zero chain halt in `CalculateReward` caused by sub-second schedule durations; replace `Seconds()` truncation with `Nanoseconds()` precision and release full remaining reward when `EndTime <= LastReleaseTime` ([#267](https://github.com/KiiChain/kiichain/issues/267))
Expand Down
Loading