Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native_assets_cli] Hook schemas #2064

Merged
merged 4 commits into from
Mar 10, 2025
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
61 changes: 61 additions & 0 deletions .github/workflows/hook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# CI for the native_* packages.
#
# Combined into a single workflow so that deps are configured and installed once.

name: hook
permissions: read-all

on:
pull_request:
# No `branches:` to enable stacked PRs on GitHub.
paths:
- ".github/workflows/hook.yaml"
- "pkgs/hook/**"
- "pkgs/code_assets/**"
- "pkgs/data_assets/**"
push:
branches: [main]
paths:
- ".github/workflows/native.yaml"
- "pkgs/hook/**"
- "pkgs/code_assets/**"
- "pkgs/data_assets/**"
schedule:
- cron: "0 0 * * 0" # weekly

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
sdk: [dev]
package: [hook, code_assets, data_assets]

runs-on: ${{ matrix.os }}-latest

defaults:
run:
working-directory: pkgs/${{ matrix.package }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}

- run: dart pub get

- run: dart analyze --fatal-infos

- run: dart format --output=none --set-exit-if-changed .

- run: dart test

- run: |
dart tool/normalize.dart
git diff --exit-code
working-directory: pkgs/${{ matrix.package }}/
if: ${{ matrix.package == 'hook' && matrix.sdk == 'dev' }}

17 changes: 17 additions & 0 deletions pkgs/code_assets/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
errors:
todo: ignore
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- dangling_library_doc_comments
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_in_for_each
- prefer_final_locals
17 changes: 17 additions & 0 deletions pkgs/code_assets/doc/schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
These schemas document the protocol for build and link hooks with code assets.

* If you are a hook author, you should likely be using a hook-helper-package
Dart API (such as `package:native_toolchain_c`) instead of directly consuming
and producing JSON.
* If you are a hook-helper-package author, you should likely be using a
hook-helper-package's Dart API (such as `package:native_assets_cli`) which
abstracts away from syntactic changes. If you do want to directly interact
with the JSON, you can find the relevant schemas in [hook/](hook/).
* If you are an SDK author, you should likely be using the SDK helper package
(`package:native_assets_builder`) which abstracts away from syntactic changes.
If you do want to directly interact with the JSON, you can find the relevant
schemas in [sdk/](sdk/).

These schemas are an extension of the base protocol:

* [`package:hook`/doc/schema](../../../hook/doc/schema/)
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/hook/build_input.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:hook BuildInput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/BuildInput"
}
]
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/hook/build_output.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:hook BuildOutput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/BuildOutput"
}
]
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/hook/link_input.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:hook LinkInput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/LinkInput"
}
]
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/hook/link_output.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:hook LinkOutput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/LinkOutput"
}
]
}
86 changes: 86 additions & 0 deletions pkgs/code_assets/doc/schema/hook/shared_definitions.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:hook shared definitions",
"allOf": [
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json"
},
{
"$ref": "../shared/shared_definitions.schema.json#"
}
],
"definitions": {
"BuildInput": {
"allOf": [
{
"$ref": "#/definitions/HookInput"
},
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json#/definitions/BuildInput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/BuildInput"
}
]
},
"BuildOutput": {
"allOf": [
{
"$ref": "#/definitions/HookOutput"
},
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json#/definitions/BuildOutput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/BuildOutput"
}
]
},
"HookInput": {
"allOf": [
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json#/definitions/HookInput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/HookInput"
}
]
},
"HookOutput": {
"allOf": [
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json#/definitions/HookOutput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/HookOutput"
}
]
},
"LinkInput": {
"allOf": [
{
"$ref": "#/definitions/HookInput"
},
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json#/definitions/LinkInput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/LinkInput"
}
]
},
"LinkOutput": {
"allOf": [
{
"$ref": "#/definitions/HookOutput"
},
{
"$ref": "../../../../hook/doc/schema/hook/shared_definitions.schema.json#/definitions/LinkOutput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/LinkOutput"
}
]
}
}
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/sdk/build_input.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:sdk BuildInput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/BuildInput"
}
]
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/sdk/build_output.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:sdk BuildOutput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/BuildOutput"
}
]
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/sdk/link_input.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:sdk LinkInput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/LinkInput"
}
]
}
9 changes: 9 additions & 0 deletions pkgs/code_assets/doc/schema/sdk/link_output.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:sdk LinkOutput",
"allOf": [
{
"$ref": "shared_definitions.schema.json#/definitions/LinkOutput"
}
]
}
86 changes: 86 additions & 0 deletions pkgs/code_assets/doc/schema/sdk/shared_definitions.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"title": "package:code_assets party:sdk shared definitions",
"allOf": [
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json"
},
{
"$ref": "../shared/shared_definitions.schema.json#"
}
],
"definitions": {
"BuildInput": {
"allOf": [
{
"$ref": "#/definitions/HookInput"
},
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json#/definitions/BuildInput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/BuildInput"
}
]
},
"BuildOutput": {
"allOf": [
{
"$ref": "#/definitions/HookOutput"
},
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json#/definitions/BuildOutput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/BuildOutput"
}
]
},
"HookInput": {
"allOf": [
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json#/definitions/HookInput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/HookInput"
}
]
},
"HookOutput": {
"allOf": [
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json#/definitions/HookOutput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/HookOutput"
}
]
},
"LinkInput": {
"allOf": [
{
"$ref": "#/definitions/HookInput"
},
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json#/definitions/LinkInput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/LinkInput"
}
]
},
"LinkOutput": {
"allOf": [
{
"$ref": "#/definitions/HookOutput"
},
{
"$ref": "../../../../hook/doc/schema/sdk/shared_definitions.schema.json#/definitions/LinkOutput"
},
{
"$ref": "../shared/shared_definitions.schema.json#/definitions/LinkOutput"
}
]
}
}
}
Loading