Skip to content

feat: add platform detection for Heroku, Platform.sh, and Upsun - #23

Open
pjcdawkins wants to merge 1 commit into
mainfrom
feat/platform-detection
Open

feat: add platform detection for Heroku, Platform.sh, and Upsun#23
pjcdawkins wants to merge 1 commit into
mainfrom
feat/platform-detection

Conversation

@pjcdawkins

Copy link
Copy Markdown
Contributor

Summary

  • Add a platforms ruleset with rules detecting Heroku, Platform.sh, and Upsun cloud hosting platforms
  • Heroku is detected via heroku.yml (definitive), app.json with buildpacks/addons (definitive), or Procfile alone (maybe)
  • Platform.sh is detected via .platform.app.yaml/.yml or .platform/applications.yaml/.yml
  • Upsun is detected via .upsun/*.yaml/.upsun/*.yml

Refs: AI-147

Test plan

  • Added test fixtures for heroku-app, heroku-docker, and upsun-app directories
  • Added assertions for all platform reports including existing configured-app (Platform.sh)
  • make test passes
  • make build regenerates expr.cache
  • make gen_docs regenerates docs
  • No new lint issues introduced (pre-existing issues only)

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new platforms ruleset to Whatsun’s YAML-driven analyzer so it can detect common cloud hosting platforms (Heroku, Platform.sh, Upsun) based on repository configuration files.

Changes:

  • Introduces config/platforms.yml with detection rules for Heroku, Platform.sh, and Upsun (including a “maybe” Heroku rule for Procfile-only repos).
  • Extends pkg/rules/analyze_testfs_test.go with new in-memory fixtures and assertions for platform detection reports.
  • Regenerates generated artifacts (expr.cache, docs/functions.md) to reflect new expressions/docs output.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
config/platforms.yml Adds the new platforms ruleset and detection heuristics for Heroku / Platform.sh / Upsun.
pkg/rules/analyze_testfs_test.go Adds test FS fixtures and asserts expected platform reports from embedded rules.
expr.cache Updates the prewarmed CEL expression cache to include new platform detection expressions.
docs/functions.md Regenerated function/operator docs (generic type formatting updates).

Comment thread config/platforms.yml
Comment on lines +14 to +15
&& (fs.fileContains("app.json", '"buildpacks"')
|| fs.fileContains("app.json", '"addons"'))

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Heroku app.json detection uses fs.fileContains to look for the substrings "buildpacks"/"addons". This will also match those words if they appear in values (e.g., description text) rather than as JSON keys, so it isn’t actually “definitive” and can produce false positives. Consider using jq(fs.read("app.json"), ...) to test for the presence of the keys (e.g., has("buildpacks") / has("addons"), or .buildpacks != null / .addons != null) instead of a raw substring search.

Suggested change
&& (fs.fileContains("app.json", '"buildpacks"')
|| fs.fileContains("app.json", '"addons"'))
&& jq(fs.read("app.json"), 'has("buildpacks") or has("addons")')

Copilot uses AI. Check for mistakes.
Comment thread config/platforms.yml Outdated
Comment on lines +22 to +26
heroku-procfile:
when: fs.fileExists("Procfile")
maybe: heroku
group: cloud
read_files: [Procfile, app.json, heroku.yml]

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heroku-procfile rule introduces new “maybe” behavior (Procfile-only projects should report heroku with maybe: true), but there isn’t a fixture/assertion covering this case. Add a Procfile-only test directory (no heroku.yml, no app.json with buildpacks/addons) and assert the platforms report includes Maybe: true (and is suppressed when a definitive cloud platform is detected in the same directory).

Copilot generated this review using guidance from repository custom instructions.
Add a `platforms` ruleset detecting cloud hosting platforms:
- Heroku: via heroku.yml (definitive), app.json with buildpacks/addons
  (definitive), or Procfile alone (maybe)
- Platform.sh: via .platform.app.yaml/.yml or .platform/applications.yaml/.yml
- Upsun: via .upsun/*.yaml or .upsun/*.yml

The `heroku-procfile` maybe result is suppressed when a definitive
heroku result already exists for the same path.

Adds test fixtures for heroku-app, heroku-docker, and upsun-app
directories, plus assertions for the existing configured-app
(Platform.sh) fixture.

Refs: AI-147

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pjcdawkins
pjcdawkins force-pushed the feat/platform-detection branch from 932994f to dcf29bc Compare March 3, 2026 18:01
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.

2 participants