Skip to content

Commit 9e7cd44

Browse files
Add breaking change detection CI check
Adds a new 'major-change-check' job to the PR workflow that detects potential breaking changes by comparing the branch against main. TEST: Renamed pos.embedded -> pos.is_embedded in POS schema to verify Zod schema breaking change detection. Revert before merging.
1 parent 2f9bc85 commit 9e7cd44

5 files changed

Lines changed: 454 additions & 2 deletions

File tree

.github/workflows/tests-pr.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,65 @@ jobs:
287287
header: Type-diff
288288
message: ${{ steps.type-diff.outputs.report }}
289289
recreate: true
290+
291+
major-change-check:
292+
if: github.event.pull_request.head.repo.full_name == github.repository
293+
name: 'Breaking change detection'
294+
runs-on: ubuntu-latest
295+
timeout-minutes: 30
296+
outputs:
297+
has_breaking_changes: ${{ steps.read-results.outputs.has_breaking_changes }}
298+
steps:
299+
- uses: actions/checkout@v3
300+
with:
301+
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
302+
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
303+
fetch-depth: 1
304+
- name: Setup deps
305+
uses: ./.github/actions/setup-cli-deps
306+
with:
307+
node-version: ${{ env.DEFAULT_NODE_VERSION }}
308+
- name: Build
309+
run: pnpm nx run-many --all --skip-nx-cache --target=build --output-style=stream
310+
- name: Check for breaking changes
311+
working-directory: workspace
312+
run: pnpm nx run major-change-check
313+
- name: Read results
314+
id: read-results
315+
run: |
316+
HAS_BREAKING=$(cat workspace/has-breaking-changes)
317+
echo "has_breaking_changes=$HAS_BREAKING" >> "$GITHUB_OUTPUT"
318+
if [ "$HAS_BREAKING" = "true" ] && [ -f workspace/breaking-changes-report.md ]; then
319+
{
320+
echo 'report<<BREAKING_CHANGES_EOF'
321+
cat workspace/breaking-changes-report.md
322+
echo 'BREAKING_CHANGES_EOF'
323+
} >> "$GITHUB_OUTPUT"
324+
fi
325+
- uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
326+
if: steps.read-results.outputs.has_breaking_changes == 'true'
327+
with:
328+
header: Breaking-change-detection
329+
message: ${{ steps.read-results.outputs.report }}
330+
recreate: true
331+
- uses: marocchino/sticky-pull-request-comment@fcf6fe9e4a0409cd9316a5011435be0f3327f1e1 # v2.3.1
332+
if: steps.read-results.outputs.has_breaking_changes != 'true'
333+
with:
334+
header: Breaking-change-detection
335+
delete: true
336+
- name: Fail if breaking changes detected
337+
if: steps.read-results.outputs.has_breaking_changes == 'true'
338+
run: |
339+
echo '::error::Breaking changes detected. A member of @shopify/dev_experience must approve the breaking-change-approval environment.'
340+
exit 1
341+
342+
major-change-approval:
343+
name: 'Breaking change approval'
344+
needs: major-change-check
345+
if: always() && needs.major-change-check.outputs.has_breaking_changes == 'true'
346+
runs-on: ubuntu-latest
347+
timeout-minutes: 5
348+
environment: breaking-change-approval
349+
steps:
350+
- name: Approved
351+
run: echo '✅ Breaking changes approved by dev_experience team member'

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,7 @@ packages/cli-kit/src/cli/api/graphql/*/*_schema.graphql
206206

207207
# Local dev alias scripts
208208
bin/p
209+
210+
# Breaking change check outputs
211+
workspace/breaking-changes-report.md
212+
workspace/has-breaking-changes

packages/app/src/cli/models/extensions/specifications/app_config_point_of_sale.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import {zod} from '@shopify/cli-kit/node/schema'
55
const PosConfigurationSchema = BaseSchemaWithoutHandle.extend({
66
pos: zod
77
.object({
8-
embedded: zod.boolean({invalid_type_error: 'Value must be Boolean'}),
8+
is_embedded: zod.boolean({invalid_type_error: 'Value must be Boolean'}),
99
})
1010
.optional(),
1111
})
1212

1313
export const PosSpecIdentifier = 'point_of_sale'
1414

1515
const PosTransformConfig: TransformationConfig = {
16-
embedded: 'pos.embedded',
16+
is_embedded: 'pos.is_embedded',
1717
}
1818

1919
const appPOSSpec = createConfigExtensionSpecification({

workspace/project.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
"commands": ["node src/type-diff.js"],
2222
"cwd": "workspace"
2323
}
24+
},
25+
"major-change-check": {
26+
"executor": "nx:run-commands",
27+
"dependsOn": ["^build"],
28+
"options": {
29+
"commands": ["node src/major-change-check.js"],
30+
"cwd": "workspace"
31+
}
2432
}
2533
}
2634
}

0 commit comments

Comments
 (0)