Repository navigation
refactor: run shell commands through Utopia\Command - #13616
Conversation
|
| $copy = (new Command('docker')) | ||
| ->argument('run') | ||
| ->flag('--rm') | ||
| ->option('-v', $source . ':/from:ro') | ||
| ->option('-v', $target . ':/to') | ||
| ->argument($image) | ||
| ->argument('sh') | ||
| ->option( | ||
| '-c', | ||
| 'cd /from && find . -type f | while read -r file; do' | ||
| . ' size=$(stat -c %s "$file");' | ||
| . ' [ "$(stat -c %s "/to/$file" 2>/dev/null)" = "$size" ] ||' | ||
| . ' { mkdir -p "/to/$(dirname "$file")" && cp -a "$file" "/to/$file"; };' | ||
| . ' [ "$(stat -c %s "/to/$file" 2>/dev/null)" = "$size" ] || echo "$file"; done' | ||
| ), | ||
| '', | ||
| $stdout, | ||
| $stderr | ||
| ); | ||
| ); | ||
| $exit = Console::execute($copy, '', $stdout, $stderr); |
There was a problem hiding this comment.
Artifact migration lacks coverage
This refactors the critical build-volume copy path, including two volume mounts and an embedded sh -c program, without an observable regression test. Add a behavioral test that populates a legacy volume, runs the migration, and verifies the target files and retry behavior. An assertion against the rendered command would be implementation-coupled and would not protect artifact recovery.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Migration/Infrastructure/Version/V1.php
Line: 118-133
Comment:
**Artifact migration lacks coverage**
This refactors the critical build-volume copy path, including two volume mounts and an embedded `sh -c` program, without an observable regression test. Add a behavioral test that populates a legacy volume, runs the migration, and verifies the target files and retry behavior. An assertion against the rendered command would be implementation-coupled and would not protect artifact recovery.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
6d56740 to
c9aeb06
Compare
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
4f40828 to
0a2e591
Compare
Bump utopia-php/console to ^0.2 and build every locally composed shell command with Utopia\Command instead of concatenating escaped strings. Plain commands now reach proc_open as an argument array (no shell), and the one composite chain (the template commit-and-push in the builds worker) is rendered by the library with every argument escaped. Migrated call sites: - src/Appwrite/Certificates/LetsEncrypt.php: certbot issuance - src/Appwrite/Platform/Modules/Functions/Workers/Builds.php: mkdir, mv, rsync, git config/checkout/add/commit/push chain, git rev-parse, rm - src/Appwrite/Migration/Infrastructure/Version/V1.php: docker volume ls and the two docker run invocations that count and copy build artifacts - tests/e2e: every tar packaging helper, docker exec/inspect/logs and the mkdir in the empty-site test The two git clone commands in the builds worker are left as strings because utopia-php/vcs still returns them as such. utopia-php/database is bumped to 7.3.8, the first release that accepts console 0.2. Supersedes #11937 by @TorstenDittmann. Co-Authored-By: Claude Fable 5.1 <[email protected]>
0a2e591 to
d7ecbaf
Compare
Summary
Supersedes #11937 by @TorstenDittmann, re-applied on current
mainagainst the releasedutopia-php/console0.2.9.utopia-php/consoleto^0.2andutopia-php/databaseto^7.3.8(the first database release that accepts console 0.2, chore: allow utopia-php/console 0.2 utopia-php/database#965).Utopia\Commandinstead of concatenating escaped strings. Plain commands reachproc_openas an argument array with no shell; the one composite chain (the template commit-and-push in the builds worker) is rendered by the library with every argument escaped.Migrated call sites:
src/Appwrite/Certificates/LetsEncrypt.php: certbot issuancesrc/Appwrite/Platform/Modules/Functions/Workers/Builds.php: mkdir, mv, rsync, the git config/checkout/add/commit/push chain, git rev-parse, rmsrc/Appwrite/Migration/Infrastructure/Version/V1.php: docker volume ls and the two docker run invocations that count and copy build artifactstests/e2e: every tar packaging helper, docker exec/inspect/logs, and the mkdir in the empty-site testThe two git clone commands in the builds worker stay as strings because
utopia-php/vcsstill returns them that way.Testing
Functions/FunctionsConsoleClientTest --filter=testFunctionDeploymentRetentionWithMaintenanceSites/SitesConsoleClientTest --filter=testSiteDeploymentRetentionWithMaintenanceFunctions/FunctionsCustomServerTest --filter=testCreateFunctionAndDeploymentFromTemplate(+ Branch, Commit)Functions/FunctionsCustomServerTest --filter=testCreateDeploymentLargeSites/SitesCustomServerTest --filter=testEmptySiteSourceProjectWebhooks/WebhooksCustomServerTest --filter=testCreateDeployment🤖 Generated with Claude Code