From 84d80999473eaa3e8fbe2a3606a84beafa954d37 Mon Sep 17 00:00:00 2001 From: Kyle Schellen Date: Fri, 8 May 2026 15:40:50 -0400 Subject: [PATCH] move android dev commands under root dev.yml --- .github/CONTRIBUTING.md | 2 +- dev.yml | 82 +++++++++++++++++++ platforms/android/CLAUDE.md | 10 +-- platforms/android/dev.yml | 60 -------------- .../samples/MobileBuyIntegration/README.md | 22 ++--- platforms/android/scripts/apollo_codegen | 2 +- 6 files changed, 100 insertions(+), 78 deletions(-) delete mode 100644 platforms/android/dev.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 72aaa6e1..535167b8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -106,7 +106,7 @@ The library's public API is tracked via a committed baseline at `platforms/andro If your change intentionally modifies the public API: -1. Run `dev api dump` (or `./gradlew :lib:apiDump`) from `platforms/android/` to regenerate the baseline. +1. Run `dev android api dump` from the repo root (or `./gradlew :lib:apiDump` from `platforms/android/`) to regenerate the baseline. 2. Review the diff in `platforms/android/lib/api/lib.api` alongside your code changes. 3. Commit the updated `.api` file in the same PR. diff --git a/dev.yml b/dev.yml index 3c517c7f..fd4bca72 100644 --- a/dev.yml +++ b/dev.yml @@ -3,13 +3,31 @@ name: checkout-kit up: - packages: - quicktype + - rover - ruby - custom: name: Install bundle packages met?: BUNDLE_GEMFILE=platforms/swift/Gemfile bundle check meet: BUNDLE_GEMFILE=platforms/swift/Gemfile bundle install + # Android + - custom: + name: Ensure Android sample app .env files exist + met?: | + ([ -f "./platforms/android/samples/MobileBuyIntegration/.env" ] || exit 1) + meet: cd platforms/android && ./scripts/setup_env.sh + +open: + "GitHub": "https://github.com/Shopify/checkout-kit" + "Issues": "https://github.com/Shopify/checkout-kit/issues" + "PRs": "https://github.com/Shopify/checkout-kit/pulls" + +check: + android-license-headers: cd platforms/android && ./scripts/check_license_headers.rb + android-detekt: cd platforms/android && ./gradlew detekt + android-lint: cd platforms/android && ./gradlew lintRelease commands: + # Repo-wide codegen: desc: "Generate UCP models. Usage: dev codegen " syntax: "" @@ -38,3 +56,67 @@ commands: swift) shift; cd platforms/swift && ./Scripts/apollo_codegen "$@" ;; *) echo "Usage: dev apollo codegen [accelerated|mobile-buy|all]"; exit 1 ;; esac + + # Android + android: + desc: "Android Checkout Kit commands" + subcommands: + build: + desc: Build the library + run: cd platforms/android && ./gradlew :lib:build + subcommands: + samples: + desc: Build all sample applications + run: cd platforms/android/samples/MobileBuyIntegration && ./gradlew build + + test: + desc: Run all tests with clean build + run: cd platforms/android && ./gradlew clean test --console=plain + subcommands: + specific: + desc: Run specific test class + syntax: (e.g. CheckoutBridgeTest) + run: cd platforms/android && ./gradlew :lib:testDebugUnitTest --tests "$1" + + lint: + desc: Check code style and lint (detekt + Android lint) + aliases: [style] + run: cd platforms/android && ./gradlew detekt lintRelease + + fix: + desc: Automatically fix format and lint issues where possible + run: cd platforms/android && ./gradlew detekt --auto-correct + + api: + desc: Validate or update the public API baseline (lib/api/lib.api) + run: | + echo "Usage: dev android api {check|dump}" + echo "" + echo " check Verify public API matches the committed baseline" + echo " dump Regenerate the baseline after intentional public API changes" + subcommands: + check: + desc: Verify public API matches the committed baseline + run: cd platforms/android && ./gradlew :lib:apiCheck + dump: + desc: Regenerate the baseline after intentional public API changes + run: cd platforms/android && ./gradlew :lib:apiDump + + check: + desc: Run all Android checks (license headers, detekt, android lint) + run: | + set -e + cd platforms/android + ./scripts/check_license_headers.rb + ./gradlew detekt + ./gradlew lintRelease + subcommands: + license-headers: + desc: Check MIT license headers in source files + run: cd platforms/android && ./scripts/check_license_headers.rb + detekt: + desc: Run detekt static analysis + run: cd platforms/android && ./gradlew detekt + android-lint: + desc: Run Android lint + run: cd platforms/android && ./gradlew lintRelease diff --git a/platforms/android/CLAUDE.md b/platforms/android/CLAUDE.md index c0a439b1..daf97767 100644 --- a/platforms/android/CLAUDE.md +++ b/platforms/android/CLAUDE.md @@ -52,7 +52,7 @@ The library's public API is captured in `lib/api/lib.api` (managed by the [binar If a change intentionally modifies public API (adding, removing, or changing any public class, method, field, or property): -1. Run `./gradlew :lib:apiDump` (or `dev api dump`) to regenerate the baseline. +1. Run `./gradlew :lib:apiDump` (or `dev android api dump`) to regenerate the baseline. 2. Review the diff in `lib/api/lib.api` — it's the single best indicator of consumer impact, and reviewers will focus on it. 3. Commit the updated `.api` file in the same PR as the code change. @@ -60,10 +60,10 @@ If `apiCheck` fails and you did *not* intend to change public API, the diff tell ## Common commands -- Tests: `./gradlew :lib:test` (or `dev test`) -- API surface: `./gradlew :lib:apiCheck` / `./gradlew :lib:apiDump` (or `dev api check` / `dev api dump`) -- Lint: `./gradlew detekt lintRelease` (or `dev style`) -- Auto-fix lint: `./gradlew detekt --auto-correct` (or `dev fix`) +- Tests: `./gradlew :lib:test` (or `dev android test`) +- API surface: `./gradlew :lib:apiCheck` / `./gradlew :lib:apiDump` (or `dev android api check` / `dev android api dump`) +- Lint: `./gradlew detekt lintRelease` (or `dev android lint`) +- Auto-fix lint: `./gradlew detekt --auto-correct` (or `dev android fix`) - Full local verification: `./gradlew :lib:clean :lib:test :lib:detekt :lib:lintRelease :lib:assembleRelease` - Sample app build (from `samples/MobileBuyIntegration/`): `./gradlew assembleDebug` diff --git a/platforms/android/dev.yml b/platforms/android/dev.yml deleted file mode 100644 index 5d4fdb5d..00000000 --- a/platforms/android/dev.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: checkout-kit-android - -type: android - -up: - - ruby - - packages: - - rover - - custom: - name: Ensure sample app .env files exists - met?: | - ([ -f "./samples/MobileBuyIntegration/.env" ] || exit 1) - meet: ./scripts/setup_env.sh - -commands: - build: - desc: Build the library - run: ./gradlew :lib:build - subcommands: - samples: - desc: Build all sample applications - run: cd samples/MobileBuyIntegration && ./gradlew build - - test: - subcommands: - specific: - desc: Run specific test class - syntax: (e.g. CheckoutBridgeTest) - run: ./gradlew :lib:testDebugUnitTest --tests "$1" - desc: Run all tests with clean build - run: ./gradlew clean test --console=plain - - style: - desc: Run code formatting and linting - aliases: [lint] - run: ./gradlew detekt lintRelease - - fix: - desc: Automatically fix format and lint issues where possible - run: ./gradlew detekt --auto-correct - - api: - desc: Validate or update the public API baseline (lib/api/lib.api) - subcommands: - check: - desc: Verify public API matches the committed baseline - run: ./gradlew :lib:apiCheck - dump: - desc: Regenerate the baseline after intentional public API changes - run: ./gradlew :lib:apiDump - -check: - license-headers: ./scripts/check_license_headers.rb - detekt: ./gradlew detekt - android-lint: ./gradlew lintRelease - -open: - "GitHub": "https://github.com/Shopify/checkout-kit" - "Issues": "https://github.com/Shopify/checkout-kit/issues" - "PRs": "https://github.com/Shopify/checkout-kit/pulls" diff --git a/platforms/android/samples/MobileBuyIntegration/README.md b/platforms/android/samples/MobileBuyIntegration/README.md index a9186356..66158cdf 100644 --- a/platforms/android/samples/MobileBuyIntegration/README.md +++ b/platforms/android/samples/MobileBuyIntegration/README.md @@ -73,10 +73,10 @@ API_VERSION=2025-10 ### 2. Download the new schema -The schema defines what types and fields are available in the API. Run from the **android module root** (`platforms/android/`): +The schema defines what types and fields are available in the API. Run from the **repo root** (`checkout-kit/`): ```bash -dev apollo download_schema +dev apollo download_schema android ``` This uses [`rover`](https://www.apollographql.com/docs/rover/) to introspect your store's Storefront API at the configured version and writes `schema.graphqls` into `app/src/main/graphql/`. @@ -106,10 +106,10 @@ query FetchProducts(...) { From the **repo root**: ```bash -dev apollo codegen +dev apollo codegen android ``` -This reads the schema + your `.graphql` files and regenerates the Kotlin code in `app/build/generated/source/apollo/`. The command also runs `dev style` to check formatting. +This reads the schema + your `.graphql` files and regenerates the Kotlin code in `app/build/generated/source/apollo/`. The command also runs `dev android lint` to check formatting. ### 5. Build and fix any issues @@ -121,16 +121,16 @@ If the new schema removed or renamed fields, you'll get compile errors pointing ## Dev commands reference -All commands are run from the **android module root** (`platforms/android/`): +All commands are run from the **repo root** (`checkout-kit/`): | Command | Description | |---------|-------------| -| `dev apollo download_schema` | Download the Storefront API schema for this sample app | -| `dev apollo codegen` | Regenerate Kotlin types from `.graphql` files | -| `dev style` | Run detekt + Android lint checks | -| `dev build` | Build the library | -| `dev build samples` | Build all sample applications | -| `dev test` | Run all tests | +| `dev apollo download_schema android` | Download the Storefront API schema for this sample app | +| `dev apollo codegen android` | Regenerate Kotlin types from `.graphql` files | +| `dev android lint` | Run detekt + Android lint checks | +| `dev android build` | Build the library | +| `dev android build samples` | Build all sample applications | +| `dev android test` | Run all tests | ## Key files diff --git a/platforms/android/scripts/apollo_codegen b/platforms/android/scripts/apollo_codegen index 444a3535..22ed987d 100755 --- a/platforms/android/scripts/apollo_codegen +++ b/platforms/android/scripts/apollo_codegen @@ -14,4 +14,4 @@ else fi cd ../.. -/opt/dev/bin/dev style +/opt/dev/bin/dev android lint