Social: Fix SIG preview infinite spinner when default image is deleted #29626
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
| name: WP Cloud Unit Testing for WPCOMSH | |
| on: | |
| pull_request: | |
| push: | |
| branches: ['trunk', '*/branch-*'] | |
| concurrency: | |
| group: wpcloud-wpcomsh | |
| cancel-in-progress: false | |
| # Concurrency is set up to make sure we can only run one WP Cloud testing job at the same time. | |
| permissions: | |
| # actions/checkout, actions/upload-artifact, actions/download-artifact | |
| contents: read | |
| jobs: | |
| build: | |
| name: Install the Monorepo and build wpcomsh | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name | |
| outputs: | |
| wpcomsh: ${{ steps.changed.outputs.wpcomsh }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # 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: | |
| # Match PHP version on WP Cloud so the right vendor packages get installed. | |
| php: 8.3 | |
| - 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" ) ')" | |
| echo "wpcomsh=${WPCOMSH_CHANGED}" >> "$GITHUB_OUTPUT" | |
| - name: Build wpcomsh | |
| if: steps.changed.outputs.wpcomsh == 'true' | |
| run: | | |
| echo "::group::Installing and building wpcomsh" | |
| rm projects/plugins/wpcomsh/composer.lock | |
| pnpm jetpack build -v --deps plugins/wpcomsh | |
| echo "::endgroup::" | |
| echo "::group::Preparing artifact" | |
| pnpm jetpack rsync -v --non-interactive wpcomsh /tmp/wpcomsh | |
| cp -a projects/plugins/wpcomsh/bin /tmp/wpcomsh | |
| cp -a projects/plugins/wpcomsh/tests /tmp/wpcomsh | |
| # The test on WP Cloud won't use `phpunit-select-config`, so select config manually. | |
| cp -aL projects/plugins/wpcomsh/phpunit.12.xml.dist /tmp/wpcomsh/phpunit.xml.dist | |
| tar -cvvf wpcomsh.tar.xz -C /tmp/ wpcomsh | |
| echo "::endgroup::" | |
| - name: Store artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| path: wpcomsh.tar.xz | |
| retention-days: 1 | |
| # Already compressed. | |
| compression-level: 0 | |
| archive: false | |
| deploy: | |
| name: Run PHPUnit on the WP Cloud test site | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: needs.build.outputs.wpcomsh == 'true' | |
| steps: | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: wpcomsh.tar.xz | |
| - name: Configure Github to be able to SSH to the WP Cloud site | |
| run: | | |
| echo "::group::Initializing" | |
| mkdir -vp ~/.ssh/ | |
| chmod -v 700 ~/.ssh | |
| touch ~/.ssh/id_site | |
| touch ~/.ssh/known_hosts | |
| touch ~/.ssh/config | |
| chmod 600 ~/.ssh/id_site | |
| chmod 600 ~/.ssh/known_hosts | |
| chmod 600 ~/.ssh/config | |
| echo "$SSH_KEY" > ~/.ssh/id_site | |
| echo "wrote ~/.ssh/id_site" | |
| echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | |
| echo "wrote ~/.ssh/known_hosts" | |
| echo "Host jpwpcomsh" > ~/.ssh/config | |
| echo " Hostname sftp.wp.com" >> ~/.ssh/config | |
| echo " User wpcom-jetpackisbestpack-default-237778992" >> ~/.ssh/config | |
| echo " IdentityFile ~/.ssh/id_site" >> ~/.ssh/config | |
| echo " IdentitiesOnly yes" >> ~/.ssh/config | |
| echo "::endgroup::" | |
| echo "::group::Extract wpcomsh build" | |
| tar -xvvf wpcomsh.tar.xz wpcomsh | |
| echo "::endgroup::" | |
| echo "::group::Transferring wpcomsh to the testing server" | |
| # This can give errors if the previous state was broken, so ignore them | |
| ssh jpwpcomsh "wp --skip-plugins --skip-themes dereferenced freshen > /dev/null 2>&1" || echo "wp dereferenced freshen has exited with code $?" | |
| ssh jpwpcomsh "rm -rf /tmp/old-* > /dev/null 2>&1" | |
| rsync -azKPv --prune-empty-dirs --delete --delete-after --delete-excluded --copy-links wpcomsh/. jpwpcomsh:/srv/htdocs/wp-content/mu-plugins/wpcomsh/. | |
| echo "::endgroup::" | |
| # Do a basic check to verify the site is loading | |
| echo "::group::Verify things load" | |
| CODE=0 | |
| SITE_URL=$(ssh jpwpcomsh "wp option get siteurl" 2>/dev/null) || CODE=$? | |
| if [[ $CODE -ne 0 ]]; then | |
| echo 'Unable to run a basic `wp` command! Something is wrong with the site.' | |
| elif [[ ! "$SITE_URL" =~ ^https?://[a-z0-9_.-]+$ ]]; then | |
| echo 'Site URL retrieved does not seem to be a URL.' | |
| CODE=1 | |
| else | |
| echo 'No issues using a simple command in WP-CLI.' | |
| curl -s --fail "$SITE_URL" > /dev/null || CODE=$? | |
| if [[ $CODE -ne 0 ]]; then | |
| echo 'Unable to load site! Something is wrong with the site.' | |
| else | |
| echo 'No issues slurping site with `curl`.' | |
| fi | |
| fi | |
| echo "::endgroup::" | |
| # Proceed with tests if all seems well | |
| if [[ $CODE -eq 0 ]]; then | |
| echo "::group::Run PHPUnit tests" | |
| ssh jpwpcomsh "/srv/htdocs/wp-content/mu-plugins/wpcomsh/bin/run-phpunit-tests.sh" || CODE=$? | |
| echo "::endgroup::" | |
| fi | |
| 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 }} |