Skip to content

Release to Staging v2.9.28 - 2026-08-07 #1639

Release to Staging v2.9.28 - 2026-08-07

Release to Staging v2.9.28 - 2026-08-07 #1639

Workflow file for this run

name: QRCode SDK CI
env:
# Build environment versions
# Node version is read from .nvmrc during workflow execution
# Cache versioning - increment these to bust caches when needed
GH_CACHE_VERSION: v1 # Global cache version
GH_PNPM_CACHE_VERSION: v1 # pnpm store cache version
GH_SDK_CACHE_VERSION: v1 # SDK build cache version
on:
pull_request:
branches:
- dev
- staging
- main
jobs:
check_changes:
runs-on: ubuntu-slim
outputs:
should_run: ${{ steps.filter.outputs.should_run }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check if should run
id: filter
run: |
set -e
if [[ "${{ github.base_ref }}" == "main" ]] || [[ "${{ github.base_ref }}" == "staging" ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
echo "Running for ${{ github.base_ref }} - no path filter"
else
# For dev branch, check if relevant files changed
# Fetch the base branch to ensure it's available for comparison
git fetch origin ${{ github.base_ref }} --depth=1
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) || {
echo "Error: Failed to diff against base branch"
exit 1
}
if echo "$CHANGED_FILES" | grep -qE "^(sdk/qrcode/|common/|\.github/workflows/qrcode-sdk-ci\.yml|\.github/actions/|\.github/CI_FORCE_RUN$)"; then
echo "should_run=true" >> $GITHUB_OUTPUT
echo "Running for dev - relevant files changed"
else
echo "should_run=false" >> $GITHUB_OUTPUT
echo "Skipping for dev - no relevant files changed"
fi
fi
# Build dependencies once and cache for other jobs
build:
needs: check_changes
if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Read and sanitize Node.js version
shell: bash
run: |
if [ ! -f .nvmrc ] || [ -z "$(cat .nvmrc)" ]; then
echo "❌ .nvmrc is missing or empty"; exit 1;
fi
VERSION="$(tr -d '\r\n' < .nvmrc)"
VERSION="${VERSION#v}"
if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
echo "Invalid .nvmrc content: '$VERSION'"; exit 1;
fi
echo "NODE_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "NODE_VERSION_SANITIZED=${VERSION//\//-}" >> "$GITHUB_ENV"
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache pnpm store
id: pnpm-cache
uses: ./.github/actions/cache-pnpm
with:
cache-version: ${{ env.GH_PNPM_CACHE_VERSION }}-node-${{ env.NODE_VERSION_SANITIZED }}
- name: Install Dependencies
uses: ./.github/actions/pnpm-install
- name: Build dependencies
shell: bash
run: |
pnpm --filter @selfxyz/common build
pnpm --filter @selfxyz/sdk-common build
pnpm --filter @selfxyz/qrcode build
- name: Cache build artifacts
uses: ./.github/actions/cache-sdk-build
with:
mode: save
cache-version: ${{ env.GH_SDK_CACHE_VERSION }}
# Quality checks job
quality-checks:
runs-on: ubuntu-latest
needs: [check_changes, build]
if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v6
- name: Read and sanitize Node.js version
shell: bash
run: |
if [ ! -f .nvmrc ] || [ -z "$(cat .nvmrc)" ]; then
echo "❌ .nvmrc is missing or empty"; exit 1;
fi
VERSION="$(tr -d '\r\n' < .nvmrc)"
VERSION="${VERSION#v}"
if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
echo "Invalid .nvmrc content: '$VERSION'"; exit 1;
fi
echo "NODE_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "NODE_VERSION_SANITIZED=${VERSION//\//-}" >> "$GITHUB_ENV"
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache pnpm store
id: pnpm-cache
uses: ./.github/actions/cache-pnpm
with:
cache-version: ${{ env.GH_PNPM_CACHE_VERSION }}-node-${{ env.NODE_VERSION_SANITIZED }}
- name: Install Dependencies
uses: ./.github/actions/pnpm-install
- name: Restore build artifacts
id: restore-build
uses: ./.github/actions/cache-sdk-build
with:
mode: restore
cache-version: ${{ env.GH_SDK_CACHE_VERSION }}
fail-on-cache-miss: false
- name: Build dependencies (fallback on cache miss)
if: steps.restore-build.outputs.cache-hit != 'true'
run: |
pnpm --filter @selfxyz/common build
pnpm --filter @selfxyz/sdk-common build
pnpm --filter @selfxyz/qrcode build
- name: Run linter
run: pnpm --filter @selfxyz/qrcode lint:imports:check
- name: Check Prettier formatting
run: pnpm --filter @selfxyz/qrcode lint
- name: Type checking
run: pnpm --filter @selfxyz/qrcode types
- name: Log cache status
run: |
echo "Cache hit results:"
echo "- pnpm store cache hit: ${{ steps.pnpm-cache.outputs.cache-hit }}"
# Build verification job
build-verification:
runs-on: ubuntu-latest
needs: [check_changes, build]
if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v6
- name: Read and sanitize Node.js version
shell: bash
run: |
if [ ! -f .nvmrc ] || [ -z "$(cat .nvmrc)" ]; then
echo "❌ .nvmrc is missing or empty"; exit 1;
fi
VERSION="$(tr -d '\r\n' < .nvmrc)"
VERSION="${VERSION#v}"
if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
echo "Invalid .nvmrc content: '$VERSION'"; exit 1;
fi
echo "NODE_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "NODE_VERSION_SANITIZED=${VERSION//\//-}" >> "$GITHUB_ENV"
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache pnpm store
id: pnpm-cache
uses: ./.github/actions/cache-pnpm
with:
cache-version: ${{ env.GH_PNPM_CACHE_VERSION }}-node-${{ env.NODE_VERSION_SANITIZED }}
- name: Install Dependencies
uses: ./.github/actions/pnpm-install
- name: Restore build artifacts
id: restore-build
uses: ./.github/actions/cache-sdk-build
with:
mode: restore
cache-version: ${{ env.GH_SDK_CACHE_VERSION }}
fail-on-cache-miss: false
- name: Build dependencies (fallback on cache miss)
if: steps.restore-build.outputs.cache-hit != 'true'
run: |
pnpm --filter @selfxyz/common build
pnpm --filter @selfxyz/sdk-common build
pnpm --filter @selfxyz/qrcode build
- name: Verify build artifacts
run: |
echo "Verifying build artifacts..."
ls -la common/dist/
ls -la sdk/sdk-common/dist/
ls -la sdk/qrcode/dist/
echo "✅ Build artifacts verified"
# Integration test job
integration-test:
runs-on: ubuntu-latest
needs: [check_changes, build]
if: github.event.pull_request.draft == false && needs.check_changes.outputs.should_run == 'true'
steps:
- uses: actions/checkout@v6
- name: Read and sanitize Node.js version
shell: bash
run: |
if [ ! -f .nvmrc ] || [ -z "$(cat .nvmrc)" ]; then
echo "❌ .nvmrc is missing or empty"; exit 1;
fi
VERSION="$(tr -d '\r\n' < .nvmrc)"
VERSION="${VERSION#v}"
if ! [[ "$VERSION" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then
echo "Invalid .nvmrc content: '$VERSION'"; exit 1;
fi
echo "NODE_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "NODE_VERSION_SANITIZED=${VERSION//\//-}" >> "$GITHUB_ENV"
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache pnpm store
id: pnpm-cache
uses: ./.github/actions/cache-pnpm
with:
cache-version: ${{ env.GH_PNPM_CACHE_VERSION }}-node-${{ env.NODE_VERSION_SANITIZED }}
- name: Install Dependencies
uses: ./.github/actions/pnpm-install
- name: Restore build artifacts
id: restore-build
uses: ./.github/actions/cache-sdk-build
with:
mode: restore
cache-version: ${{ env.GH_SDK_CACHE_VERSION }}
fail-on-cache-miss: false
- name: Build dependencies (fallback on cache miss)
if: steps.restore-build.outputs.cache-hit != 'true'
run: |
pnpm --filter @selfxyz/common build
pnpm --filter @selfxyz/sdk-common build
pnpm --filter @selfxyz/qrcode build
- name: Check for nested require() in tests
uses: ./.github/actions/check-nested-requires
with:
paths: |
sdk/qrcode/src/
sdk/qrcode/tests/
- name: Run tests
run: pnpm --filter @selfxyz/qrcode test
- name: Test package import
run: |
echo "Testing package import..."
node -e "
const pkg = require('./sdk/qrcode/dist/cjs/index.cjs');
console.log('✅ Package imported successfully');
console.log('Package exports:', Object.keys(pkg));
"
- name: Log cache status
run: |
echo "Cache hit results:"
echo "- pnpm store cache hit: ${{ steps.pnpm-cache.outputs.cache-hit }}"