test: Update integration tests for compatibility with Node24 (#21685)

This commit is contained in:
Mykola Mokhnach
2025-10-30 08:59:17 +01:00
committed by GitHub
parent b12a47349a
commit 0d5ba222d1
10 changed files with 264 additions and 158 deletions

50
.github/actions/setup-build/action.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Setup Node, Install, Build
description: |
Common setup for Appium CI jobs: checkout, setup Node, install deps, optional build, optional V8 cache clear.
inputs:
node-version:
description: Node.js version to setup
required: true
install-command:
description: npm install command
required: false
default: npm ci --foreground-scripts
run-build:
description: Whether to run npm run build
required: false
default: 'true'
clear-v8-cache:
description: Whether to clear V8 code cache (for Node.js 24+ compatibility)
required: false
default: 'true'
runs:
using: composite
steps:
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: npm
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
useRollingCache: true
install-command: ${{ inputs.install-command }}
- name: Build packages
if: ${{ inputs.run-build == 'true' }}
shell: bash
run: npm run build
- name: Clear V8 code cache
if: ${{ inputs.clear-v8-cache == 'true' }}
shell: bash
run: |
# Clear V8 code cache to avoid bytecode deserialization errors
if [[ -d "$HOME/.node" ]]; then
rm -rf "$HOME/.node"/* 2>/dev/null || true
fi
if [[ -d "$HOME/.cache/node" ]]; then
rm -rf "$HOME/.cache/node"/* 2>/dev/null || true
fi

View File

@@ -64,44 +64,148 @@ jobs:
id: generate-matrix
uses: msimerson/node-lts-versions@v1
test:
prepare_e2e_packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.discover-packages.outputs.packages }}
steps:
- uses: actions/checkout@v5
- name: Discover packages with e2e tests
id: discover-packages
run: |
packages=()
for package_dir in packages/*/; do
package_json="${package_dir}package.json"
if [[ -f "$package_json" ]]; then
# Check if package.json has test:e2e script and it's not a no-op
has_e2e=$(node -e "
try {
const pkg = require('./$package_json');
const script = pkg.scripts && pkg.scripts['test:e2e'];
if (script && !script.includes('echo') && !script.includes('No e2e tests')) {
console.log('true');
}
} catch(e) {
// Ignore errors
}
")
if [[ "$has_e2e" == "true" ]]; then
# Use the directory path without packages/ prefix (remove trailing slash)
package_name="${package_dir%/}"
package_name="${package_name#packages/}"
packages+=("$package_name")
fi
fi
done
# Convert array to JSON array for GitHub Actions matrix
if [[ ${#packages[@]} -eq 0 ]]; then
echo "No packages with e2e tests found"
packages_json="[]"
else
# Use jq to create a compact single-line JSON array
packages_json=$(printf '%s\n' "${packages[@]}" | jq -R '.' | jq -s '.' | jq -c '.')
fi
echo "packages=$packages_json" >> $GITHUB_OUTPUT
echo "Found packages with e2e tests:"
echo "$packages_json" | jq -r '.[]' | sed 's/^/ - /'
test-smoke:
needs:
- prepare_matrix
name: Tests
name: Smoke Tests
strategy:
matrix:
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
os:
- ubuntu-latest
# TODO: Windows is not stable and slow to run
# - windows-latest
# TODO: Enable below envs after all tests have been verified green
# - macos-latest
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
- name: Setup, install and build
uses: ./.github/actions/setup-build
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
uses: bahmutov/npm-install@v1
with:
useRollingCache: true
install-command: npm ci --foreground-scripts
- name: Run smoke, unit & E2E tests
run: npm run test:ci
run-build: 'true'
clear-v8-cache: 'true'
- name: Run smoke tests
run: npm run test:smoke
test-unit:
needs:
- prepare_matrix
name: Unit Tests
strategy:
matrix:
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup, install and build
uses: ./.github/actions/setup-build
with:
node-version: ${{ matrix.node-version }}
install-command: npm ci --foreground-scripts
run-build: 'true'
clear-v8-cache: 'true'
- name: Run unit tests
run: npm run test:unit
test-types:
needs:
- prepare_matrix
name: Type Tests
strategy:
matrix:
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup, install and build
uses: ./.github/actions/setup-build
with:
node-version: ${{ matrix.node-version }}
install-command: npm ci --foreground-scripts
run-build: 'true'
clear-v8-cache: 'true'
- name: Run type tests
run: npm run test:types
test-e2e:
needs:
- prepare_matrix
- prepare_e2e_packages
name: E2E Tests - ${{ matrix.package_dir }} (Node ${{ matrix.node-version }})
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
package_dir: ${{ fromJSON(needs.prepare_e2e_packages.outputs.packages) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup, install and build
uses: ./.github/actions/setup-build
with:
node-version: ${{ matrix.node-version }}
install-command: npm ci --foreground-scripts
run-build: 'true'
clear-v8-cache: 'true'
- name: Run E2E tests for ${{ matrix.package_dir }}
run: |
set -o pipefail
cd "packages/${{ matrix.package_dir }}"
npm run test:e2e
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Setup and install (no build)
uses: ./.github/actions/setup-build
with:
useRollingCache: true
node-version: lts/*
install-command: npm ci
run-build: 'false'
clear-v8-cache: 'false'
- name: ESLint
run: npm run lint:ci