Files
self/.github/workflows/qrcode-sdk-ci.yml
Justin Hernandez 2ed8bcfe53 feat: modernize sdk/qrcode build pipeline (#872)
* Modernize qrcode build

* chore(qrcode): add lint helpers

* fix sdk qrcode

* add new qrcode ci

* fix formatting

* qrcode fixes

* fixes

* fixes rd2

* enable corepack

* enable corepack

* build caching

* update caching

* cr feedback
2025-08-10 21:22:02 -07:00

254 lines
7.6 KiB
YAML

name: QRCode SDK CI
env:
# Build environment versions
NODE_VERSION: 22
# Cache versioning - increment these to bust caches when needed
GH_CACHE_VERSION: v1 # Global cache version
GH_YARN_CACHE_VERSION: v1 # Yarn-specific cache version
GH_SDK_CACHE_VERSION: v1 # SDK build cache version
on:
pull_request:
paths:
- "sdk/qrcode/**"
- "common/**"
- ".github/workflows/qrcode-sdk-ci.yml"
- ".github/actions/**"
push:
branches: [main, develop]
paths:
- "sdk/qrcode/**"
- "common/**"
jobs:
# Build dependencies once and cache for other jobs
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache Yarn dependencies
id: yarn-cache
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
sdk/qrcode/node_modules
common/node_modules
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
- name: Install Dependencies
uses: ./.github/actions/yarn-install
- name: Build dependencies
shell: bash
run: |
yarn workspace @selfxyz/common build
yarn workspace @selfxyz/qrcode build
- name: Cache build artifacts
uses: actions/cache/save@v4
with:
path: |
common/dist
sdk/qrcode/dist
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
# Quality checks job
quality-checks:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache Yarn dependencies
id: yarn-cache
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
sdk/qrcode/node_modules
common/node_modules
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
- name: Install Dependencies
uses: ./.github/actions/yarn-install
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
common/dist
sdk/qrcode/dist
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Run linter
run: yarn workspace @selfxyz/qrcode lint:imports:check
- name: Check Prettier formatting
run: yarn workspace @selfxyz/qrcode lint
- name: Type checking
run: yarn workspace @selfxyz/qrcode types
- name: Log cache status
run: |
echo "Cache hit results:"
echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}"
# Build verification job
build-verification:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache Yarn dependencies
id: yarn-cache
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
sdk/qrcode/node_modules
common/node_modules
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
- name: Install Dependencies
uses: ./.github/actions/yarn-install
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
common/dist
sdk/qrcode/dist
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Verify build output
run: |
echo "Checking build output structure..."
ls -la sdk/qrcode/dist/
echo "Checking ESM build..."
ls -la sdk/qrcode/dist/esm/
echo "Checking CJS build..."
ls -la sdk/qrcode/dist/cjs/
echo "Checking type definitions..."
if ! find sdk/qrcode/dist/esm -maxdepth 1 -name '*.d.ts' | grep -q .; then
echo "No .d.ts files found in dist/esm"; exit 1;
fi
find sdk/qrcode/dist/esm -maxdepth 1 -name '*.d.ts' -ls
- name: Test package exports
run: |
echo "Testing package exports..."
node -e "
const pkg = require('./sdk/qrcode/package.json');
console.log('Package exports:', JSON.stringify(pkg.exports, null, 2));
"
- name: Verify bundle size
run: yarn workspace @selfxyz/qrcode size-limit
- name: Log cache status
run: |
echo "Cache hit results:"
echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}"
# Integration test job
integration-test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable Corepack
run: corepack enable
- name: Cache Yarn dependencies
id: yarn-cache
uses: actions/cache@v4
with:
path: |
.yarn/cache
node_modules
sdk/qrcode/node_modules
common/node_modules
key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-
- name: Install Dependencies
uses: ./.github/actions/yarn-install
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
common/dist
sdk/qrcode/dist
key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }}
fail-on-cache-miss: true
- name: Run tests
run: yarn workspace @selfxyz/qrcode test
- name: Test package import
run: |
echo "Testing package import..."
node -e "
try {
const { SelfQRcode, SelfQRcodeWrapper, countries } = require('./sdk/qrcode/dist/cjs/index.cjs');
console.log('✅ Package import successful');
console.log('Exported components:', Object.keys({ SelfQRcode, SelfQRcodeWrapper, countries }));
} catch (error) {
console.error('❌ Package import failed:', error.message);
process.exit(1);
}
"
- name: Log cache status
run: |
echo "Cache hit results:"
echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}"