|
| 1 | +name: Run Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + - 'releases/**' |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_NET_GIT_FETCH_WITH_CLI: 'true' |
| 13 | + GIT_SSH_COMMAND: 'ssh -o UserKnownHostsFile=/github/home/.ssh/known_hosts -o StrictHostKeyChecking=yes' |
| 14 | + |
| 15 | +jobs: |
| 16 | + ci: |
| 17 | + name: CI - Node.js ${{ matrix.node-version }} & Python ${{ matrix.python-version }} |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: |
| 20 | + image: python:${{ matrix.python-version }}-slim |
| 21 | + options: --user 0 |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + node-version: [22, 24] |
| 25 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14-rc'] |
| 26 | + timeout-minutes: 25 |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + - name: Install base packages |
| 31 | + run: | |
| 32 | + apt-get update |
| 33 | + apt-get install -y --no-install-recommends \ |
| 34 | + ca-certificates \ |
| 35 | + curl \ |
| 36 | + gnupg \ |
| 37 | + git \ |
| 38 | + openssh-client \ |
| 39 | + build-essential \ |
| 40 | + pkg-config \ |
| 41 | + gdb \ |
| 42 | + binutils |
| 43 | + - name: Setup SSH Agent |
| 44 | + uses: webfactory/[email protected] |
| 45 | + with: |
| 46 | + ssh-private-key: | |
| 47 | + ${{ secrets.SSH_PRIVATE_KEY }} |
| 48 | + ${{ secrets.HTTP_HANDLER_ACCESS_TOKEN }} |
| 49 | + ${{ secrets.HTTP_REWRITER_ACCESS_TOKEN }} |
| 50 | + - name: Trust internal SSH host aliases |
| 51 | + run: | |
| 52 | + set -e |
| 53 | + mkdir -p ~/.ssh |
| 54 | + chmod 700 ~/.ssh |
| 55 | + touch ~/.ssh/known_hosts |
| 56 | + chmod 644 ~/.ssh/known_hosts |
| 57 | + KEY_ENTRY=$(ssh-keyscan github.com 2>/dev/null) |
| 58 | + echo "$KEY_ENTRY" >> ~/.ssh/known_hosts |
| 59 | + echo "$KEY_ENTRY" | sed 's/^github\.com\([[:space:]]\)/github.com-http-handler\1/' >> ~/.ssh/known_hosts |
| 60 | + echo "$KEY_ENTRY" | sed 's/^github\.com\([[:space:]]\)/github.com-http-rewriter\1/' >> ~/.ssh/known_hosts |
| 61 | + - uses: actions/setup-node@v5 |
| 62 | + with: |
| 63 | + node-version: ${{ matrix.node-version }} |
| 64 | + - name: Restore cached dependencies |
| 65 | + uses: actions/cache@v4 |
| 66 | + with: |
| 67 | + path: ~/.pnpm-store |
| 68 | + key: node-modules-${{ hashFiles('package.json') }} |
| 69 | + - name: Setup pnpm |
| 70 | + uses: pnpm/action-setup@v4 |
| 71 | + with: |
| 72 | + version: latest |
| 73 | + - name: Set private package config |
| 74 | + run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" |
| 75 | + env: |
| 76 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 77 | + - name: Install dependencies |
| 78 | + run: pnpm install |
| 79 | + - name: Install Rust toolchain |
| 80 | + run: | |
| 81 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 82 | + echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 83 | + # TODO: remove when using published dependency |
| 84 | + - name: Build python-node manually |
| 85 | + run: | |
| 86 | + # Configure git to use SSH host aliases for private repos (needed by cargo) |
| 87 | + git config --global url."ssh://[email protected]/platformatic/http-handler".insteadOf "ssh://[email protected]/platformatic/http-handler" |
| 88 | + git config --global url."ssh://[email protected]/platformatic/http-handler.git".insteadOf "ssh://[email protected]/platformatic/http-handler.git" |
| 89 | + git config --global url."ssh://[email protected]/platformatic/http-rewriter".insteadOf "ssh://[email protected]/platformatic/http-rewriter" |
| 90 | + git config --global url."ssh://[email protected]/platformatic/http-rewriter.git".insteadOf "ssh://[email protected]/platformatic/http-rewriter.git" |
| 91 | +
|
| 92 | + cd node_modules/@platformatic/python-node |
| 93 | + pnpm install --ignore-scripts |
| 94 | + pnpm run build |
| 95 | + pnpm run build:wasm |
| 96 | + pnpm run build:fix |
| 97 | + - name: Run isolated debug test |
| 98 | + run: | |
| 99 | + set -euxo pipefail |
| 100 | + export NODE_OPTIONS="--trace-warnings --trace-uncaught --trace-exit --max-old-space-size=4096" |
| 101 | + export DEBUG="*" |
| 102 | + ulimit -c unlimited |
| 103 | + sysctl -w kernel.core_pattern=/tmp/core || true |
| 104 | + rm -rf core-dumps |
| 105 | + mkdir -p core-dumps |
| 106 | + set +e |
| 107 | + node --trace-warnings --trace-uncaught --trace-exit ./test/debug-isolated.js |
| 108 | + status=$? |
| 109 | + set -e |
| 110 | + if [ "$status" -ne 0 ]; then |
| 111 | + echo "Isolated debug test failed with status $status" |
| 112 | + echo "Searching for core files..." |
| 113 | + find . -maxdepth 3 -type f -name 'core*' -print -exec cp {} core-dumps/ \; || true |
| 114 | + find /tmp -maxdepth 1 -type f -name 'core*' -print -exec cp {} core-dumps/ \; || true |
| 115 | + exit "$status" |
| 116 | + fi |
| 117 | + - name: Run Full Test Suite |
| 118 | + run: | |
| 119 | + set -euxo pipefail |
| 120 | + export NODE_OPTIONS="--trace-warnings --trace-uncaught --trace-exit --max-old-space-size=4096" |
| 121 | + export DEBUG="*" |
| 122 | + ulimit -c unlimited |
| 123 | + sysctl -w kernel.core_pattern=/tmp/core || true |
| 124 | + pnpm test || { |
| 125 | + echo "Checking for core dumps..." |
| 126 | + find . -maxdepth 3 -type f -name 'core*' -print -exec cp {} core-dumps/ \; || true |
| 127 | + find /tmp -maxdepth 1 -type f -name 'core*' -print -exec cp {} core-dumps/ \; || true |
| 128 | + exit 1 |
| 129 | + } |
| 130 | + - name: Upload crash dumps |
| 131 | + if: failure() |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: crash-dumps-${{ matrix.node-version }}-${{ matrix.python-version }} |
| 135 | + path: core-dumps |
| 136 | + if-no-files-found: error |
| 137 | + if-no-files-found: ignore |
0 commit comments