chore: migrate to utoo CI #497
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |