-
Notifications
You must be signed in to change notification settings - Fork 0
WEB-11226: Add worktree-isolated test flow to shared make helpers #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
|
|
||
| name: Test | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| make-helpers: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| with: | ||
| persist-credentials: false | ||
| - name: php_tests_worktree | ||
| run: ./test/php_tests_worktree.sh | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/bin/sh | ||
| # | ||
| # Verifies the `php_tests_worktree` make target by inspecting the commands it | ||
| # would run (`make -n`), so it needs only `make` — no Docker. Checks that the | ||
| # flow reuses the already-running services, isolates the database per worktree, | ||
| # runs against the worktree's source, and handles composer/vendor drift. | ||
|
|
||
| set -eu | ||
|
|
||
| repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) | ||
| worktree=/tmp/wt-fixture-test | ||
|
|
||
| if ! rendered=$(make -n \ | ||
| -f "$repo_root/docker.mk" \ | ||
| -f "$repo_root/php.mk" \ | ||
| php_tests_worktree WORKTREE="$worktree" 2>&1); then | ||
| echo "FAIL: 'make -n php_tests_worktree' errored:" >&2 | ||
| printf '%s\n' "$rendered" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "rendered commands:" | ||
| printf '%s\n' "$rendered" | sed 's/^/ | /' | ||
| echo | ||
|
|
||
| failures=0 | ||
|
|
||
| expect() { # description, fixed-string | ||
| if printf '%s\n' "$rendered" | grep -qF -- "$2"; then | ||
| echo "ok - $1" | ||
| else | ||
| echo "FAIL - $1 (expected to find: $2)" | ||
| failures=$((failures + 1)) | ||
| fi | ||
| } | ||
|
|
||
| refute() { # description, fixed-string | ||
| if printf '%s\n' "$rendered" | grep -qF -- "$2"; then | ||
| echo "FAIL - $1 (did not expect: $2)" | ||
| failures=$((failures + 1)) | ||
| else | ||
| echo "ok - $1" | ||
| fi | ||
| } | ||
|
|
||
| # AC1 — runs against the specified worktree's code, and runs the suite | ||
| expect "mounts the worktree source" "$worktree" | ||
| expect "runs the selected test suite" "vendor/bin/phpunit" | ||
| # AC2 — per-worktree database isolation (sanitised basename + hash of full path) | ||
| expect "isolates the database per worktree" "DB_DATABASE=test_wt_fixture_test_3943437479" | ||
| # AC3 — reuses the already-running services, no duplicate full stack | ||
| expect "reuses running services (--no-deps)" "--no-deps" | ||
| refute "does not start a full stack (up)" "up --abort-on-container-exit" | ||
| # AC4 — composer/vendor drift handled | ||
| expect "compares composer.lock for drift" "composer.lock" | ||
| expect "installs dependencies on drift" "composer install" | ||
|
|
||
| echo | ||
| if [ "$failures" -ne 0 ]; then | ||
| echo "php_tests_worktree: $failures assertion(s) FAILED" | ||
| exit 1 | ||
| fi | ||
| echo "php_tests_worktree: all assertions passed" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.