Skip to content

ci: one verified tool fetch, every check reported; no lint baselines - #16

Merged
ardmn merged 8 commits into
mainfrom
ardmn/ci-lint-robustness
Nov 24, 2026
Merged

ardmn merged 8 commits into
mainfrom
ardmn/ci-lint-robustness

Conversation

@ardmn

@ardmn ardmn commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

CI (ardmn/work#15)

  • .github/actions/fetch-tool (with scripts/fetch-tool.ts and scripts/verified-download.ts, Node built-ins only) installs ktlint, detekt, SwiftFormat, SwiftLint and gitleaks: cache keyed by URL + SHA-256, SHA-256 checked before use, a corrupted cached copy is replaced with a warning, saved right after verification. It replaces five copies of curl + sha256sum; scripts/lib.ts (bundletool) uses the same downloader.
  • Tools are fetched before any check; every lint check is its own step and runs unless what it needs is missing, so one failure no longer hides the others. native-tests runs Gradle with --continue.

Baselines (ardmn/work#16)

  • ESLint bulk suppressions 94 → 0, detekt baseline 9 → 0, Android Lint baseline 2 → 0. 43 ESLint findings fixed in code; two rule settings: node:test top-level calls are known-safe for no-floating-promises, numbers allowed in template literals (as in recommendedTypeChecked). What must stay is suppressed inline with a reason (ESLint 4, detekt 8, Android Lint 1).
  • Behaviour: describe() in convert errors no longer prints a function's source; PerformanceScreen and getInitialURL failures are logged instead of unhandled rejections; unused productCardJson removed from the demo bundles.

Fixes ardmn/work#15, ardmn/work#16

Summary by CodeRabbit

  • New Features
    • CI now verifies downloaded tools against pinned checksums and reuses cached downloads.
  • Bug Fixes
    • Improved error reporting and recovery across demos, performance runs, and JSON conversion.
    • Added safer fallbacks for network document selection and generated native values.
  • Chores
    • Removed lint baselines and shifted static analysis to fixing findings or using targeted, reasoned suppressions.
    • Updated contributor guidance and expanded tests for verified downloads and input validation.

…plates

51 of the 94 bulk-suppressed violations were two rule settings, not code problems:

- no-floating-promises flagged every top-level node:test test() call. The promise it returns only
  reports completion and is fulfilled whether the test passes or fails; the runner tracks the test.
  allowForKnownSafeCalls names node:test's test/it/describe/suite.
- restrict-template-expressions (strictTypeChecked) rejects numbers. A number has one string form;
  booleans, null, arrays and objects stay errors, as before.

Bulk suppressions count per file and rule, so a fixed violation can hide a new one in the same
file. Fewer suppressed rules means fewer places where that can happen.

Refs ardmn/work#16
…very check reported

The lint and secrets jobs downloaded five tools with five copies of the same curl/sha256sum
snippet, inside the linter steps:

- A download happened after yarn lint and the tests, so an early failure skipped it, and the cache
  save ran at the end of the job (with always(), so also on cancelled runs).
- A cached file that failed its checksum was never replaced: `[ -f ]` skipped the download, the
  check failed, and the save was skipped on a cache hit. Every run failed until the entry expired.
- The lint job ran its checks fail-fast, so one failing check hid the others; the Android step ran
  unit tests and lint in one Gradle call without --continue, so a failing test hid lint.

Now:

- scripts/verified-download.ts owns "use a download only if its SHA-256 matches" for the scripts
  (bundletool in lib.ts, which had its own copy) and CI. A file already there is re-checked; one
  that fails is reported and downloaded again; a download is checked before it is written and
  renamed into place. Network errors, 5xx and 429 are retried. No dependencies, so the secrets job
  needs only Node, not a yarn install.
- .github/actions/fetch-tool (the approach of remote-compose-storybook's action of the same name)
  restores the tool's cache entry, runs scripts/fetch-tool.ts (verify or download, extract from a
  zip or tar, install on PATH), and saves a new download right away. The lint job fetches all four
  tools before any check.
- Each lint check runs with !cancelled() and skips only when what it needs did not install. In
  native-tests, the lockfile check and the Android step run after an earlier failure too, and
  Gradle gets --continue.
- Quoted three shell expansions actionlint's shellcheck reported (SC2086) in the turbo and NDK
  steps, so actionlint passes on the whole file.

A cache entry cannot be overwritten, so after a corrupted hit the job downloads on every run (with
a warning naming the fix, gh cache delete) instead of failing.

Refs ardmn/work#15
…ssions

eslint-suppressions.json counted violations per file and rule, so fixing one violation let a new
one of the same rule in that file through. The 43 left after the previous commit are fixed in code,
except four lines that are right as they are and now carry an inline disable with the reason:

- the two Metro asset require() calls for .rc files in documents.ts (Metro bundles an asset only
  through require());
- the two `=== null` checks in convert.ts that the types call impossible but JavaScript callers can
  still reach (a test passes a null source).

The fixes that change behaviour:

- productCardJson is deleted: no screen used it, it stayed only behind @knipignore, and it bundled
  product_card.json into both demos. The JSON stays as the source of product_card.rc. pulse.json is
  now a typed import, not an untyped require().
- PerformanceScreen: a run that throws logs RC_PERF_FAILED and stops showing "running…", instead of
  an unhandled rejection; measure-perf's timeout message names that marker.
- App: a failing Linking.getInitialURL() is logged instead of an unhandled rejection.
- convert.ts describe(): a function is described as "a function", not printed as its source.
- measure-perf reads request bodies as UTF-8 across chunk boundaries and rejects only with Errors.
- generate-native-contract: an enum without values or a struct without fields throws a message
  instead of a non-null assertion; list errors are joined with ", ".

An unused inline disable is reported and fails yarn lint (--max-warnings 0), so each one is
removed together with the finding it covers.

Refs ardmn/work#16
…ns with reasons

detekt's baseline matched an entry by file name and signature, so `TooGenericExceptionCaught:
Main.kt$e: Exception` hid every `catch (e: Exception)` in any Main.kt, including new ones. Android
Lint's baseline had two entries. Both baselines are gone; CI fails on any finding.

detekt (9 entries):
- MagicNumber, MaxLineLength (Main.kt): fixed (DIR_ARGUMENTS, the usage text split).
- TooGenericExceptionCaught (x4), SpreadOperator, ThrowsCount, TooManyFunctions (x2): kept as they
  are, each with @Suppress on the narrowest element (the catch parameter, the expression, the
  function or class) and a comment saying why.

Android Lint (2 entries):
- UseKtx: Uri.parse(s) becomes s.toUri().
- ViewConstructor: @SuppressLint on RemoteComposeView, which React Native creates only through its
  view manager and never inflates from XML.

CONTRIBUTING describes inline suppressions instead of the three baselines, and the fetch-tool
action for CI's pinned linters.

Refs ardmn/work#16
…lete

Review findings on the fetch-tool action:

- The cache key and path held only the tool name and its SHA-256. A version bump that changed the
  URL but not the pinned checksum restored the old file from a warm cache, which passed the check,
  and CI stayed green on the old version. The entry is now named after a hash of the URL and the
  checksum together, so a URL change always misses the cache, downloads, and fails the check.
- The comment said a corrupted entry is re-downloaded until it is deleted "or expires", but an entry
  restored on every run never expires. The comment says so, and the warning now names the exact
  `gh cache delete <key>` command (the action passes CACHE_KEY).
- The `downloaded` output fetch-tool.ts writes is now exposed by the action.
- A pinned URL that does not parse is refused before any request, as a malformed checksum is.

New tests: a 503 then 429 then 200 download succeeds on the third try; a malformed URL is refused;
fetch-tool keeps a valid cached copy without a request; fetch-tool replaces a corrupted cached copy
and prints the warning with the cache key.

Refs ardmn/work#15
… no baseline

- The JDK and the four Fetch steps kept the default `success()` condition, so one failed fetch or a
  failed yarn install skipped every later setup step, and with them every check that needs them.
  They now run with `!cancelled()`, and each check is skipped only when what it needs did not
  install: yarn checks on Setup, ktlint and detekt on the JDK and their fetch, the Swift tools on
  their fetch.
- The Android step still said "new findings only" and pointed to android/lint-baseline.xml, which
  the previous change deleted.

Refs ardmn/work#15
describe() in src/convert.ts now says "a function" instead of printing the function's source into
the error message; nothing tested that. Named values of null and of a function are reported with
"got null" and "got a function", and the function's source text is not in the message. Both tests
fail against the previous describe().

Refs ardmn/work#16
toUri() comes from androidx.core:core-ktx, which the library does not declare; it compiled only
because the dependency arrives transitively. Declaring it would set a minimum core-ktx version for
every app that installs the library, for a one-line wrapper around Uri.parse. Uri.parse with
@SuppressLint("UseKtx") and the reason adds no consumer dependency.

Refs ardmn/work#16
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Verified tool downloads and CI integration

Layer / File(s) Summary
Checksum verification and bundletool integration
scripts/verified-download.ts, scripts/lib.ts, scripts/__tests__/verified-download.test.ts
Adds pinned URL and checksum validation, cache verification, partial-file writes, and retries for selected failures. bundletool uses the shared helper. Tests cover cache reuse, replacement, checksum rejection, and retry behavior.
Fetch-tool action and installation
.github/actions/fetch-tool/action.yml, scripts/fetch-tool.ts, scripts/__tests__/verified-download.test.ts
Adds an action that verifies and installs a pinned tool, supports named-file extraction from ZIP and tar archives, and reports its installed path and download status. Tests cover action outputs, caching, and archive extraction.
CI tool setup and job conditions
.github/workflows/ci.yml, CONTRIBUTING.md
The lint and secrets jobs use the action instead of inline tool downloads. Lint and native-test steps gain setup conditions; Android tests use Gradle --continue. Contributor guidance documents checksum verification.

Lint baseline removal and targeted suppressions

Layer / File(s) Summary
Baseline removal and lint rules
CONTRIBUTING.md, android/build.gradle, android/lint-baseline.xml, detekt-baseline.xml, detekt.yml, eslint-suppressions.json, eslint.config.mjs
Removes ESLint, Detekt, and Android Lint baselines. Documentation and configuration direct contributors to fix findings or add narrow, reasoned suppressions. ESLint adds floating-promise and template-expression rules.
Reasoned Android and Kotlin suppressions
android/src/main/java/com/remotecompose/*, tools/remote-compose-json/src/main/kotlin/com/remotecompose/tools/Main.kt
Adds targeted suppressions and comments for selected lint and Detekt findings. The Kotlin command uses a named constant for the directory-mode argument count.

Demo and conversion error handling

Layer / File(s) Summary
Demo assets and asynchronous failures
example-shared/src/App.tsx, example-shared/src/documents.ts, example-shared/src/screens/*
Exports pulseJson and removes productCardJson. Demo screens add rejection handling for URL lookup, conversion, and performance runs, and use the first network document when the selected entry is unavailable.
Value descriptions and conversion tests
src/convert.ts, src/RemoteComposeView.native.tsx, src/__tests__/*
Conversion error descriptions now identify null and function values. Tests update matcher typing and cover those descriptions; the invalid-source result uses Record<string, never> for its props type.

Script and native-contract validation

Layer / File(s) Summary
Native-contract generator checks
scripts/generate-native-contract.ts
Stale-entry errors list multiple keys with commas. String-backed enum generation checks fallback values, and struct initialization rejects empty structs.
Environment and command values
scripts/lib.ts
Environment values must be nonempty strings. The script reuses JAVA_HOME and converts command status and the Gradle R8 flag to strings.
Performance request and statistics handling
scripts/measure-perf.ts, scripts/stats.ts
The report server decodes request data as UTF-8 and wraps non-Error failures. The median helper throws when an indexed value is missing.

Possibly related issues

  • ardmn/react-native-remote-compose#9 — This PR replaces repeated CI tool-download logic with a shared fetch action and changes lint and Android test execution conditions, addressing several reported CI issues. The issue also mentions cache-save conditions that this PR does not change.
  • ardmn/react-native-remote-compose#10 — This PR removes the ESLint suppression counts and Detekt and Android Lint baselines. It also removes the productCardJson export from the demo documents.

Possibly related PRs

Change: Other

Merge Risk: Minimal · up to 4ebe3

This change moves CI tool downloads onto a checksum-verified shared action, removes lint baselines in favor of reasoned inline suppressions, and tightens error handling in the demo and scripts. No concrete defect was found, so merge risk is minimal. The first CI run will show any lint findings that the removed baselines previously hid.

Security architecture risk: Low · up to 4ebe3

Downloads and cache hits still require a matching checksum. The main regression is that CI now installs linters before running project checks and later uses those installations without rechecking their identity. This weakens the verification guarantee within the lint job, but does not show a path to production access or broader credentials.

Retained concerns

  • Low · security · inferred: Lint and test steps now execute between verified installation and native linter invocation. A preceding step with the same job's write access can replace an installed tool after verification; bare-name invocation also lets a later PATH entry select a different executable. The base checked the pinned asset and invoked the tool by explicit path in one step. The regression is in same-job check integrity, not a demonstrated expansion of runner privileges.
Security review details

Security Blast Radius

  • inferred — The shared integrity logic affects four linters, the separate secret-scanning job, and local bundletool execution. The supported exposure is tool execution under the consuming runner or local user's authority; the inspected change does not establish a path to production deployment or credentials.

Trust Boundaries and Controls

  • observed — Remote releases and restored cache entries supply bytes, not the expected digest. Current callers supply repository-controlled pins and archive member names. Digest failure stops installation, and the separate secret-scan job runs no project check between fetching gitleaks and invoking it.

Resilience and Maintainability Implications

  • inferred — For one writer, an interrupted download or staging write does not publish a partial target, and later use rechecks the digest. Separate local processes in one checkout can contend for the same staging filename; this is a residual publication limitation, not evidence of a new remote compromise. The base wrote directly to the final jar and trusted it on reuse.

Hardening Proposals

  • proposed — Keep early cache population, but verify the pinned artifact and invoke the tool by explicit path in the same check step, after intervening project code has run.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

eslint.config.mjs

Parsing error: Unexpected token import

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: de62e54c-6e4a-4bc7-9e7a-975abc7c0b71
Commits

Reviewing files that changed from the base of the PR and between 3e07a8c and 4ebe388.

Files selected for processing: 32

  • .github/actions/fetch-tool/action.yml
  • .github/workflows/ci.yml
  • CONTRIBUTING.md
  • android/build.gradle
  • android/lint-baseline.xml
  • android/src/main/java/com/remotecompose/DocumentLoader.kt
  • android/src/main/java/com/remotecompose/PreparedDocument.kt
  • android/src/main/java/com/remotecompose/RemoteComposeModule.kt
  • android/src/main/java/com/remotecompose/RemoteComposeView.kt
  • android/src/main/java/com/remotecompose/RemoteComposeViewManager.kt
  • detekt-baseline.xml
  • detekt.yml
  • eslint-suppressions.json
  • eslint.config.mjs
  • example-shared/src/App.tsx
  • example-shared/src/documents.ts
  • example-shared/src/screens/JsonScreen.tsx
  • example-shared/src/screens/NetworkScreen.tsx
  • example-shared/src/screens/PerformanceScreen.tsx
  • scripts/__tests__/verified-download.test.ts
  • scripts/fetch-tool.ts
  • scripts/generate-native-contract.ts
  • scripts/lib.ts
  • scripts/measure-perf.ts
  • scripts/stats.ts
  • scripts/verified-download.ts
  • src/RemoteComposeView.native.tsx
  • src/__tests__/RemoteComposeView.test.tsx
  • src/__tests__/index.test.ts
  • src/__tests__/unsupportedPlatform.test.tsx
  • src/convert.ts
  • tools/remote-compose-json/src/main/kotlin/com/remotecompose/tools/Main.kt
Files with no reviewable changes: 3

  • android/lint-baseline.xml
  • detekt-baseline.xml
  • eslint-suppressions.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@ardmn
ardmn merged commit ee8f52c into main Nov 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant