-
Notifications
You must be signed in to change notification settings - Fork 800
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
Added a CI job for WPCloud testing of wpcomsh. #39258
Open
zinigor
wants to merge
22
commits into
trunk
Choose a base branch
from
add/wpcomsh-wpcloud-testing
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3a57a51
Added a CI job for WPCloud testing of wpcomsh.
zinigor 2ab2c4a
Add pnpm and install.
zinigor 0d40db9
Testing WPCloud on a new test site for jetpackisbestpack.
zinigor a8da4b4
Merge branch 'trunk' into add/wpcomsh-wpcloud-testing
zinigor a3a5533
Temporarily marking wpcomsh as always changed.
zinigor 8b74cdf
Merge branch 'trunk' into add/wpcomsh-wpcloud-testing
zinigor 4df8ed7
Added transferring of tests.
zinigor b102738
Added DB password slash escaping.
zinigor 27bbd07
changelog
zinigor aad27e3
Added a mock for get_option_and_ensure_autoload.
zinigor 9e892e4
Added a missing cache expulsion function.
zinigor dfb7439
Removed set -x from test installer.
zinigor bf302d5
Using pnpm to not bother with linking binaries.
zinigor 8f1f194
Added a build step.
zinigor df0ed81
Merge branch 'trunk' into add/wpcomsh-wpcloud-testing
zinigor 3618211
Created a separate job to avoid re-building on a re-run, h/t @anomiex.
zinigor 510482f
Added cache saving and restoring, moved if to parent job.
zinigor 747555d
Added the before file.
zinigor cdff320
Trying with instead of .
zinigor a60df09
Fixing var schema.
zinigor 4f4f451
Merge branch 'trunk' into add/wpcomsh-wpcloud-testing
zinigor f2ff12f
Merge branch 'trunk' into add/wpcomsh-wpcloud-testing
zinigor 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 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,142 @@ | ||||
name: WPCloud Unit Testing for WPCOMSH | ||||
|
||||
on: | ||||
pull_request: | ||||
push: | ||||
branches: ['trunk', '*/branch-*'] | ||||
concurrency: | ||||
group: wpcloud-${{ github.event_name }}-${{ github.ref }} | ||||
cancel-in-progress: true | ||||
|
||||
jobs: | ||||
build: | ||||
name: Install the Monorepo and build wpcomsh | ||||
runs-on: ubuntu-latest | ||||
outputs: | ||||
wpcomsh: ${{ steps.changed.outputs.wpcomsh }} | ||||
steps: | ||||
- uses: actions/checkout@v4 | ||||
with: | ||||
# codecov.io requires a fetch depth > 1. | ||||
fetch-depth: 2 | ||||
|
||||
# For pull requests, list-changed-projects.sh needs the merge base. | ||||
# But it doesn't have to be checked out. | ||||
- name: Deepen to merge base | ||||
if: github.event_name == 'pull_request' | ||||
uses: ./.github/actions/deepen-to-merge-base | ||||
with: | ||||
checkout: false | ||||
|
||||
- name: Setup tools | ||||
uses: ./.github/actions/tool-setup | ||||
with: | ||||
php: ${{ matrix.php }} | ||||
node: ${{ matrix.node }} | ||||
- name: Monorepo install | ||||
run: | | ||||
echo "::group::Pnpm" | ||||
pnpm install | ||||
echo "::endgroup::" | ||||
- name: Detect if wpcomsh has changed | ||||
id: changed | ||||
run: | | ||||
CHANGED="$(EXTRA=test .github/files/list-changed-projects.sh)" | ||||
|
||||
# WPCOMSH_CHANGED="$(jq --argjson changed "$CHANGED" -n '$changed | has( "plugins/wpcomsh" ) ')" | ||||
WPCOMSH_CHANGED="true" | ||||
echo "wpcomsh=${WPCOMSH_CHANGED}" >> "$GITHUB_OUTPUT" | ||||
- name: Build wpcomsh | ||||
if: steps.changed.outputs.wpcomsh == 'true' | ||||
run: | | ||||
find . -path ./.github -prune -o -type f -print | sort > /tmp/before.txt | ||||
echo "::group::Installing and building wpcomsh" | ||||
pnpm jetpack build -v --deps plugins/wpcomsh | ||||
echo "::endgroup::" | ||||
|
||||
# We only want to save the files that were actually created or changed. | ||||
# But we can't just list them for actions/cache/save, "Argument list too long". | ||||
# So instead we delete all the unchanged files so we can tell actions/cache/save | ||||
# to save everything that's left. | ||||
git -c core.quotepath=off diff --name-only | sort > /tmp/changed.txt | ||||
if [[ -s /tmp/changed.txt ]]; then | ||||
grep -F -x -v -f /tmp/changed.txt /tmp/before.txt > /tmp/remove.txt | ||||
else | ||||
cp /tmp/before.txt /tmp/remove.txt | ||||
fi | ||||
xargs -d '\n' rm < /tmp/remove.txt | ||||
find . -type d -empty -delete | ||||
|
||||
- name: Save wpcomsh build cache | ||||
if: steps.changed.outputs.wpcomsh == 'true' | ||||
id: wpcomsh-build-cache-save | ||||
uses: actions/cache/save@v4 | ||||
with: | ||||
path: | | ||||
. | ||||
!./.github/ | ||||
key: ${{ github.sha }} | ||||
deploy: | ||||
name: Run PHPUnit on the WPCloud test site | ||||
runs-on: ubuntu-latest | ||||
needs: build | ||||
if: needs.build.changed.outputs.wpcomsh == 'true' | ||||
steps: | ||||
- uses: actions/checkout@v4 | ||||
|
||||
- name: Restore wpcomsh build cache | ||||
id: wpcomsh-build-cache | ||||
if: needs.build.result == 'success' | ||||
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. I think we can leave out this line, it's there in the E2E workflow because the build might be skipped when it's going to run against Atomic or something.
Suggested change
|
||||
uses: actions/cache/restore@v4 | ||||
with: | ||||
path: | | ||||
. | ||||
!./.github/ | ||||
key: ${{ github.sha }} | ||||
fail-on-cache-miss: true | ||||
|
||||
- name: Setup tools | ||||
uses: ./.github/actions/tool-setup | ||||
|
||||
- name: Install monorepo | ||||
run: | | ||||
pnpm install | ||||
|
||||
- name: Configure Github to be able to SSH to the Atomic site | ||||
run: | | ||||
echo "::group::Intializing" | ||||
|
||||
mkdir -vp ~/.ssh/ | ||||
chmod -v 700 ~/.ssh | ||||
|
||||
touch ~/.ssh/id_site | ||||
touch ~/.ssh/known_hosts | ||||
chmod 600 ~/.ssh/id_site | ||||
chmod 600 ~/.ssh/known_hosts | ||||
echo "$SSH_KEY" > ~/.ssh/id_site | ||||
echo "wrote ~/.ssh/id_site" | ||||
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | ||||
echo "wrote ~/.ssh/known_hosts" | ||||
|
||||
echo "::endgroup::" | ||||
|
||||
echo "::group::Transferring wpcomsh to the testing server" | ||||
pnpm jetpack rsync wpcomsh [email protected]:~/htdocs/wp-content/mu-plugins | ||||
scp -r projects/plugins/wpcomsh/bin [email protected]:/srv/htdocs/wp-content/mu-plugins/wpcomsh | ||||
scp -r projects/plugins/wpcomsh/tests [email protected]:/srv/htdocs/wp-content/mu-plugins/wpcomsh/ | ||||
scp projects/plugins/wpcomsh/phpunit.xml.dist [email protected]:/srv/htdocs/wp-content/mu-plugins/wpcomsh/ | ||||
|
||||
echo "::engroup::" | ||||
|
||||
echo "::group::execution" | ||||
ssh -i ~/.ssh/id_site [email protected] "~/htdocs/github-action-handler.sh" || CODE=$? | ||||
echo "::endgroup::" | ||||
|
||||
echo "::group::teardown" | ||||
rm -rvf ~/.ssh/ | ||||
echo "::endgroup::" | ||||
echo "Exiting with exit code $CODE" | ||||
exit $CODE | ||||
env: | ||||
SSH_KEY: ${{ secrets.UPDATEJETPACKSTAGING_SSH_KEY }} | ||||
SSH_KNOWN_HOSTS: ${{ secrets.UPDATEJETPACKSTAGING_SSH_KNOWN_HOSTS }} |
This file contains 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
4 changes: 4 additions & 0 deletions
4
projects/plugins/wpcomsh/changelog/add-wpcomsh-wpcloud-testing
This file contains 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,4 @@ | ||
Significance: patch | ||
Type: fixed | ||
|
||
Fixed a database password escaping issue when installing tests. |
This file contains 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 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
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.
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.
Oops, this is why it skipped this time.