|
| 1 | +name: Design index cloud smoke |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [codex/design-index-cloud-smoke] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: design-index-cloud-smoke |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +env: |
| 15 | + ENGINE: 7f2c2fd67fda51ff9bd46af1cd5f79ad70d7f75d |
| 16 | + |
| 17 | +jobs: |
| 18 | + baseline: |
| 19 | + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} |
| 20 | + timeout-minutes: 15 |
| 21 | + outputs: |
| 22 | + key: ${{ steps.identity.outputs.key }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 25 | + with: |
| 26 | + ref: ${{ env.ENGINE }} |
| 27 | + fetch-depth: 0 |
| 28 | + persist-credentials: false |
| 29 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 |
| 30 | + with: |
| 31 | + bun-version: 1.4.1 |
| 32 | + - run: bun install --frozen-lockfile --ignore-scripts |
| 33 | + - id: identity |
| 34 | + run: echo "key=design-index-smoke-$(bun --no-env-file scripts/design-diff/index-cli.ts --identity)-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT" |
| 35 | + - name: Build and checkpoint baseline |
| 36 | + env: |
| 37 | + CACHE: ${{ runner.temp }}/index-cache |
| 38 | + METRICS: ${{ runner.temp }}/baseline.metrics.json |
| 39 | + run: bun run design:index --ref "$ENGINE" --cache-dir "$CACHE" --metrics "$METRICS" > /dev/null 2>&1 |
| 40 | + - name: Save immutable baseline cache |
| 41 | + uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 |
| 42 | + with: |
| 43 | + path: ${{ runner.temp }}/index-cache |
| 44 | + key: ${{ steps.identity.outputs.key }} |
| 45 | + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 46 | + if: always() |
| 47 | + with: |
| 48 | + name: index-smoke-baseline-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }} |
| 49 | + path: ${{ runner.temp }}/baseline.metrics.json |
| 50 | + retention-days: 7 |
| 51 | + if-no-files-found: error |
| 52 | + |
| 53 | + comparison: |
| 54 | + needs: baseline |
| 55 | + runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }} |
| 56 | + timeout-minutes: 15 |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 59 | + with: |
| 60 | + ref: ${{ env.ENGINE }} |
| 61 | + fetch-depth: 0 |
| 62 | + persist-credentials: false |
| 63 | + - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 |
| 64 | + with: |
| 65 | + bun-version: 1.4.1 |
| 66 | + - run: bun install --frozen-lockfile --ignore-scripts |
| 67 | + - name: Restore baseline to isolated job |
| 68 | + id: cache |
| 69 | + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 |
| 70 | + with: |
| 71 | + path: ${{ runner.temp }}/index-cache |
| 72 | + key: ${{ needs.baseline.outputs.key }} |
| 73 | + fail-on-cache-miss: true |
| 74 | + - name: Verify cache delivery |
| 75 | + env: |
| 76 | + CACHE_HIT: ${{ steps.cache.outputs.cache-hit }} |
| 77 | + run: test "$CACHE_HIT" = true |
| 78 | + - name: Prepare source-only synthetic commits |
| 79 | + id: fixtures |
| 80 | + env: |
| 81 | + REPORTS: ${{ runner.temp }}/reports |
| 82 | + run: | |
| 83 | + python3 - <<'PY' |
| 84 | + import json, os, pathlib, subprocess |
| 85 | + base = os.environ['ENGINE'] |
| 86 | + output = pathlib.Path(os.environ['REPORTS']) |
| 87 | + output.mkdir() |
| 88 | + env = {**os.environ, 'GIT_INDEX_FILE': str(output / 'source-index'), 'GIT_AUTHOR_NAME': 'Design index smoke', 'GIT_AUTHOR_EMAIL': 'design-index@example.invalid', 'GIT_COMMITTER_NAME': 'Design index smoke', 'GIT_COMMITTER_EMAIL': 'design-index@example.invalid', 'GIT_AUTHOR_DATE': '2000-01-01T00:00:00Z', 'GIT_COMMITTER_DATE': '2000-01-01T00:00:00Z'} |
| 89 | + def git(*args, data=None): |
| 90 | + return subprocess.check_output(['git', *args], input=data, env=env, stderr=subprocess.DEVNULL).decode().strip() |
| 91 | + file = 'packages/emcn/src/components/button/button.tsx' |
| 92 | + source = git('show', base + ':' + file) |
| 93 | + heads = {} |
| 94 | + for name, before, after in [('shape', 'rounded-[5px]', 'rounded-none'), ('comment', 'a section-header action.', 'an action in a section header.')]: |
| 95 | + assert source.count(before) == 1 |
| 96 | + blob = git('hash-object', '-w', '--stdin', data=source.replace(before, after).encode()) |
| 97 | + git('read-tree', base) |
| 98 | + git('update-index', '--add', '--cacheinfo', '100644', blob, file) |
| 99 | + tree = git('write-tree') |
| 100 | + heads[name] = git('commit-tree', tree, '-p', base, data=b'Isolated design index fixture\n') |
| 101 | + (output / 'comparison.json').write_text(json.dumps({'engine': base, 'heads': heads, 'workflow': os.environ['GITHUB_SHA'], 'run': os.environ['GITHUB_RUN_ID'], 'attempt': os.environ['GITHUB_RUN_ATTEMPT']}, indent=2)) |
| 102 | + with open(os.environ['GITHUB_OUTPUT'], 'a') as stream: |
| 103 | + for name, head in heads.items(): stream.write(f'{name}={head}\n') |
| 104 | + (output / 'source-index').unlink() |
| 105 | + PY |
| 106 | + - name: Run cached, uncached, repeated and clean comparisons |
| 107 | + env: |
| 108 | + SHAPE: ${{ steps.fixtures.outputs.shape }} |
| 109 | + COMMENT: ${{ steps.fixtures.outputs.comment }} |
| 110 | + CACHE: ${{ runner.temp }}/index-cache |
| 111 | + REPORTS: ${{ runner.temp }}/reports |
| 112 | + run: | |
| 113 | + bun run design:diff --base "$ENGINE" --head "$SHAPE" --cache-dir "$CACHE" --output "$REPORTS/warm.json" --metrics "$REPORTS/warm.metrics.json" > /dev/null 2>&1 |
| 114 | + bun run design:diff --base "$ENGINE" --head "$SHAPE" --no-cache --output "$REPORTS/uncached.json" --metrics "$REPORTS/uncached.metrics.json" > /dev/null 2>&1 |
| 115 | + bun run design:diff --base "$ENGINE" --head "$SHAPE" --cache-dir "$CACHE" --output "$REPORTS/repeat.json" --metrics "$REPORTS/repeat.metrics.json" > /dev/null 2>&1 |
| 116 | + bun run design:diff --base "$ENGINE" --head "$COMMENT" --cache-dir "$CACHE" --output "$REPORTS/comment.json" --metrics "$REPORTS/comment.metrics.json" > /dev/null 2>&1 |
| 117 | + if bun run design:diff --base missing-revision --head "$SHAPE" --cache-dir "$CACHE" --output "$REPORTS/failure.json" > /dev/null 2>&1; then exit 1; fi |
| 118 | + - name: Verify results without logging findings |
| 119 | + env: |
| 120 | + REPORTS: ${{ runner.temp }}/reports |
| 121 | + run: | |
| 122 | + python3 - <<'PY' |
| 123 | + import json, os, pathlib |
| 124 | + root = pathlib.Path(os.environ['REPORTS']) |
| 125 | + load = lambda name: json.loads((root / name).read_text()) |
| 126 | + assert (root/'warm.json').read_bytes() == (root/'uncached.json').read_bytes() == (root/'repeat.json').read_bytes() |
| 127 | + report = load('warm.json'); identity = load('comparison.json') |
| 128 | + assert (report['schemaVersion'], report['engineVersion'], report['policyVersion']) == ('3.0.0', '0.6.0', '5.0.0') |
| 129 | + assert report['commits'] == {'base': identity['engine'], 'head': identity['heads']['shape'], 'mergeBase': identity['engine']} |
| 130 | + assert report['status'] == 'completed' and report['flagged'] is True |
| 131 | + groups = [f for f in report['findings'] if f['source']['after']['file'] == 'packages/emcn/src/components/button/button.tsx' and f['decision'] == 'flag'] |
| 132 | + assert len(groups) == 1 and 'shape-effects' in groups[0]['categories'] |
| 133 | + assert groups[0]['impact']['after']['referenceCount'] > 0 |
| 134 | + assert load('comment.json')['flagged'] is False |
| 135 | + assert load('failure.json')['status'] == 'failed' and load('failure.json')['flagged'] is None |
| 136 | + assert load('warm.metrics.json')['counters']['cache.hits'] > 0 |
| 137 | + result = {'status': 'passed', 'parity': True, 'cacheRestored': True, 'checks': ['shape-evidence', 'resolved-consumers', 'comment-clean', 'missing-revision-failure'], 'metrics': {name: load(name+'.metrics.json') for name in ['warm', 'uncached', 'repeat']}, **identity} |
| 138 | + (root/'test-results.json').write_text(json.dumps(result, indent=2)) |
| 139 | + print('Design index cloud smoke passed: cache restore, parity, detection and failure handling') |
| 140 | + PY |
| 141 | + - name: Retain reports and metrics |
| 142 | + if: always() |
| 143 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 144 | + with: |
| 145 | + name: index-smoke-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }} |
| 146 | + path: ${{ runner.temp }}/reports/*.json |
| 147 | + retention-days: 7 |
| 148 | + if-no-files-found: error |
0 commit comments