-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (108 loc) · 4.1 KB
/
qit-environment-test-linux.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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-13]
#php: ['7.2', '7.4', '8.0'] # Example PHP versions, adjust as necessary
fail-fast: false
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-13'
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-13'
run: sudo sh -c 'echo "127.0.0.1 qit.test" >> /etc/hosts'
- name: Setup Docker on macOS
if: matrix.os == 'macos-13'
uses: douglascamata/setup-docker-macos-action@v1-alpha
- 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: Start environment and get URL (Unix)
if: runner.os != 'Windows'
run: |
set -e
echo "Starting environment and retrieving site URL..."
output=$(./qit env:up)
echo "$output"
siteUrl=$(echo "$output" | tail -n 1)
if [ -z "$siteUrl" ]; then
echo "Failed to get site URL"
exit 1
fi
echo "Retrieved site URL: $siteUrl"
echo "SITE_URL=$siteUrl" >> $GITHUB_ENV
- name: Run command and check output
if: runner.os == 'Windows'
run: |
./qit env:up
- name: Print output for debugging
if: runner.os == 'Windows'
run: |
Get-Content output.txt
- name: Get last line for site URL (Windows)
if: runner.os == 'Windows'
run: |
$siteUrl = Get-Content output.txt | 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