|
| 1 | +name: QRCode SDK CI |
| 2 | + |
| 3 | +env: |
| 4 | + # Build environment versions |
| 5 | + NODE_VERSION: 22 |
| 6 | + # Cache versioning - increment these to bust caches when needed |
| 7 | + GH_CACHE_VERSION: v1 # Global cache version |
| 8 | + GH_YARN_CACHE_VERSION: v1 # Yarn-specific cache version |
| 9 | + GH_SDK_CACHE_VERSION: v1 # SDK build cache version |
| 10 | + |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + paths: |
| 14 | + - "sdk/qrcode/**" |
| 15 | + - "common/**" |
| 16 | + - ".github/workflows/qrcode-sdk-ci.yml" |
| 17 | + - ".github/actions/**" |
| 18 | + push: |
| 19 | + branches: [main, develop] |
| 20 | + paths: |
| 21 | + - "sdk/qrcode/**" |
| 22 | + - "common/**" |
| 23 | + |
| 24 | +jobs: |
| 25 | + # Build dependencies once and cache for other jobs |
| 26 | + build: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Use Node.js ${{ env.NODE_VERSION }} |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: ${{ env.NODE_VERSION }} |
| 35 | + |
| 36 | + - name: Enable Corepack |
| 37 | + run: corepack enable |
| 38 | + |
| 39 | + - name: Cache Yarn dependencies |
| 40 | + id: yarn-cache |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: | |
| 44 | + .yarn/cache |
| 45 | + node_modules |
| 46 | + sdk/qrcode/node_modules |
| 47 | + common/node_modules |
| 48 | + key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn- |
| 51 | +
|
| 52 | + - name: Install Dependencies |
| 53 | + uses: ./.github/actions/yarn-install |
| 54 | + |
| 55 | + - name: Build dependencies |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + yarn workspace @selfxyz/common build |
| 59 | + yarn workspace @selfxyz/qrcode build |
| 60 | +
|
| 61 | + - name: Cache build artifacts |
| 62 | + uses: actions/cache/save@v4 |
| 63 | + with: |
| 64 | + path: | |
| 65 | + common/dist |
| 66 | + sdk/qrcode/dist |
| 67 | + key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }} |
| 68 | + |
| 69 | + # Quality checks job |
| 70 | + quality-checks: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: build |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Use Node.js ${{ env.NODE_VERSION }} |
| 77 | + uses: actions/setup-node@v4 |
| 78 | + with: |
| 79 | + node-version: ${{ env.NODE_VERSION }} |
| 80 | + |
| 81 | + - name: Enable Corepack |
| 82 | + run: corepack enable |
| 83 | + |
| 84 | + - name: Cache Yarn dependencies |
| 85 | + id: yarn-cache |
| 86 | + uses: actions/cache@v4 |
| 87 | + with: |
| 88 | + path: | |
| 89 | + .yarn/cache |
| 90 | + node_modules |
| 91 | + sdk/qrcode/node_modules |
| 92 | + common/node_modules |
| 93 | + key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }} |
| 94 | + restore-keys: | |
| 95 | + ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn- |
| 96 | +
|
| 97 | + - name: Install Dependencies |
| 98 | + uses: ./.github/actions/yarn-install |
| 99 | + |
| 100 | + - name: Restore build artifacts |
| 101 | + uses: actions/cache/restore@v4 |
| 102 | + with: |
| 103 | + path: | |
| 104 | + common/dist |
| 105 | + sdk/qrcode/dist |
| 106 | + key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }} |
| 107 | + fail-on-cache-miss: true |
| 108 | + |
| 109 | + - name: Run linter |
| 110 | + run: yarn workspace @selfxyz/qrcode lint:imports:check |
| 111 | + |
| 112 | + - name: Check Prettier formatting |
| 113 | + run: yarn workspace @selfxyz/qrcode lint |
| 114 | + |
| 115 | + - name: Type checking |
| 116 | + run: yarn workspace @selfxyz/qrcode types |
| 117 | + |
| 118 | + - name: Log cache status |
| 119 | + run: | |
| 120 | + echo "Cache hit results:" |
| 121 | + echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}" |
| 122 | +
|
| 123 | + # Build verification job |
| 124 | + build-verification: |
| 125 | + runs-on: ubuntu-latest |
| 126 | + needs: build |
| 127 | + steps: |
| 128 | + - uses: actions/checkout@v4 |
| 129 | + |
| 130 | + - name: Use Node.js ${{ env.NODE_VERSION }} |
| 131 | + uses: actions/setup-node@v4 |
| 132 | + with: |
| 133 | + node-version: ${{ env.NODE_VERSION }} |
| 134 | + |
| 135 | + - name: Enable Corepack |
| 136 | + run: corepack enable |
| 137 | + |
| 138 | + - name: Cache Yarn dependencies |
| 139 | + id: yarn-cache |
| 140 | + uses: actions/cache@v4 |
| 141 | + with: |
| 142 | + path: | |
| 143 | + .yarn/cache |
| 144 | + node_modules |
| 145 | + sdk/qrcode/node_modules |
| 146 | + common/node_modules |
| 147 | + key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }} |
| 148 | + restore-keys: | |
| 149 | + ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn- |
| 150 | +
|
| 151 | + - name: Install Dependencies |
| 152 | + uses: ./.github/actions/yarn-install |
| 153 | + |
| 154 | + - name: Restore build artifacts |
| 155 | + uses: actions/cache/restore@v4 |
| 156 | + with: |
| 157 | + path: | |
| 158 | + common/dist |
| 159 | + sdk/qrcode/dist |
| 160 | + key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }} |
| 161 | + fail-on-cache-miss: true |
| 162 | + |
| 163 | + - name: Verify build output |
| 164 | + run: | |
| 165 | + echo "Checking build output structure..." |
| 166 | + ls -la sdk/qrcode/dist/ |
| 167 | + echo "Checking ESM build..." |
| 168 | + ls -la sdk/qrcode/dist/esm/ |
| 169 | + echo "Checking CJS build..." |
| 170 | + ls -la sdk/qrcode/dist/cjs/ |
| 171 | + echo "Checking type definitions..." |
| 172 | + if ! find sdk/qrcode/dist/esm -maxdepth 1 -name '*.d.ts' | grep -q .; then |
| 173 | + echo "No .d.ts files found in dist/esm"; exit 1; |
| 174 | + fi |
| 175 | + find sdk/qrcode/dist/esm -maxdepth 1 -name '*.d.ts' -ls |
| 176 | +
|
| 177 | + - name: Test package exports |
| 178 | + run: | |
| 179 | + echo "Testing package exports..." |
| 180 | + node -e " |
| 181 | + const pkg = require('./sdk/qrcode/package.json'); |
| 182 | + console.log('Package exports:', JSON.stringify(pkg.exports, null, 2)); |
| 183 | + " |
| 184 | +
|
| 185 | + - name: Verify bundle size |
| 186 | + run: yarn workspace @selfxyz/qrcode size-limit |
| 187 | + |
| 188 | + - name: Log cache status |
| 189 | + run: | |
| 190 | + echo "Cache hit results:" |
| 191 | + echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}" |
| 192 | +
|
| 193 | + # Integration test job |
| 194 | + integration-test: |
| 195 | + runs-on: ubuntu-latest |
| 196 | + needs: build |
| 197 | + steps: |
| 198 | + - uses: actions/checkout@v4 |
| 199 | + |
| 200 | + - name: Use Node.js ${{ env.NODE_VERSION }} |
| 201 | + uses: actions/setup-node@v4 |
| 202 | + with: |
| 203 | + node-version: ${{ env.NODE_VERSION }} |
| 204 | + |
| 205 | + - name: Enable Corepack |
| 206 | + run: corepack enable |
| 207 | + |
| 208 | + - name: Cache Yarn dependencies |
| 209 | + id: yarn-cache |
| 210 | + uses: actions/cache@v4 |
| 211 | + with: |
| 212 | + path: | |
| 213 | + .yarn/cache |
| 214 | + node_modules |
| 215 | + sdk/qrcode/node_modules |
| 216 | + common/node_modules |
| 217 | + key: ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn-${{ hashFiles('yarn.lock') }} |
| 218 | + restore-keys: | |
| 219 | + ${{ runner.os }}-${{ env.GH_YARN_CACHE_VERSION }}-node${{ env.NODE_VERSION }}-yarn- |
| 220 | +
|
| 221 | + - name: Install Dependencies |
| 222 | + uses: ./.github/actions/yarn-install |
| 223 | + |
| 224 | + - name: Restore build artifacts |
| 225 | + uses: actions/cache/restore@v4 |
| 226 | + with: |
| 227 | + path: | |
| 228 | + common/dist |
| 229 | + sdk/qrcode/dist |
| 230 | + key: qrcode-sdk-build-${{ env.GH_SDK_CACHE_VERSION }}-${{ github.sha }} |
| 231 | + fail-on-cache-miss: true |
| 232 | + |
| 233 | + - name: Run tests |
| 234 | + run: yarn workspace @selfxyz/qrcode test |
| 235 | + |
| 236 | + - name: Test package import |
| 237 | + run: | |
| 238 | + echo "Testing package import..." |
| 239 | + node -e " |
| 240 | + try { |
| 241 | + const { SelfQRcode, SelfQRcodeWrapper, countries } = require('./sdk/qrcode/dist/cjs/index.cjs'); |
| 242 | + console.log('✅ Package import successful'); |
| 243 | + console.log('Exported components:', Object.keys({ SelfQRcode, SelfQRcodeWrapper, countries })); |
| 244 | + } catch (error) { |
| 245 | + console.error('❌ Package import failed:', error.message); |
| 246 | + process.exit(1); |
| 247 | + } |
| 248 | + " |
| 249 | +
|
| 250 | + - name: Log cache status |
| 251 | + run: | |
| 252 | + echo "Cache hit results:" |
| 253 | + echo "- Yarn cache hit: ${{ steps.yarn-cache.outputs.cache-hit }}" |
0 commit comments