-
Notifications
You must be signed in to change notification settings - Fork 3
110 lines (91 loc) · 3.82 KB
/
qit-environment-test-mac.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
##
# 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 }}
if: false # Docker on Mac in GitHub Actions is broken. We need to wait. https://github.com/douglascamata/setup-docker-macos-action/issues/37
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"