Validate Node.js #32
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: Validate corrupted Node.js SDK | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| id: setup-node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '21' | |
| # Normalize runner.arch (x64 / arm64) | |
| - name: Normalize runner architecture | |
| shell: bash | |
| run: | | |
| echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
| # Detect package manager + cache path (Node equivalent of `go env`) | |
| - name: Detect package manager and cache path | |
| shell: bash | |
| run: | | |
| set -e | |
| if [ -f pnpm-lock.yaml ]; then | |
| PM=pnpm | |
| CACHE_PATH=$(pnpm store path) | |
| LOCK_PATTERN="**/pnpm-lock.yaml" | |
| elif [ -f yarn.lock ]; then | |
| PM=yarn | |
| CACHE_PATH=$(yarn cache dir) | |
| LOCK_PATTERN="**/yarn.lock" | |
| else | |
| PM=npm | |
| CACHE_PATH=$(npm config get cache) | |
| LOCK_PATTERN="**/package-lock.json" | |
| fi | |
| echo "PACKAGE_MANAGER=$PM" >> $GITHUB_ENV | |
| echo "NODE_CACHE=$CACHE_PATH" >> $GITHUB_ENV | |
| echo "LOCK_PATTERN=$LOCK_PATTERN" >> $GITHUB_ENV | |
| - name: Debug cache variables | |
| run: | | |
| echo "OS=${{ runner.os }}" | |
| echo "ARCH=$ARCH" | |
| echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" | |
| echo "NODE_CACHE=$NODE_CACHE" | |
| echo "LOCK_PATTERN=$LOCK_PATTERN" | |
| # Restore Node cache (setup-go equivalent) | |
| - name: Restore Node cache | |
| id: node-cache | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: ${{ env.NODE_CACHE }} | |
| key: node-cache-${{ runner.os }}-${{ env.ARCH }}-${{ env.PACKAGE_MANAGER }}-${{ hashFiles(env.LOCK_PATTERN) }} | |
| # Install dependencies (PM-aware) | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| if [ "$PACKAGE_MANAGER" = "pnpm" ]; then | |
| pnpm install --frozen-lockfile | |
| elif [ "$PACKAGE_MANAGER" = "yarn" ]; then | |
| yarn install --frozen-lockfile | |
| else | |
| npm ci | |
| fi | |
| - name: Build | |
| shell: bash | |
| run: | | |
| if [ "$PACKAGE_MANAGER" = "pnpm" ]; then | |
| pnpm run build | |
| elif [ "$PACKAGE_MANAGER" = "yarn" ]; then | |
| yarn build | |
| else | |
| npm run build --if-present | |
| fi |