Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

gha: add workflow to run migrations#70

Merged
RaghavSood merged 5 commits into
mainfrom
chore/59
May 27, 2025
Merged

gha: add workflow to run migrations#70
RaghavSood merged 5 commits into
mainfrom
chore/59

Conversation

@RaghavSood

@RaghavSood RaghavSood commented May 27, 2025

Copy link
Copy Markdown
Contributor

Closes #69

Mirror the workflow on verifier repo to run migrations and test their consistency.

This only runs the DCA plugin binary, since any of them should be able to run the current migrations

We can expand this as we go deeper into plugin-specific db flows.

Summary by CodeRabbit

  • Chores
    • Introduced a new automated workflow to test database migrations and verify integrity using GitHub Actions. This ensures migrations run successfully and related tables are properly created.

Copilot AI review requested due to automatic review settings May 27, 2025 04:11
@coderabbitai

coderabbitai Bot commented May 27, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A new GitHub Actions workflow named "Migration Test" has been added. It sets up PostgreSQL and Redis services, checks out the code, prepares configuration, builds and runs a Go binary, verifies database migrations, and checks migration integrity, all within an automated CI environment triggered by push events.

Changes

File(s) Change Summary
.github/workflows/migration-test.yml Added a workflow for automated migration testing with PostgreSQL, Redis, Go setup, and validation

Poem

In the warren of code, a new test hops in,
With Postgres and Redis, the checks now begin.
Go builds a burrow, migrations take flight,
Tables are counted in the soft server light.
If all goes well, the carrots abound—
Success for the workflow, in CI it’s found!
🥕


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

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.

Pull Request Overview

Adds a new GitHub Actions workflow to verify database migrations by running the DCA plugin binary and checking both table creation and the Goose version table.

  • Introduces a migration-test job with Postgres and Redis services
  • Builds and runs the DCA binary against the test config
  • Validates that expected tables exist and that Goose migration records are present
Comments suppressed due to low confidence (2)

.github/workflows/migration-test.yml:98

  • [nitpick] This error message is generic. Including the DCA process exit code or logs would improve debuggability when migrations fail to start.
            echo "DCA process failed to start"

.github/workflows/migration-test.yml:50

  • The here-doc block is indented, which will include leading spaces in config.json and may break JSON parsing. Consider using <<-EOF or left-aligning the JSON content.
          cat > config.json <<EOF

Comment thread .github/workflows/migration-test.yml
Comment thread .github/workflows/migration-test.yml
Comment thread .github/workflows/migration-test.yml

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

♻️ Duplicate comments (3)
.github/workflows/migration-test.yml (3)

93-94: Avoid fixed sleep for migration completion.

Using sleep 10 can cause flakiness if migrations take a variable amount of time. Instead, implement a retry loop or health check that polls the database until the expected tables appear, with a timeout:

TIMEOUT=60
ELAPSED=0
until PGPASSWORD=${{ secrets.POSTGRES_PASSWORD }} \
      psql -h localhost -U ${{ secrets.POSTGRES_USER }} -d ${{ secrets.POSTGRES_DB }} \
      -c "\dt" | grep -q "plugin_policy"; do
  sleep 1
  ELAPSED=$((ELAPSED+1))
  if [ $ELAPSED -ge $TIMEOUT ]; then
    echo "Migrations did not complete within the timeout period"
    kill $DCA_PID
    exit 1
  fi
done

81-82: DRY up the LD_LIBRARY_PATH exports.

The LD_LIBRARY_PATH is exported twice. Consolidate this into an env: block at the job or step level:

jobs:
  migration-test:
    env:
      LD_LIBRARY_PATH: ../go-wrappers/includes/linux/:$LD_LIBRARY_PATH
    runs-on: ubuntu-latest
    services:
      # ...
    steps:
      - name: Build dca binary
        run: go build -o dca cmd/dca/*.go
      - name: Run dca and check migrations
        run: |
          export VS_CONFIG_NAME=config
          ./dca &
          # ...

Also applies to: 86-87


56-58: ⚠️ Potential issue

Use GitHub Actions secrets for the database DSN in config.json.

Embedding credentials directly in config.json risks exposure and complicates management. Refactor to template the DSN from secrets:

            "database": {
-            "dsn": "postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable"
+            "dsn": "${{ secrets.DB_DSN }}"
            }
🧰 Tools
🪛 Checkov (3.2.334)

[MEDIUM] 57-58: Basic Auth Credentials

(CKV_SECRET_4)

🧹 Nitpick comments (2)
.github/workflows/migration-test.yml (2)

44-47: Cache or vendor external dependencies instead of cloning.

Cloning go-wrappers on every run adds network overhead and risks rate limits. Consider:

  • Adding go-wrappers as a Git submodule
  • Using actions/checkout with path: go-wrappers
  • Leveraging actions/cache to cache the cloned repository
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 47-47: trailing spaces

(trailing-spaces)


9-9: Remove trailing whitespace and add newline at end of file.

Several lines contain trailing spaces, and the file is missing a final newline. Cleaning these will satisfy the YAML linter:

sed -i 's/[[:space:]]\+$//' .github/workflows/migration-test.yml
printf '\n' >> .github/workflows/migration-test.yml

Also applies to: 24-24, 34-34, 38-38, 43-43, 47-47, 78-78, 83-83, 88-88, 92-92, 95-95, 101-101, 109-109, 111-111, 114-114, 123-124

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 9-9: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92392f8 and ab81813.

📒 Files selected for processing (1)
  • .github/workflows/migration-test.yml (1 hunks)
🧰 Additional context used
🪛 Checkov (3.2.334)
.github/workflows/migration-test.yml

[MEDIUM] 57-58: Basic Auth Credentials

(CKV_SECRET_4)

🪛 YAMLlint (1.37.1)
.github/workflows/migration-test.yml

[error] 9-9: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)


[error] 34-34: trailing spaces

(trailing-spaces)


[error] 38-38: trailing spaces

(trailing-spaces)


[error] 43-43: trailing spaces

(trailing-spaces)


[error] 47-47: trailing spaces

(trailing-spaces)


[error] 78-78: trailing spaces

(trailing-spaces)


[error] 83-83: trailing spaces

(trailing-spaces)


[error] 88-88: trailing spaces

(trailing-spaces)


[error] 92-92: trailing spaces

(trailing-spaces)


[error] 95-95: trailing spaces

(trailing-spaces)


[error] 101-101: trailing spaces

(trailing-spaces)


[error] 109-109: trailing spaces

(trailing-spaces)


[error] 111-111: trailing spaces

(trailing-spaces)


[error] 114-114: trailing spaces

(trailing-spaces)


[error] 123-123: trailing spaces

(trailing-spaces)


[error] 124-124: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/migration-test.yml (1)

64-70: Verify block storage service availability.

The block_storage_config points to http://localhost:9000 (MinIO), but no corresponding service container is defined. If DCA requires S3-compatible storage during migrations, this will fail. Please confirm whether you intend to:

  • Add a MinIO service under services:
  • Mock or disable block storage in config.json for testing
  • Or adjust the workflow to handle block storage dependencies

Comment thread .github/workflows/migration-test.yml
Comment thread .github/workflows/migration-test.yml

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

♻️ Duplicate comments (3)
.github/workflows/migration-test.yml (3)

88-93: DRY up repeated LD_LIBRARY_PATH exports.
You export the same path in both build (line 88) and run (line 93) steps. Extract it into a shared env: block at the job or step level to eliminate duplication.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 90-90: trailing spaces

(trailing-spaces)


100-104: Replace fixed sleep with a polling loop.
A hardcoded sleep 10 may still be flaky under load. Use a retry loop that checks the DB (or a health endpoint) until migrations finish, as previously suggested.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 102-102: trailing spaces

(trailing-spaces)


124-129: Strengthen the migration integrity check.
Grep "[0-9]+" will match 0 and pass even if no migrations ran. Parse the count and assert it’s > 0:

count=$(PGPASSWORD=mypassword \
  psql -h localhost -U myuser -d vultisig-plugin -t -c "SELECT COUNT(*) FROM goose_db_version;" | xargs)
if [ "$count" -le 0 ]; then
  echo "No migrations applied; goose_db_version is empty"
  exit 1
fi
🧹 Nitpick comments (2)
.github/workflows/migration-test.yml (2)

48-58: Avoid duplicating DB credentials in the JSON config.
You’re re-stating the same Postgres credentials inside dca.json. Consider templating or referencing the service env vars to DRY this out.
Example diff:

- "dsn": "postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable"
+ "dsn": "${{ format('postgres://{0}:{1}@localhost:5432/{2}?sslmode=disable', env.POSTGRES_USER, env.POSTGRES_PASSWORD, env.POSTGRES_DB) }}"
🧰 Tools
🪛 Checkov (3.2.334)

[MEDIUM] 57-58: Basic Auth Credentials

(CKV_SECRET_4)


9-9: Remove trailing whitespace & add final newline.
YAMLlint flagged trailing spaces on multiple lines and a missing newline at EOF. Please trim all trailing spaces and ensure the file ends with a single newline.

Also applies to: 24-24, 34-34, 38-38, 43-43, 47-47, 85-85, 90-90, 95-95, 99-99, 102-102, 108-108, 116-116, 118-118, 121-121, 130-131

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 9-9: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab81813 and d32cee0.

📒 Files selected for processing (1)
  • .github/workflows/migration-test.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: RaghavSood
PR: vultisig/plugin#70
File: .github/workflows/migration-test.yml:14-17
Timestamp: 2025-05-27T04:28:20.394Z
Learning: In GitHub Actions workflows for testing, hardcoded database credentials are acceptable when using ephemeral test services (like PostgreSQL containers) that only exist during the CI run, as there's no security risk with temporary test environments.
.github/workflows/migration-test.yml (1)
Learnt from: RaghavSood
PR: vultisig/plugin#70
File: .github/workflows/migration-test.yml:14-17
Timestamp: 2025-05-27T04:28:20.394Z
Learning: In GitHub Actions workflows for testing, hardcoded database credentials are acceptable when using ephemeral test services (like PostgreSQL containers) that only exist during the CI run, as there's no security risk with temporary test environments.
🪛 Checkov (3.2.334)
.github/workflows/migration-test.yml

[MEDIUM] 57-58: Basic Auth Credentials

(CKV_SECRET_4)

🪛 YAMLlint (1.37.1)
.github/workflows/migration-test.yml

[error] 9-9: trailing spaces

(trailing-spaces)


[error] 24-24: trailing spaces

(trailing-spaces)


[error] 34-34: trailing spaces

(trailing-spaces)


[error] 38-38: trailing spaces

(trailing-spaces)


[error] 43-43: trailing spaces

(trailing-spaces)


[error] 47-47: trailing spaces

(trailing-spaces)


[error] 85-85: trailing spaces

(trailing-spaces)


[error] 90-90: trailing spaces

(trailing-spaces)


[error] 95-95: trailing spaces

(trailing-spaces)


[error] 99-99: trailing spaces

(trailing-spaces)


[error] 102-102: trailing spaces

(trailing-spaces)


[error] 108-108: trailing spaces

(trailing-spaces)


[error] 116-116: trailing spaces

(trailing-spaces)


[error] 118-118: trailing spaces

(trailing-spaces)


[error] 121-121: trailing spaces

(trailing-spaces)


[error] 130-130: trailing spaces

(trailing-spaces)


[error] 131-131: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (3)
.github/workflows/migration-test.yml (3)

1-5: Workflow definition looks solid.
The new “Migration Test” workflow is correctly configured to trigger on push events and lays out the migration verification steps as intended.


6-9: Standard jobs and runs-on configuration; no issues detected.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 9-9: trailing spaces

(trailing-spaces)


14-17: Hardcoded credentials are acceptable in this CI context.
Per our ephemeral-test-services guideline, embedding myuser/mypassword/vultisig-plugin here does not introduce a security risk.

@johnnyluo johnnyluo left a comment

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.

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GHA for migrations

3 participants