AikidoSec-safe-chain/.github/workflows/test-on-pr.yml
2026-05-22 13:16:55 +09:00

125 lines
3.7 KiB
YAML

name: Run tests
on: pull_request
jobs:
unit-test:
name: Run unit tests and linting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "lts/*"
- name: Setup safe-chain
run: curl -fsSL https://github.com/AikidoSec/safe-chain/releases/latest/download/install-safe-chain.sh | sh -s -- --ci
shell: bash
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run unit tests
run: npm test
- name: Run linting
run: npm run lint
- name: Type check
run: npm run typecheck --workspace=packages/safe-chain
- name: Create package tarball
if: matrix.os == 'ubuntu-latest'
run: npm pack --workspace=packages/safe-chain
- name: Upload package tarball
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: matrix.os == 'ubuntu-latest'
with:
name: safe-chain-package
path: aikidosec-safe-chain-*.tgz
e2e-tests:
name: Run E2E tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# Common production setup
- node_version: "20"
npm_version: "10.2.0"
yarn_version: "4.0.0"
pnpm_version: "9.0.0"
# Current Active LTS with latest tools
- node_version: "22"
npm_version: "latest"
yarn_version: "latest"
pnpm_version: "latest"
# Legacy support (EOL April 2025)
- node_version: "18"
npm_version: "9.0.0"
yarn_version: "3.6.0"
pnpm_version: "8.0.0"
# Mixed versions (old npm, new package managers)
- node_version: "20"
npm_version: "9.0.0"
yarn_version: "latest"
pnpm_version: "10.0.0"
# Version pinning scenario
- node_version: "22"
npm_version: "10.2.0"
yarn_version: "4.0.0"
pnpm_version: "9.0.0"
# Backward compatibility testing
- node_version: "18"
npm_version: "latest"
yarn_version: "latest"
pnpm_version: "10.0.0"
# Future compatibility (becomes LTS October 2025)
- node_version: "24"
npm_version: "latest"
yarn_version: "latest"
pnpm_version: "latest"
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "lts/*"
- name: Setup safe-chain
run: curl -fsSL https://github.com/AikidoSec/safe-chain/releases/latest/download/install-safe-chain.sh | sh -s -- --ci
- name: Install dependencies (root)
run: npm ci
- name: Run E2E tests
env:
NODE_VERSION: ${{ matrix.node_version }}
NPM_VERSION: ${{ matrix.npm_version }}
YARN_VERSION: ${{ matrix.yarn_version }}
PNPM_VERSION: ${{ matrix.pnpm_version }}
run: npm run test:e2e
- name: Clean up Docker resources
if: always()
run: |
# Clean up any remaining containers and images
docker ps -aq --filter "name=safe-chain-e2e-test" | xargs -r docker rm -f
docker images -q safe-chain-e2e-test | xargs -r docker rmi -f