Skip to content

Commit

Permalink
Merge pull request #2 from macbre/index-digest-dsn
Browse files Browse the repository at this point in the history
Add index-digest-dsn option
  • Loading branch information
macbre authored Feb 8, 2021
2 parents 3d78b33 + 3d2f03c commit 78de1ef
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,38 @@ jobs:
- "1.4.0"
- "latest"

services:
# https://hub.docker.com/_/mysql
database:
image: "mysql:8.0.22"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: index_digest
ports:
- "3310:3306" # will be listening on 3310 host port
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v2

- name: Import test schema into the database
run: |
mysql --host=127.0.0.1 --port=3310 --user=root --database=index_digest < ./sql/0000_setup.sql
echo -e "[client]\nuser=digest\npassword=s3cr3t\n" > ~/.my.cnf
mysql --host=127.0.0.1 --port=3310 --user=digest --database=index_digest < ./sql/0001_redundant_indices.sql
mysql --host=127.0.0.1 --port=3310 --user=digest --database=index_digest --execute="SHOW TABLES"
# docker run --network=host -t macbre/index-digest:latest mysql://index_digest:qwerty@debian/index_digest | head -n 20
- name: Run an action
uses: ./
with:
index-digest-version: ${{ matrix.index-digest-version }}
index-digest-dsn: "mysql://digest:s3cr3t@127.0.0.1:3310/index_digest"
index-digest-report-file: "./report.yml"

- name: Check the version and the output file
run: |
docker run -t macbre/index-digest:${{ matrix.index-digest-version }} --version
cat ./report.yml
- name: Check the version
run: docker run -t macbre/index-digest:${{ matrix.index-digest-version }} --version
24 changes: 21 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ inputs:
description: "The version of index-digest to install"
required: true
default: "1.4.0"

index-digest-dsn:
description: "DSN pointing at the database to check"
require: true

index-digest-checks:
description: "Which index-digest checks to perform"
require: true
default: "redundant_indices,missing_primary_index,not_used_indices,queries_not_using_index,queries_using_filesort,queries_using_temporary,queries_using_full_table_scan"

index-digest-report-file:
description: "Where to save YAML report file"
required: true
default: "/tmp/index-digest.yml"

runs:
using: "composite"
steps:
Expand All @@ -19,6 +34,9 @@ runs:
echo "Using index-version v${{ inputs.index-digest-version }} ..."
docker pull macbre/index-digest:${{ inputs.index-digest-version }}
# - shell: bash
# # run: docker run --network=host -t macbre/index-digest:latest mysql://index_digest:qwerty@debian/index_digest | head -n 20
# run: docker run --network=host -t macbre/index-digest:${{ inputs.index-digest-version }} --version
- shell: bash
run: |
docker run --network=host -t macbre/index-digest:${{ inputs.index-digest-version }} \
--checks=${{ inputs.index-digest-checks }} \
--format=yaml \
${{ inputs.index-digest-dsn }} | tee ${{ inputs.index-digest-report-file }}
6 changes: 6 additions & 0 deletions sql/0000_setup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- create a test user and grant access to our database
-- "mysql_native_password" used to fix "Plugin caching_sha2_password could not be loaded" issue
CREATE USER 'digest'@'%' IDENTIFIED WITH mysql_native_password BY 's3cr3t';

GRANT ALL ON index_digest.* TO 'digest'@'%';

7 changes: 7 additions & 0 deletions sql/0001_redundant_indices.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE `0001_redundant_indices` (
`item_id` int(9) NOT NULL AUTO_INCREMENT,
`foo` varbinary(16) NOT NULL DEFAULT '',
PRIMARY KEY (`item_id`),
UNIQUE KEY `idx_foo` (`foo`),
UNIQUE KEY `idx_foo_2` (`foo`)
);

0 comments on commit 78de1ef

Please sign in to comment.