-
Notifications
You must be signed in to change notification settings - Fork 26
183 lines (155 loc) · 5.85 KB
/
Copy pathstaging-test.yml
File metadata and controls
183 lines (155 loc) · 5.85 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: User Registration QA Automation
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
- labeled
branches:
- develop
concurrency:
group: ur-qa-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
qa-automation:
name: Run UR QA Automation
if: >
github.event.pull_request.draft == false &&
(
contains(github.event.pull_request.labels.*.name, 'qa-needed') ||
contains(github.event.pull_request.labels.*.name, 'final-qa')
)
runs-on: ubuntu-latest
steps:
# 🔍 Decide QA Mode (Smoke vs Final)
- name: Decide QA mode
id: qa_mode
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'final-qa') }}" == "true" ]] || \
[[ "${{ startsWith(github.event.pull_request.title, 'final-qa') }}" == "true" ]]; then
echo "mode=final" >> $GITHUB_OUTPUT
else
echo "mode=smoke" >> $GITHUB_OUTPUT
fi
# Checkout PR Code
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# SSH Setup
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.TG_PRIVATE_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# Git Config
- name: Configure Git
run: |
git config --global user.email "${{ secrets.TG_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.TG_GITHUB_USERNAME }}"
# Environment Setup
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: cli, curl, mbstring, xmlrpc
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: 9
# Build Plugin
- name: Install & Build
run: |
pnpm install
composer install
pnpm run build
composer install --no-dev
mkdir -p user-registration
rsync -rc --exclude-from="./.distignore" ./ user-registration --delete --delete-excluded
- name: Create ZIP
run: zip -r user-registration.zip user-registration
# Deploy to QA Server
- name: Remove old plugin
run: |
sshpass -p "${{ secrets.QA_AUTOMATION_SERVER_PASS }}" ssh -o StrictHostKeyChecking=no \
${{ secrets.QA_AUTOMATION_SERVER_USERNAME }}@${{ secrets.QA_AUTOMATION_SERVER_IP }} << 'EOF'
cd /var/www/anup-urautomation.wp1.site/wp-content/plugins/
rm -rf user-registration
EOF
- name: Upload plugin
run: |
sshpass -p "${{ secrets.QA_AUTOMATION_SERVER_PASS }}" scp -o StrictHostKeyChecking=no \
user-registration.zip \
${{ secrets.QA_AUTOMATION_SERVER_USERNAME }}@${{ secrets.QA_AUTOMATION_SERVER_IP }}:/var/www/anup-urautomation.wp1.site/wp-content/plugins/
- name: Install via WP-CLI
run: |
sshpass -p "${{ secrets.QA_AUTOMATION_SERVER_PASS }}" ssh -o StrictHostKeyChecking=no \
${{ secrets.QA_AUTOMATION_SERVER_USERNAME }}@${{ secrets.QA_AUTOMATION_SERVER_IP }} << 'EOF'
cd /var/www/anup-urautomation.wp1.site/
wp plugin install wp-content/plugins/user-registration.zip --activate
rm -f wp-content/plugins/user-registration.zip
EOF
# Browser Setup
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1
# Python Setup
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12.1
# Run Automation
- name: Run UR Automation
run: |
mkdir python-code
cd python-code
git init
git remote add origin git@github.com:wpeverest/UR-Automation.git
git pull origin test-ur-free
pip install -r requirements.txt
chmod +x test_ur_free.sh
bash ./test_ur_free.sh "${{ steps.qa_mode.outputs.mode }}"
continue-on-error: true
# Upload Artifact
- name: Upload Report
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: UR-Report
path: python-code/results/
- name: Publish Report to Server
if: always()
run: |
PR_ID=${{ github.event.pull_request.number }}
RUN_ID=${{ github.run_number }}
REMOTE_PATH="/var/www/anup-urautomation.wp1.site/reports/pr-${PR_ID}/run-${RUN_ID}"
echo "Creating remote directory..."
sshpass -p "${{ secrets.QA_AUTOMATION_SERVER_PASS }}" ssh -o StrictHostKeyChecking=no \
${{ secrets.QA_AUTOMATION_SERVER_USERNAME }}@${{ secrets.QA_AUTOMATION_SERVER_IP }} \
"mkdir -p $REMOTE_PATH"
echo "Uploading reports..."
sshpass -p "${{ secrets.QA_AUTOMATION_SERVER_PASS }}" scp -r -o StrictHostKeyChecking=no \
python-code/results/* \
${{ secrets.QA_AUTOMATION_SERVER_USERNAME }}@${{ secrets.QA_AUTOMATION_SERVER_IP }}:$REMOTE_PATH
echo "Report URL:"
echo "https://anup-urautomation.wp1.site/reports/pr-${PR_ID}/run-${RUN_ID}/report.html"
- name: Comment PR with Execution Report
if: always()
uses: actions/github-script@v7
with:
script: |
const pr = context.issue.number;
const run = context.runNumber;
const reportUrl = `https://anup-urautomation.wp1.site/reports/pr-${pr}/run-${run}/report.html`;
const body = `**Latest Report:** ${reportUrl}`;
github.rest.issues.createComment({
issue_number: pr,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});