-
Notifications
You must be signed in to change notification settings - Fork 143
202 lines (177 loc) · 6.93 KB
/
ci.yml
File metadata and controls
202 lines (177 loc) · 6.93 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
198
199
200
201
202
name: CI/CD Pipeline
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-ci.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+-ci.[0-9]+'
# CI pipeline for tagged releases: Fast unit tests + Docker build + SDK tests
# Note: Comprehensive tests (including Slow + Integration) run in nightly.yml
workflow_dispatch:
inputs:
skip_tests:
description: 'Skip tests'
required: false
default: false
type: boolean
debug_mode:
description: 'Enable debug mode'
required: false
default: false
type: boolean
env:
IMAGE_NAME: browser4
NETWORK_NAME: 'browser4_backend'
CONTAINER_NAME: 'browser4-test'
DOCKER_COMPOSE_FILE: './docker-compose.yml'
DEPENDENCY_SERVICES: 'mongodb'
MONGODB_CONTAINER: 'mongodb'
MONGODB_PORT: '27017'
JAVA_VERSION: '17'
MAVEN_OPTS: '-Xmx3g -XX:+UseG1GC'
jobs:
ci-build:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.build.outputs.image_tag }}
test_results: ${{ steps.tests.outputs.test_status }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Environment
id: setup
uses: ./.github/actions/setup-environment
with:
java_version: ${{ env.JAVA_VERSION }}
- name: Verify Dependencies
id: deps
uses: ./.github/actions/verify-dependencies
with:
network_name: ${{ env.NETWORK_NAME }}
compose_file: ${{ env.DOCKER_COMPOSE_FILE }}
services_to_start: ${{ env.DEPENDENCY_SERVICES }}
mongodb_container: ${{ env.MONGODB_CONTAINER }}
mongodb_port: ${{ env.MONGODB_PORT }}
startup_timeout: '120'
verify_network_connectivity: 'true'
- name: Maven Build
id: build-maven
uses: ./.github/actions/maven-build
with:
skip_tests: ${{ inputs.skip_tests || 'true' }}
timeout_minutes: '15'
maven_profiles: 'all-modules'
- name: Setup Rust Toolchain
id: rust-setup
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust Build Artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: sdks/browser4-cli
- name: Cleanup Docker system to free space
run: |
docker system prune -af
docker volume prune -f
rm -rf ~/.m2/repository # If you no longer need Maven cache
sudo apt-get clean
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo df -h
- name: Build Docker Image
id: build
uses: ./.github/actions/docker-build
with:
image_name: ${{ env.IMAGE_NAME }}
version: ${{ github.sha }}
timeout_minutes: '20'
- name: Start Application
id: app
uses: ./.github/actions/start-application
with:
image_name: ${{ env.IMAGE_NAME }}
version: ${{ github.sha }}
container_name: ${{ env.CONTAINER_NAME }}
network_name: ${{ env.NETWORK_NAME }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
proxy_rotation_url: ${{ secrets.PROXY_ROTATION_URL }}
- name: Health Check
id: health
uses: ./.github/actions/health-check
with:
service_port: '8182'
timeout_minutes: '5'
container_name: ${{ env.CONTAINER_NAME }}
- name: Run browser4-cli E2E Tests
id: e2e-cli
timeout-minutes: 15
shell: bash
env:
BROWSER4_E2E_SERVICE_URL: http://localhost:8182
BROWSER4_E2E_FIXTURE_HOST: host.docker.internal
run: |
echo "::group::🧪 browser4-cli E2E Tests"
# Run the CLI tests against the already-running Docker container
echo "Running browser4-cli E2E tests..."
echo "Working directory: $(pwd)"
cd sdks/browser4-cli
cargo test --test e2e -- --nocapture
cd "$(git rev-parse --show-toplevel)"
echo "::endgroup::"
- name: Run Tests
id: run-tests
if: inputs.skip_tests != true
uses: ./.github/actions/run-tests
with:
maven_profiles: 'all-modules'
# CI Pipeline: Run only Fast unit tests (same as PR tests)
# Comprehensive tests (Slow + Integration) run in nightly.yml
# Exclude: Slow, Heavy, Integration, E2E, SDK, and all environment-dependent tests
excluded_groups: 'Slow,Heavy,RequiresServer,RequiresBrowser,RequiresAI,RequiresDocker,Integration,E2E,SDK,ManualOnly,IntegrationTest,E2ETest,HeavyTest,SkippableLowerLevelTest,TestInfraCheck,OptionalTest'
timeout_minutes: '35'
- name: Check Test Status
if: inputs.skip_tests != true
run: |
if [ "${{ steps.run-tests.outputs.test_status }}" != "success" ]; then
echo "❌ Tests failed with status: ${{ steps.run-tests.outputs.test_status }}"
echo "📊 Test Results:"
echo " - Total Tests: ${{ steps.run-tests.outputs.test_count }}"
echo " - Failed Tests: ${{ steps.run-tests.outputs.failed_count }}"
echo " - Passed Tests: ${{ steps.run-tests.outputs.passed_count }}"
echo " - Skipped Tests: ${{ steps.run-tests.outputs.skipped_count }}"
exit 1
else
echo "✅ All tests passed successfully"
echo "📊 Test Results: ${{ steps.run-tests.outputs.passed_count }} tests passed"
fi
- name: Pipeline Summary
if: always()
shell: bash
run: |
echo "::group::📊 Pipeline Summary"
echo "🎯 Pipeline Results:"
echo " - Setup: ${{ steps.setup.outcome }}"
echo " - Dependencies: ${{ steps.deps.outcome }}"
echo " - Maven Build: ${{ steps.build-maven.outcome }}"
echo " - Docker Build: ${{ steps.build.outcome }}"
echo " - Application: ${{ steps.app.outcome }}"
echo " - Health Check: ${{ steps.health.outcome }}"
echo " - CLI E2E Tests: ${{ steps.e2e-cli.outcome }}"
echo " - Unit Tests: ${{ steps.run-tests.outcome || 'skipped' }}"
echo ""
echo "🌐 Infrastructure:"
echo " - Network: ${{ env.NETWORK_NAME }}"
echo " - Container: ${{ env.CONTAINER_NAME }}"
echo " - Image: ${{ env.IMAGE_NAME }}:${{ github.sha }}"
echo " - MongoDB: ${{ steps.deps.outputs.mongodb_status }}"
echo " - Redis: ${{ steps.deps.outputs.redis_status }}"
echo ""
echo "📅 Completed at: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo "👤 Triggered by: ${{ github.actor }}"
echo "🌟 Commit: ${{ github.sha }}"
echo "::endgroup::"
- name: Cleanup Resources
if: always()
uses: ./.github/actions/cleanup-resources
with:
container_name: ${{ env.CONTAINER_NAME }}
cleanup_compose: 'true'
cleanup_volumes: 'true'
network_name: ${{ env.NETWORK_NAME }}