Validate Node.js #35
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 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '21' | |
| - name: Setup pnpm | |
| if: hashFiles('pnpm-lock.yaml') != '' | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Normalize runner architecture | |
| shell: bash | |
| run: | | |
| echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_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 | |
| shell: bash | |
| run: | | |
| echo "OS=${{ runner.os }}" | |
| echo "ARCH=$ARCH" | |
| echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" | |
| echo "NODE_CACHE=$NODE_CACHE" | |
| echo "LOCK_PATTERN=$LOCK_PATTERN" | |
| - name: Restore 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) }} | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| if [ "$PACKAGE_MANAGER" = "pnpm" ]; then | |
| if pnpm install --frozen-lockfile; then | |
| echo "pnpm frozen-lockfile install succeeded" | |
| else | |
| echo "pnpm lockfile incompatible — retrying without frozen-lockfile" | |
| pnpm install --no-frozen-lockfile | |
| fi | |
| 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 |