diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 34d2461..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,62 +0,0 @@ -version: 2 -workflows: - version: 2 - main: - jobs: - - test-behat - nightly: - triggers: - - schedule: - cron: "0 0 * * *" - filters: - branches: - only: - - main - jobs: - - test-behat -jobs: - test-behat: - working_directory: ~/pantheon-systems/pantheon-hud - parallelism: 1 - docker: - - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2 - steps: - - checkout - - restore_cache: - keys: - - test-behat-dependencies-{{ checksum "composer.json" }} - - run: composer install -n --prefer-dist - - save_cache: - key: test-behat-dependencies-{{ checksum "composer.json" }} - paths: - - vendor - - run: echo $(openssl rand -hex 8) > /tmp/WORDPRESS_ADMIN_PASSWORD - - run: | - echo 'export TERMINUS_ENV=ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV - echo 'export TERMINUS_SITE=pantheon-hud' >> $BASH_ENV - echo 'export SITE_ENV=pantheon-hud.ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV - echo 'export WORDPRESS_ADMIN_USERNAME=pantheon' >> $BASH_ENV - echo 'export WORDPRESS_ADMIN_EMAIL=no-reply@getpantheon.com' >> $BASH_ENV - echo 'export WORDPRESS_ADMIN_PASSWORD=$(cat /tmp/WORDPRESS_ADMIN_PASSWORD)' >> $BASH_ENV - source $BASH_ENV - - run: echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config" - - run: | - if [ -z "$GITHUB_TOKEN" ]; then - echo "GITHUB_TOKEN environment variables missing; assuming unauthenticated build" - exit 0 - fi - echo "Setting GitHub OAuth token with suppressed ouput" - { - composer config -g github-oauth.github.com $GITHUB_TOKEN - } &> /dev/null - - run: | - if [ -z "$TERMINUS_TOKEN" ]; then - echo "TERMINUS_TOKEN environment variables missing; assuming unauthenticated build" - exit 0 - fi - terminus auth:login --machine-token=$TERMINUS_TOKEN - - run: ./bin/behat-prepare.sh - - run: ./bin/behat-test.sh --strict - - run: - command: ./bin/behat-cleanup.sh - when: always diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 133f78a..6a6c672 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -19,6 +19,7 @@ jobs: steps: - uses: pantheon-systems/action-wporg-validator@v2.0.0 with: + path: ./plugin type: 'plugin' validate-readme-spacing: name: Validate README Spacing diff --git a/.github/workflows/test-behat.yml b/.github/workflows/test-behat.yml new file mode 100644 index 0000000..1ef114b --- /dev/null +++ b/.github/workflows/test-behat.yml @@ -0,0 +1,100 @@ +name: Test Behat CI + +on: + pull_request: + workflow_dispatch: + # Nightly at 00:00 UTC + schedule: + - cron: "0 0 * * *" + +jobs: + test-behat: + # Skip scheduled runs unless the workflow file is on a branch named 'release' + if: github.event_name != 'schedule' || github.ref_name == 'release' + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + working-directory: . + + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + composer install -n --prefer-dist + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + tools: composer + coverage: none + extensions: mbstring, intl, zip + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/vendor + key: test-lint-dependencies-{{ checksum "composer.json" }} + restore-keys: test-lint-dependencies-{{ checksum "composer.json" }} + + - name: Generate WP admin password + run: echo "$(openssl rand -hex 8)" > /tmp/WORDPRESS_ADMIN_PASSWORD + + - name: Export environment + run: | + echo "TERMINUS_ENV=ci-${GITHUB_RUN_NUMBER}" >> "$GITHUB_ENV" + echo "TERMINUS_SITE=pantheon-hud" >> "$GITHUB_ENV" + echo "SITE_ENV=pantheon-hud.ci-${GITHUB_RUN_NUMBER}" >> "$GITHUB_ENV" + echo "WORDPRESS_ADMIN_USERNAME=pantheon" >> "$GITHUB_ENV" + echo "WORDPRESS_ADMIN_EMAIL=no-reply@getpantheon.com" >> "$GITHUB_ENV" + echo "WORDPRESS_ADMIN_PASSWORD=$(cat /tmp/WORDPRESS_ADMIN_PASSWORD)" >> "$GITHUB_ENV" + + # Configures SSH to automatically accept new host keys. + - name: Force SSH to ignore host keys + run: echo "GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" >> $GITHUB_ENV + + - name: Install SSH key + uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SITE_OWNER_SSH_PRIVATE_KEY }} + + - name: Configure Composer GitHub OAuth (optional) + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ -z "${GITHUB_TOKEN}" ]; then + echo "GITHUB_TOKEN missing; assuming unauthenticated build"; exit 0 + fi + { composer config -g github-oauth.github.com "${GITHUB_TOKEN}"; } &>/dev/null + + - name: Install Terminus + uses: pantheon-systems/terminus-github-actions@v1 + with: + pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} + + - name: Validate fixture version + uses: jazzsequence/action-validate-plugin-version@v1 + with: + branch: ${{ github.head_ref }} + dry-run: 'true' + + - name: Behat prepare + run: | + composer install --no-progress --prefer-dist + ./bin/behat-prepare.sh + + - name: Behat tests (strict) + run: ./bin/behat-test.sh --strict + + - name: Behat cleanup (always) + if: always() + run: ./bin/behat-cleanup.sh diff --git a/.gitignore b/.gitignore index 0ee3fce..125947c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .DS_Store +.idea +.codacy binding.* node_modules/ vendor/ diff --git a/README.md b/README.md index bafdfa0..6165d36 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ **Contributors:** [getpantheon](https://profiles.wordpress.org/getpantheon/), [danielbachhuber](https://profiles.wordpress.org/danielbachhuber/), [jspellman](https://profiles.wordpress.org/jspellman/), [jazzs3quence](https://profiles.wordpress.org/jazzs3quence), [pwtyler](https://profiles.wordpress.org/pwtyler) **Tags:** Pantheon, hosting, environment-indicator **Requires at least:** 4.9 -**Tested up to:** 6.8.1 -**Requires PHP:** 7.4 +**Tested up to:** 6.8.3 +**Requires PHP:** 8.2 **Stable tag:** 0.4.5-dev **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html diff --git a/bin/behat-prepare.sh b/bin/behat-prepare.sh index 8625aef..a8c33a6 100755 --- a/bin/behat-prepare.sh +++ b/bin/behat-prepare.sh @@ -78,15 +78,25 @@ git commit -m "Include Pantheon HUD and its configuration files" git push # Sometimes Pantheon takes a little time to refresh the filesystem -terminus build:workflow:wait $TERMINUS_SITE.$TERMINUS_ENV +terminus workflow:wait $TERMINUS_SITE.$TERMINUS_ENV ### # Set up WordPress, theme, and plugins for the test run ### -# Silence output so as not to show the password. -{ - terminus wp $SITE_ENV -- core install --title=$TERMINUS_ENV-$TERMINUS_SITE --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME --admin_email=pantheon-hud@getpantheon.com --admin_password=$WORDPRESS_ADMIN_PASSWORD -} &> /dev/null + +# Retry WP core install as the environment may take a moment to be ready. +max_attempts=5 +attempt_num=1 +until terminus wp $SITE_ENV -- core install --title=$TERMINUS_ENV-$TERMINUS_SITE --url=$PANTHEON_SITE_URL --admin_user=$WORDPRESS_ADMIN_USERNAME --admin_email=pantheon-hud@getpantheon.com --admin_password=$WORDPRESS_ADMIN_PASSWORD; do + if [ $attempt_num -eq $max_attempts ]; then + echo "WP core install failed after $max_attempts attempts." + exit 1 + fi + echo "WP core install failed. Retrying in 15 seconds... (Attempt $attempt_num of $max_attempts)" + sleep 15 + attempt_num=$((attempt_num+1)) +done + terminus wp $SITE_ENV -- cache flush terminus wp $SITE_ENV -- plugin activate pantheon-hud terminus wp $SITE_ENV -- theme activate twentytwentythree diff --git a/bin/validate-fixture-version.sh b/bin/validate-fixture-version.sh deleted file mode 100755 index b646d22..0000000 --- a/bin/validate-fixture-version.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -set -euo pipefail -IFS=$'\n\t' - -main(){ - export TERMINUS_HIDE_GIT_MODE_WARNING=1 - local DIRNAME=$(dirname "$0") - - if [ -z "${TERMINUS_SITE}" ]; then - echo "TERMINUS_SITE environment variable must be set" - exit 1 - fi - - if ! terminus whoami > /dev/null; then - if [ -z "${TERMINUS_TOKEN}" ]; then - echo "TERMINUS_TOKEN environment variable must be set or terminus already logged in." - exit 1 - fi - terminus auth:login --machine-token="${TERMINUS_TOKEN}" - fi - # Use find to locate the file with a case-insensitive search - README_FILE_PATH=$(find ${DIRNAME}/.. -iname "readme.txt" -print -quit) - if [[ -z "$README_FILE_PATH" ]]; then - echo "readme.txt not found." - exit 1 - fi - - local TESTED_UP_TO - TESTED_UP_TO=$(grep -i "Tested up to:" "${README_FILE_PATH}" | tr -d '\r\n' | awk -F ': ' '{ print $2 }') - echo "Tested Up To: ${TESTED_UP_TO}" - local FIXTURE_VERSION - FIXTURE_VERSION=$(terminus wp "${TERMINUS_SITE}.dev" -- core version) - echo "Fixture Version: ${FIXTURE_VERSION}" - - compare_result=$(php -r "echo version_compare('${TESTED_UP_TO}', '${FIXTURE_VERSION}');") - - if [ $compare_result == "-1" ]; then - echo "${FIXTURE_VERSION} is greater than ${TESTED_UP_TO}" - echo "You should update the 'Tested up to' in your plugin's readme.txt to '${FIXTURE_VERSION}'." - exit 1 - elif [ $compare_result == "1" ]; then - echo "${FIXTURE_VERSION} is less than ${TESTED_UP_TO}" - echo "Please update ${TERMINUS_SITE} to at least WordPress ${TESTED_UP_TO}" - exit 1 - elif [ $compare_result == "0" ]; then - echo "${FIXTURE_VERSION} is equal to ${TESTED_UP_TO}" - echo "No action required." - else - echo "An error occurred during version comparison." - exit 1 - fi -} - -main diff --git a/readme.txt b/readme.txt index 6a04b12..5f13b00 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: getpantheon, danielbachhuber, jazzs3quence, jspellman, pwtyler Tags: Pantheon, hosting, environment-indicator Requires at least: 4.9 -Tested up to: 6.8.1 -Requires PHP: 7.4 +Tested up to: 6.8.3 +Requires PHP: 8.2 Stable tag: 0.4.5-dev License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -12,7 +12,7 @@ A heads-up display into your Pantheon environment. == Description == -This plugin provides situational awareness of the Pantheon plaform from within your WordPress dashboard. It's helpful to be reminded what environment you're in, as well as providing quick links to get back to Pantheon's dashboard, or to interface with your WordPress installation via the command line. +This plugin provides situational awareness of the Pantheon platform from within your WordPress dashboard. It's helpful to be reminded what environment you're in, as well as providing quick links to get back to Pantheon's dashboard, or to interface with your WordPress installation via the command line. Pantheon HUD is in early stages of development. We want your feedback! [Create a Github issue](https://github.com/pantheon-systems/pantheon-hud/issues) with questions, feature requests, or bug reports.