-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
147 lines (128 loc) · 4.49 KB
/
Copy pathe2e-test.yml
File metadata and controls
147 lines (128 loc) · 4.49 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
name: E2E Test
on:
push:
branches:
- next
paths-ignore:
- '**/*.md'
pull_request:
branches:
- next
paths-ignore:
- '**/*.md'
concurrency:
group: ${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
e2e-test:
name: ${{ matrix.project.name }} E2E test
permissions:
contents: read
packages: read
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_DATABASE: cnpmcore
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
redis:
image: redis
ports:
- 6379:6379
strategy:
fail-fast: false
matrix:
project:
- name: cnpmcore
node-version: 24
command: |
npm install
npm run lint -- --quiet
npm run typecheck
npm run build
npm run prepublishOnly
# Clean build artifacts to avoid double-loading (src + dist)
npm run clean
# Run the full test suite
echo "Preparing databases..."
mysql -h 127.0.0.1 -u root -e "CREATE DATABASE IF NOT EXISTS cnpmcore_unittest"
CNPMCORE_DATABASE_NAME=cnpmcore_unittest bash ./prepare-database-mysql.sh
CNPMCORE_DATABASE_NAME=cnpmcore bash ./prepare-database-mysql.sh
EGG_FILE_PARALLELISM=false npm run test:local
# Deployment test: start the app and verify it boots correctly
npm run clean
echo "Preparing database for deployment test..."
CNPMCORE_DATABASE_NAME=cnpmcore bash ./prepare-database-mysql.sh
echo "Starting cnpmcore..."
CNPMCORE_FORCE_LOCAL_FS=true npx eggctl start &
SERVER_PID=$!
echo "Health checking cnpmcore..."
URL="http://127.0.0.1:7001"
PATTERN="instance_start_time"
TIMEOUT=60
TMP="$(mktemp)"
deadline=$((SECONDS + TIMEOUT))
last_status=""
while (( SECONDS < deadline )); do
last_status="$(curl -sS -o "$TMP" -w '%{http_code}' "$URL" || true)"
if [[ "$last_status" == "200" ]] && grep -q "$PATTERN" "$TMP"; then
echo "cnpmcore is ready (status=$last_status)"
rm -f "$TMP"
npx eggctl stop || true
exit 0
fi
sleep 1
done
echo "Health check failed: status=$last_status"
cat "$TMP" || true
rm -f "$TMP"
npx eggctl stop || true
exit 1
- name: examples
node-version: 24
command: |
# examples/helloworld https://github.com/eggjs/examples/blob/master/helloworld/package.json
cd helloworld
npm install
npm run lint
npm run test
npm run prepublishOnly
cd ..
# examples/hello-tegg https://github.com/eggjs/examples/blob/master/hello-tegg/package.json
cd hello-tegg
npm install
npm run lint
npm run test
npm run prepublishOnly
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- uses: ./.github/actions/clone
with:
ecosystem-ci-project: ${{ matrix.project.name }}
- name: Install utoo
uses: utooland/setup-utoo@v1
- name: Set up Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: ${{ matrix.project.node-version }}
- name: Install dependencies
run: ut install
- name: Build all packages
run: ut build
# - name: Pack packages into tgz
# run: |
# pnpm -r pack
- name: Override dependencies from tgz in ${{ matrix.project.name }}
working-directory: ecosystem-ci/${{ matrix.project.name }}
run: |
node ../patch-project.ts ${{ matrix.project.name }}
- name: Run e2e test commands in ${{ matrix.project.name }}
working-directory: ecosystem-ci/${{ matrix.project.name }}
run: ${{ matrix.project.command }}