{"id":15178941,"url":"https://github.com/macbre/actions-index-digest","last_synced_at":"2025-04-22T16:30:51.204Z","repository":{"id":48480791,"uuid":"336324168","full_name":"macbre/actions-index-digest","owner":"macbre","description":"GitHub Actions for index-digest - database performance regression testing","archived":false,"fork":false,"pushed_at":"2022-09-19T14:24:56.000Z","size":272,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T20:18:02.852Z","etag":null,"topics":["database-perfomance","mysql-database","performance","regression-testing","slow-queries"],"latest_commit_sha":null,"homepage":"https://github.com/macbre/index-digest","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/macbre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-05T16:20:19.000Z","updated_at":"2024-01-08T15:31:06.000Z","dependencies_parsed_at":"2023-01-18T14:30:30.847Z","dependency_job_id":null,"html_url":"https://github.com/macbre/actions-index-digest","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Factions-index-digest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Factions-index-digest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Factions-index-digest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macbre%2Factions-index-digest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macbre","download_url":"https://codeload.github.com/macbre/actions-index-digest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250277050,"owners_count":21403979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-perfomance","mysql-database","performance","regression-testing","slow-queries"],"created_at":"2024-09-27T15:42:31.926Z","updated_at":"2025-04-22T16:30:50.935Z","avatar_url":"https://github.com/macbre.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# index-digest action for database performance regression testing\n\n![actions_output](https://user-images.githubusercontent.com/1929317/107210174-12a2ba80-6a04-11eb-9958-f127521a03d8.png)\n\nGitHub Action for running [`index-digest`](https://github.com/macbre/index-digest) that **analyses your MySQL queries and schema** and suggests indices and schema improvements.\n\nWith this Action you can easily **implement database performance regression testing in your continuos integration pipeline**.\n\nTake a look at [what does `index-digest` check](https://github.com/macbre/index-digest#checks).\n\n## How to use it\n\nWe assume that you have a MySQL up and running in your CI pipeline. Your tests suite runs using this database and SQL queries log is collected.\n\nGiven your MySQL test instance (and the optional SQL queries log) you can simply add this Action to your pipeline:\n\n```yaml\n    - name: Install and run index-digest\n      id: run-index-digest\n      uses: macbre/actions-index-digest@0.9.0\n      with:\n        index-digest-version: \"1.5.0\"  # or \"latest\" if you wish use the master version\n        index-digest-dsn: \"mysql://test_user:test_password@127.0.0.1:3306/test_db\"\n        index-digest-report-file: \"./report.yml\"\n```\n\n\u003e Here we assume that MySQL uses `test_user` with `test_password` credential for `test_db` database. And that the MySQL server runs locally listening on a default port (3306).\n\n`index-digest` image will be fetched and run with the provided options. The YAML report file will be stored in the location specified by `index-digest-report-file`. You can use it for additional assertions and to raise an error in your CI pipeline if there's something wrong.\n\n\u003e **Read more on medium.com** - [Using Continuous Integration pipeline to guard against database performance regressions\n](https://medium.com/bethink-pl/using-continuous-integration-pipeline-to-guard-against-database-performance-regressions-d50f3c79278a)\n\n### Asserting on issues reported\n\nYou can make the action fail if there are issues reported by index-digest. Simply add `fail-on-issues: true` option to `with` context when calling the action.\n\n```yaml\n      with:\n        # ...\n        fail-on-issues: true\n```\n\n\nAnd you'll get something similar to:\n\n![Assertion](https://raw.githubusercontent.com/macbre/actions-index-digest/main/graphics/index-digest-failed.png)\n\nAnd GitHub Actions will log these warnings and errors:\n\n![Assertion](https://raw.githubusercontent.com/macbre/actions-index-digest/main/graphics/aff22da.png)\n\n## An example result file\n\n```yaml\n---\nmeta:\n  version: index-digest v1.5.0\n  database_name: index_digest\n  database_host: eeae7273a00a\n  database_version: MySQL v8.0.22\nreports:\n- type: redundant_indices\n  table: 0001_redundant_indices\n  message: '\"idx_foo\" index can be removed as redundant (covered by \"idx_foo_2\")'\n  context:\n    redundant: UNIQUE KEY idx_foo (foo)\n    covered_by: UNIQUE KEY idx_foo_2 (foo)\n    schema: \"CREATE TABLE `0001_redundant_indices` (\\n  `item_id` int NOT NULL AUTO_INCREMENT,\\n\\\n      \\  `foo` varbinary(16) NOT NULL DEFAULT '',\\n  PRIMARY KEY (`item_id`),\\n  UNIQUE\\\n      \\ KEY `idx_foo` (`foo`),\\n  UNIQUE KEY `idx_foo_2` (`foo`)\\n) ENGINE=InnoDB\\\n      \\ DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci\"\n    table_data_size_mb: 0.015625\n    table_index_size_mb: 0.03125\n...\n```\n\n## Getting SQL query log\n\nThe problem of collecting SQL query logs from your application can be approached from several different perspectives.\n\n1. You can tell your application / framework to collect the logs for you.\n2. Your legacy software or your framework does not allow you to get the log? Then you can instruct your MySQL instance to collect SQL queries log for you.\n\nIn this example we assume that you use Docker Compose to set up your CI environment on GitHub Actions. And that you have `mysql-ci` service defined there. Simply set up [the slow query log]( https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html) for it:\n\n```yaml\n  mysql-ci:\n    image: mysql:8.0.22\n    command: --default-authentication-plugin=mysql_native_password\n    # enable slow query log for performance regression checks\n    # https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html\n    command: \u003e-\n      --default-authentication-plugin=mysql_native_password\n      --slow-query-log=1\n      --slow-query-log-file=/tmp/log/slow_query.log\n      --long-query-time=0\n    volumes:\n      # if not existing, Docker will create a directory\n      - \"/tmp/log:/tmp/log\"\n```\n\nYou will then have **all queries** (not only slow ones - see `--long-query-time` option value) logged in `/tmp/log/slow_query.log` file that will be exposed in you host filesystem on GitHub Actions.\n\nThen, having a slow query log, all you need to do is parse it with [`pt-query-digest`](https://www.percona.com/doc/percona-toolkit/LATEST/pt-query-digest.html) and get the list of unique SQL queries:\n\n```\npt-query-digest /tmp/log/slow_query.log --limit=1000 --output json | jq .classes[].example.query | sed 's/\\\\n/ /g'| jq -r . \u003e /tmp/log.sql\n```\n\nAnd then run the action:\n\n```yaml\n    - name: Install and run index-digest\n      uses: macbre/actions-index-digest@0.9.0\n      with:\n        index-digest-version: \"1.5.0\"\n        index-digest-dsn: \"mysql://test_user:test_password@127.0.0.1:3306/test_db\"\n        index-digest-sql-log: \"/tmp/log.sql\"  # use an absolute path here!\n        index-digest-report-file: \"./report.yml\"\n```\n\n\u003e Please note that `index-digest-sql-log` **needs to be provided with an absolute path**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacbre%2Factions-index-digest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacbre%2Factions-index-digest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacbre%2Factions-index-digest/lists"}