-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
197 lines (178 loc) · 6.19 KB
/
Copy pathaction.yml
File metadata and controls
197 lines (178 loc) · 6.19 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: 'AppCrawl AI Testing'
description: 'Run AI-powered mobile and web app tests with AppCrawl'
branding:
icon: 'search'
color: 'blue'
inputs:
suite:
description: 'Path to test suite YAML file or directory'
required: false
command:
description: 'Full appcrawl command to run (alternative to suite)'
required: false
model:
description: 'LLM model to use (e.g. gpt-4o, gemini-2.0-flash)'
default: 'gpt-4o'
platform:
description: 'Target platform: ios, android, or web'
default: 'web'
max-steps:
description: 'Maximum steps per test'
default: '30'
step-delay:
description: 'Delay between steps in ms'
default: '2000'
baseline:
description: 'Path to visual regression baseline directory'
required: false
threshold:
description: 'Visual regression threshold (percentage)'
default: '0.5'
artifact-name:
description: 'Name for the uploaded report artifact'
default: 'appcrawl-report'
comment:
description: 'Post results as PR comment (true/false)'
default: 'true'
outputs:
result:
description: 'Overall result: pass or fail'
value: ${{ steps.run.outputs.result }}
report-dir:
description: 'Path to the generated report directory'
value: ${{ steps.run.outputs.report-dir }}
summary:
description: 'One-line summary of results'
value: ${{ steps.run.outputs.summary }}
runs:
using: 'composite'
steps:
- name: Install AppCrawl
shell: bash
run: |
npm install -g appcrawl@latest 2>/dev/null || npm install -g ./
- name: Install Playwright browsers (web only)
if: inputs.platform == 'web'
shell: bash
run: npx playwright install chromium
- name: Run tests
id: run
shell: bash
env:
ANTHROPIC_API_KEY: ${{ env.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ env.OPENAI_API_KEY }}
GOOGLE_GENERATIVE_AI_API_KEY: ${{ env.GOOGLE_GENERATIVE_AI_API_KEY }}
OPENROUTER_API_KEY: ${{ env.OPENROUTER_API_KEY }}
APPCRAWL_LICENSE: ${{ env.APPCRAWL_LICENSE }}
run: |
set +e
if [ -n "${{ inputs.suite }}" ]; then
appcrawl suite "${{ inputs.suite }}" \
--platform "${{ inputs.platform }}" \
--model "${{ inputs.model }}" \
--step-delay "${{ inputs.step-delay }}" \
--ci 2>&1 | tee appcrawl-output.log
EXIT_CODE=$?
elif [ -n "${{ inputs.command }}" ]; then
${{ inputs.command }} --ci 2>&1 | tee appcrawl-output.log
EXIT_CODE=$?
else
echo "Either 'suite' or 'command' input is required"
exit 2
fi
# Find the latest report directory
REPORT_DIR=$(ls -dt appcrawl-reports/*/ 2>/dev/null | head -1)
echo "report-dir=${REPORT_DIR}" >> "$GITHUB_OUTPUT"
if [ $EXIT_CODE -eq 0 ]; then
echo "result=pass" >> "$GITHUB_OUTPUT"
echo "summary=All tests passed" >> "$GITHUB_OUTPUT"
else
echo "result=fail" >> "$GITHUB_OUTPUT"
echo "summary=Some tests failed (exit code $EXIT_CODE)" >> "$GITHUB_OUTPUT"
fi
# Store exit code for later — don't fail yet if we need to run visual diff
echo "EXIT_CODE=$EXIT_CODE" >> "$GITHUB_ENV"
- name: Visual regression
if: inputs.baseline != ''
id: visual
shell: bash
run: |
REPORT_DIR="${{ steps.run.outputs.report-dir }}"
if [ -d "${REPORT_DIR}screenshots" ]; then
appcrawl visual-diff \
--baseline "${{ inputs.baseline }}" \
--current "${REPORT_DIR}screenshots" \
--threshold "${{ inputs.threshold }}" \
--ci 2>&1 | tee -a appcrawl-output.log
if [ $? -ne 0 ]; then
echo "EXIT_CODE=1" >> "$GITHUB_ENV"
fi
fi
- name: Upload report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: |
appcrawl-reports/
appcrawl-output.log
retention-days: 30
- name: Upload JUnit results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}-junit
path: appcrawl-reports/**/junit.xml
retention-days: 30
- name: Post PR comment
if: inputs.comment == 'true' && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const output = fs.readFileSync('appcrawl-output.log', 'utf8');
const result = '${{ steps.run.outputs.result }}';
const icon = result === 'pass' ? ':white_check_mark:' : ':x:';
// Extract the summary sections from output
const suiteMatch = output.match(/SUITE RESULTS[\s\S]*?={50,}/g);
const summary = suiteMatch ? suiteMatch[suiteMatch.length - 1] : output.slice(-500);
const body = [
`## ${icon} AppCrawl Test Results`,
'',
'```',
summary.trim(),
'```',
'',
`Model: \`${{ inputs.model }}\` | Platform: \`${{ inputs.platform }}\``,
'',
'_Generated by [AppCrawl](https://appcrawl.dev) AI Testing_',
].join('\n');
// Find and update existing comment, or create new one
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c =>
c.body.includes('AppCrawl Test Results') &&
c.user.type === 'Bot'
);
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
- name: Set exit code
if: always()
shell: bash
run: exit ${EXIT_CODE:-0}