QIT Environment Test - Linux #378
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 Test - Linux | |
on: | |
# Every day at 11pm UTC (6pm ET) | |
schedule: | |
- cron: '0 23 * * *' | |
# Manually | |
workflow_dispatch: | |
jobs: | |
linux_environment_test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-20.04 ] | |
php: [ '7.4' ] | |
wordpress: [ 'nightly' ] | |
include: | |
- os: ubuntu-20.04 | |
php: '8.3' | |
wordpress: 'nightly' | |
fail-fast: false | |
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: Enable dev mode | |
run: ./qit dev | |
- name: Connect to Staging QIT | |
run: ./qit backend:add --environment="staging" --qit_secret="${{ secrets.QIT_STAGING_SECRET }}" --manager_url="https://stagingcompatibilitydashboard.wpcomstaging.com" | |
- name: Debug Docker and Docker Compose | |
run: | | |
echo "Checking Docker version..." | |
docker --version || echo "Docker is not installed" | |
echo "Checking Docker Compose (plugin) version..." | |
docker compose version || echo "Docker Compose (plugin) is not installed" | |
echo "Checking Docker Compose (standalone) version..." | |
docker-compose --version || echo "Docker Compose (standalone) is not installed" | |
- name: Benchmark Docker | |
working-directory: scripts | |
run: docker run -v $GITHUB_WORKSPACE/scripts:/scripts -w /scripts alpine sh -c "apk add --no-cache bash wget tar; chmod +x benchmark.sh; ./benchmark.sh" | |
- name: Composer install | |
working-directory: src | |
run: composer install | |
- name: Start environment | |
working-directory: src | |
run: php qit-cli.php env:up --wp ${{ matrix.wordpress }} --php_version ${{ matrix.php }} | |
- name: Get URL | |
working-directory: src | |
run: | | |
siteUrl=$(php -r "echo exec(PHP_BINARY . ' qit-cli.php env:list --field=site_url');"); | |
echo "SITE_URL=$siteUrl" >> $GITHUB_ENV | |
- name: Print site URL | |
run: | | |
php -r "echo 'Site URL: ' . getenv('SITE_URL');" | |
- name: Test Site Up | |
run: | | |
php -r " | |
\$url = '${{ env.SITE_URL }}'; | |
\$context = stream_context_create(['http' => ['method' => 'GET']]); | |
\$headers = @get_headers(\$url, 1, \$context); | |
\$statusCode = \$headers ? substr(\$headers[0], 9, 3) : 500; | |
if (\$statusCode == 200) { | |
echo 'Site is up'; | |
} else { | |
echo 'Site is not up, status code: ' . \$statusCode; | |
exit(1); | |
}" | |
- name: Query WP JSON | |
run: php -r "echo file_get_contents('${{ env.SITE_URL }}/wp-json');" | |
- name: Verify PHP Version | |
working-directory: src | |
run: | | |
actual_major_minor=$(docker exec $(php qit-cli.php env:list --field=docker_images | grep php) php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;') | |
[[ "$actual_major_minor" == "${{ matrix.php }}" ]] || { echo "PHP Major.Minor version mismatch. Expected: ${{ matrix.php }}, Actual: $actual_major_minor"; exit 1; } | |
- name: Print WordPress Version | |
working-directory: src | |
run: php qit-cli.php env:exec "wp core version" |