QIT Environment Dangling Test #49
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
name: QIT Environment Dangling Test | |
on: | |
# Every day at 11pm UTC (6pm ET) | |
schedule: | |
- cron: '0 23 * * *' | |
# Manually | |
workflow_dispatch: | |
jobs: | |
environment_dangling_tests: | |
runs-on: ubuntu-latest | |
env: | |
NO_COLOR: 1 | |
QIT_DISABLE_ONBOARDING: yes | |
steps: | |
- name: Checkout code (Cross-platform) | |
uses: actions/checkout@v4 | |
- name: Setup PHP (Cross-platform) | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
- name: Composer install (Unix) | |
working-directory: src | |
run: composer install | |
- name: Enable dev mode | |
working-directory: src | |
run: php qit-cli.php dev | |
- name: Connect to Staging QIT | |
working-directory: src | |
run: php qit-cli.php backend:add --environment="staging" --qit_secret="${{ secrets.QIT_STAGING_SECRET }}" --manager_url="https://stagingcompatibilitydashboard.wpcomstaging.com" | |
- name: Add "qit.test" to hosts file (Linux) | |
run: sudo echo "127.0.0.1 qit.test" | sudo tee -a /etc/hosts | |
- name: Start environment | |
working-directory: src | |
run: php qit-cli.php env:up | |
- name: Test Site Up | |
run: | | |
# Fetch the site URL | |
SITE_URL=$(php qit-cli.php env:list --field=site_url) | |
echo "Site URL: $SITE_URL" | |
# Assert home page is 200 | |
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" $SITE_URL) | |
if [ "$HTTP_STATUS" -ne 200 ]; then | |
echo "Home page is not up. HTTP status: $HTTP_STATUS" | |
exit 1 | |
fi | |
echo "Home page is up. HTTP status: $HTTP_STATUS" | |
# Assert the name property in the JSON response | |
JSON_RESPONSE=$(curl -s $SITE_URL/wp-json) | |
NAME_PROPERTY=$(echo $JSON_RESPONSE | jq -r '.name') | |
if [ "$NAME_PROPERTY" != "WooCommerce Core E2E Test Suite" ]; then | |
echo "Name property does not match. Found: $NAME_PROPERTY" | |
exit 1 | |
fi | |
echo "Name property matches: $NAME_PROPERTY" |