diff --git a/.github/workflows/swagger-check.yml b/.github/workflows/swagger-check.yml new file mode 100644 index 00000000..bc2a22da --- /dev/null +++ b/.github/workflows/swagger-check.yml @@ -0,0 +1,53 @@ +name: Swagger Check + +on: + pull_request: + paths: + - "proto/**" + - "client/docs/**" + - "x/**/query.go" + - "x/**/tx.go" + - ".github/workflows/swagger-check.yml" + push: + branches: + - main + paths: + - "proto/**" + - "client/docs/**" + +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." diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d80040c..09138578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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))