diff --git a/.github/workflows/index-review.yml b/.github/workflows/index-review.yml new file mode 100644 index 0000000..94b7f48 --- /dev/null +++ b/.github/workflows/index-review.yml @@ -0,0 +1,35 @@ +name: Index review + +# The repository runs its own GitHub Action on every pull request that touches +# SQL or Mapper XML. Two things are proven by this file existing: the `uses:` ref +# in the README resolves, and a contributor gets advice on the line they changed +# without anyone installing anything. +# +# `fail-on: off` on purpose. Adoption first: the check comments, it does not +# redden the build. A team that wants a gate changes it to `error` in their own +# copy (see examples/github-action/pr-review.yml). + +on: + pull_request: + paths: + - "**/*.xml" + - "**/*.sql" + - "examples/**" + +permissions: + contents: read + pull-requests: write + +jobs: + review: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Index review + uses: JingYu-create520/sql-index-advisor@v0 + with: + path: examples/pr-demo + schema: examples/pr-demo/demo-schema.json + min-severity: info + fail-on: "off" diff --git a/examples/pr-demo/OrderSearchDao.xml b/examples/pr-demo/OrderSearchDao.xml new file mode 100644 index 0000000..292f619 --- /dev/null +++ b/examples/pr-demo/OrderSearchDao.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + diff --git a/examples/pr-demo/demo-schema.json b/examples/pr-demo/demo-schema.json new file mode 100644 index 0000000..0cf48b1 --- /dev/null +++ b/examples/pr-demo/demo-schema.json @@ -0,0 +1,41 @@ +{ + "mysqlVersion": "8.0.46", + "tables": [ + { + "name": "demo_order", + "engine": "InnoDB", + "charset": "utf8mb4", + "rowCountEstimate": 480000, + "columns": [ + { "name": "id", "type": "bigint", "nullable": false }, + { "name": "order_sn", "type": "varchar", "length": 32, "charset": "utf8mb4", "nullable": false }, + { "name": "shop_id", "type": "bigint", "nullable": false }, + { "name": "user_id", "type": "bigint", "nullable": false }, + { "name": "status", "type": "tinyint", "nullable": false }, + { "name": "delete_status", "type": "tinyint", "nullable": false }, + { "name": "receiver_name", "type": "varchar", "length": 64, "charset": "utf8mb4", "nullable": true }, + { "name": "amount", "type": "decimal", "nullable": false }, + { "name": "create_time", "type": "datetime", "nullable": true } + ], + "indexes": [ + { "name": "PRIMARY", "unique": true, "primary": true, "columns": ["id"], "subParts": [null] } + ] + }, + { + "name": "demo_order_detail", + "engine": "InnoDB", + "charset": "utf8mb4", + "rowCountEstimate": 1250000, + "columns": [ + { "name": "id", "type": "bigint", "nullable": false }, + { "name": "order_id", "type": "bigint", "nullable": false }, + { "name": "product_id", "type": "bigint", "nullable": false }, + { "name": "quantity", "type": "int", "nullable": false }, + { "name": "amount", "type": "decimal", "nullable": false } + ], + "indexes": [ + { "name": "PRIMARY", "unique": true, "primary": true, "columns": ["id"], "subParts": [null] } + ] + } + ] +}