Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,23 @@ repos:
# prek run sync-java-sdk-dag-schema --hook-stage manual
stages: ['manual']
files: ^java-sdk/sdk/schema/dag-schema\.json$
- id: check-go-sdk-spec-drift
name: Check Go SDK Dag spec structs against the serialization schema
description: "Regenerate go-sdk/airflow/spec.gen.go and fail when the committed file differs"
entry: ./scripts/ci/prek/check_go_sdk_spec_drift.py
- id: check-go-sdk-generated-drift
name: Check Go SDK generated files against the schemas they generate from
description: "Regenerate the Dag specs and the coordinator-protocol models, and fail when a committed file differs"
entry: ./scripts/ci/prek/check_go_sdk_generated_drift.py
# golang so prek provisions the toolchain the generators need, the way the
# other checks that shell out to `go` in go-sdk get theirs.
language: golang
files: >
(?x)
^airflow-core/src/airflow/serialization/schema\.json$|
^task-sdk/src/airflow/sdk/execution_time/schema/schema\.json$|
^go-sdk/airflow/spec\.gen\.go$|
^go-sdk/airflow/spec\.go$|
^go-sdk/internal/genspec/.*\.go$|
^go-sdk/internal/genlicense/.*\.go$|
^scripts/ci/prek/check_go_sdk_spec_drift\.py$
^go-sdk/pkg/execution/genmodels/.*\.go$|
^scripts/ci/prek/check_go_sdk_generated_drift\.py$
pass_filenames: false
require_serial: true
- id: check-go-version-in-sync
Expand Down
7 changes: 5 additions & 2 deletions go-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ SDK to a newer schema version:
2. Run `just generate-models`.

`TestSupervisorSchemaVersionMatchesSnapshot` fails when the constant and the snapshot's `api_version`
drift, so a missed bump is caught by `go test` instead of needing a dedicated prek hook.
drift, so a missed bump is caught by `go test`. A snapshot can also grow a field without the
`api_version` moving, which leaves the models behind with nothing failing — msgpack drops a field the
struct does not declare — so the `check-go-sdk-generated-drift` prek hook regenerates them and fails
when the committed files differ.

## Regenerating the Dag and task specs

Expand All @@ -417,7 +420,7 @@ it into the authoring shape, each entry carrying the reason it exists:
are hand-written in [`airflow/spec.go`](./airflow/spec.go);
`TestTriggerRuleConstantsMatchPython` is their tripwire against Airflow's own enum.

The `check-go-sdk-spec-drift` prek hook regenerates the file and fails when the committed one
The `check-go-sdk-generated-drift` prek hook regenerates the file and fails when the committed one
differs, so a schema change that never reached Go cannot merge.

## Architectural decisions
Expand Down
143 changes: 74 additions & 69 deletions go-sdk/pkg/execution/genmodels/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading