Skip to content

Commit

Permalink
move lint and validate behat
Browse files Browse the repository at this point in the history
  • Loading branch information
pwtyler committed Aug 11, 2023
1 parent 550e7dc commit 6f56691
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 20 deletions.
21 changes: 1 addition & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: 2.1
workflows:
main:
jobs:
- lint
- test-behat
- test-phpunit-redis-disabled-74
- test-phpunit-redis-enabled-74
Expand Down Expand Up @@ -58,25 +57,6 @@ commands:
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 nightly true
composer phpunit
jobs:
lint:
working_directory: ~/pantheon-systems/wp-redis
docker:
- image: quay.io/pantheon-public/build-tools-ci:8.x-php8.0
steps:
- checkout
- restore_cache:
keys:
- test-lint-dependencies-{{ checksum "composer.json" }}
- run: composer install -n --prefer-dist
- save_cache:
key: test-lint-dependencies-{{ checksum "composer.json" }}
paths:
- vendor
- run:
name: "Run PHP Lint"
command: |
composer phpcs
test-behat:
working_directory: ~/pantheon-systems/wp-redis
parallelism: 1
Expand Down Expand Up @@ -117,6 +97,7 @@ jobs:
exit 0
fi
terminus auth:login --machine-token=$TERMINUS_TOKEN
- run: ./bin/validate-fixture-version.sh
- run: ./bin/behat-prepare.sh
- run: ./bin/behat-test.sh --strict
- run:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- uses: pantheon-systems/validate-readme-spacing@v1
lint:
name: PHPCS Linting
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Install dependencies
run: composer install -n --prefer-dist
- name: Run PHP Lint
run: composer phpcs
wporg-validation:
name: WP.org Validator
runs-on: ubuntu-latest
Expand Down
44 changes: 44 additions & 0 deletions bin/validate-fixture-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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}"

if ! php -r "exit(version_compare('${TESTED_UP_TO}', '${FIXTURE_VERSION}'));"; then
echo "${FIXTURE_VERSION} is less than ${TESTED_UP_TO}"
echo "Please update ${TERMINUS_SITE} to at least WordPress ${TESTED_UP_TO}"
exit 1
fi
}

main

0 comments on commit 6f56691

Please sign in to comment.