-
Notifications
You must be signed in to change notification settings - Fork 3
ci: exercise migrations against MySQL and PostgreSQL #1629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cae2458
8d332d0
253b981
beddd86
3d1c593
2806760
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,6 +136,98 @@ jobs: | |
| run: | | ||
| npm run test | ||
|
|
||
| tests-migrations: | ||
| name: Test Migrations | ||
| needs: [build] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| service: [ server-core, server-storage, server-telemetry ] | ||
| db: [ mysql, postgres ] | ||
| include: | ||
| - db: mysql | ||
| port: 3306 | ||
| user: root | ||
| - db: postgres | ||
| port: 5432 | ||
| user: postgres | ||
|
|
||
| env: | ||
| DB_TYPE: ${{ matrix.db }} | ||
| DB_HOST: 127.0.0.1 | ||
| DB_PORT: ${{ matrix.port }} | ||
| DB_USERNAME: ${{ matrix.user }} | ||
| DB_PASSWORD: start123 | ||
| DB_DATABASE: app | ||
|
|
||
| services: | ||
| mysql: | ||
| image: mysql:9 | ||
| env: | ||
| MYSQL_ROOT_PASSWORD: start123 | ||
| ports: | ||
| - 3306:3306 | ||
| options: >- | ||
| --health-cmd="mysqladmin ping -h localhost -pstart123" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=5 | ||
|
|
||
| postgres: | ||
| image: postgres:18 | ||
| env: | ||
| POSTGRES_PASSWORD: start123 | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd="pg_isready -U postgres" | ||
| --health-interval=10s | ||
| --health-timeout=5s | ||
| --health-retries=5 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
Comment on lines
+191
to
+192
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/main.yml | sed -n '160,175p'Repository: PrivateAIM/hub Length of output: 654 🌐 Web query:
💡 Result: Pinning GitHub Actions to a full-length commit SHA is considered the industry standard for supply chain security [1][2][3]. Unlike version tags (e.g., Citations:
🌐 Web query:
💡 Result: Setting Citations:
Harden checkout: pin to a commit SHA and disable credential persistence. Using a floating action tag ( Suggested hardening- - name: Checkout
- uses: actions/checkout@v6
+ - name: Checkout
+ uses: actions/checkout@<pinned_commit_sha_for_v6>
+ with:
+ persist-credentials: false🧰 Tools🪛 zizmor (1.25.2)[warning] 166-167: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) [error] 167-167: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Install | ||
| uses: ./.github/actions/install | ||
| with: | ||
| node-version: ${{ env.NODE_VERSION }} | ||
| node-registry: ${{ env.NODE_REGISTRY }} | ||
|
|
||
| - name: Build | ||
| uses: ./.github/actions/build | ||
|
|
||
| - name: Verify compiled migrations exist | ||
| working-directory: apps/${{ matrix.service }} | ||
| run: | | ||
| shopt -s nullglob | ||
| files=(dist/adapters/database/migrations/${{ matrix.db }}/*.mjs) | ||
| count=${#files[@]} | ||
| if [ "$count" = "0" ]; then | ||
| echo "ERROR: no compiled migrations in apps/${{ matrix.service }}/dist/adapters/database/migrations/${{ matrix.db }}/" | ||
| exit 1 | ||
| fi | ||
| echo "Found $count migration(s)" | ||
| echo "MIGRATION_COUNT=$count" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Run migrations forward | ||
| working-directory: apps/${{ matrix.service }} | ||
| run: node dist/cli/index.mjs migration run | ||
|
|
||
| - name: Revert all migrations | ||
| working-directory: apps/${{ matrix.service }} | ||
| run: | | ||
| for ((i = 1; i <= MIGRATION_COUNT; i++)); do | ||
| node dist/cli/index.mjs migration revert | ||
| done | ||
|
|
||
| - name: Re-apply all migrations (idempotency) | ||
| working-directory: apps/${{ matrix.service }} | ||
| run: node dist/cli/index.mjs migration run | ||
|
|
||
| lint: | ||
| needs: [build] | ||
| runs-on: ubuntu-latest | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: PrivateAIM/hub
Length of output: 229
🏁 Script executed:
fd "main.yml" .github/workflows/Repository: PrivateAIM/hub
Length of output: 85
🏁 Script executed:
Repository: PrivateAIM/hub
Length of output: 1349
🏁 Script executed:
Repository: PrivateAIM/hub
Length of output: 3149
Add explicit least-privilege
permissionsfortests-migrations.This job currently inherits default token permissions. Set an explicit minimal block with
contents: readto avoid accidental over-privilege drift. The job only requires repository read access for the checkout step.Suggested hardening
🧰 Tools
🪛 zizmor (1.25.2)
[warning] 139-213: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents