QIT Environment Test - Mac (non M1) #21
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
## | |
# ARM64 Macs such as M1/M2/M3 can't run Docker in CI, so we test only with older Macs. | |
# More info: https://github.com/douglascamata/setup-docker-macos-action | |
## | |
name: QIT Environment Test - Mac (non M1) | |
on: | |
# Every day at 11pm UTC (6pm ET) | |
schedule: | |
- cron: '0 23 * * *' | |
# Manually | |
workflow_dispatch: | |
jobs: | |
mac_environment_test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ macos-13 ] | |
php: [ '7.4' ] | |
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: Setup Docker on macOS | |
if: matrix.os == 'macos-13' | |
uses: douglascamata/setup-docker-macos-action@v1-alpha | |
- name: Check Colima Status (Mac) | |
if: matrix.os == 'macos-13' | |
run: colima status | |
- 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 | |
env: | |
QIT_DOCKER_RUN_TIMEOUT: 1800 | |
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" |