QIT Environment Test - Linux #20
Workflow file for this run
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 11am and 11pm UTC (6am and 6pm ET) | |
schedule: | |
- cron: '0 11 * * *' | |
- cron: '0 23 * * *' | |
# Manually | |
workflow_dispatch: | |
jobs: | |
environment_tests: | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-latest, macos-latest] | |
#php: ['7.2', '7.4', '8.0'] # Example PHP versions, adjust as necessary | |
runs-on: ${{ matrix.os }} | |
env: | |
NO_COLOR: 1 | |
QIT_DISABLE_ONBOARDING: yes | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '7.2' | |
- 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: Add "qit.test" to hosts file (Linux) | |
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-latest' | |
run: sudo echo "127.0.0.1 qit.test" | sudo tee -a /etc/hosts | |
- name: Add "qit.test" to hosts file (Windows) | |
if: matrix.os == 'windows-latest' | |
run: echo "127.0.0.1 qit.test" | Out-File -Append -Encoding ASCII -FilePath C:\Windows\System32\drivers\etc\hosts | |
- name: Add "qit.test" to hosts file (macOS) | |
if: matrix.os == 'macos-latest' | |
run: sudo sh -c 'echo "127.0.0.1 qit.test" >> /etc/hosts' | |
- name: Set up Docker | |
if: matrix.os == 'macos-latest' | |
uses: crazy-max/[email protected] | |
- name: Start environment and get URL (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
set -e | |
siteUrl=$(./qit env:up | tail -n 1) | |
if [ -z "$siteUrl" ]; then | |
echo "Failed to get site URL" | |
exit 1 | |
fi | |
echo "SITE_URL=$siteUrl" >> $GITHUB_ENV | |
- name: Start environment and get URL (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
$envOutput = ./qit env:up | |
$siteUrl = $envOutput -split "`r`n" | Select-Object -Last 1 | |
echo "SITE_URL=$siteUrl" | Out-File -Append -FilePath $Env:GITHUB_ENV | |
- name: Print site URL | |
run: | | |
php -r "echo 'Site URL: ' . getenv('SITE_URL');" | |
- name: Test Site Up (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
statusCode=$(curl -o /dev/null -s -w "%{http_code}" ${{ env.SITE_URL }}) | |
if [ "$statusCode" -eq 200 ]; then | |
echo "Site is up" | |
else | |
echo "Site is not up, status code: $statusCode" | |
exit 1 | |
fi | |
- name: Test Site Up (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
$statusCode = (Invoke-WebRequest -Uri $env:SITE_URL -UseBasicParsing).StatusCode | |
if ($statusCode -eq 200) { | |
echo "Site is up" | |
} else { | |
echo "Site is not up, status code: $statusCode" | |
exit 1 | |
} | |
- name: Query WP JSON (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
curl -s "${{ env.SITE_URL }}/wp-json" | |
- name: Query WP JSON (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
Invoke-RestMethod -Uri "$env:SITE_URL/wp-json" -UseBasicParsing |