feat: add platform detection for Heroku, Platform.sh, and Upsun - #23
feat: add platform detection for Heroku, Platform.sh, and Upsun#23pjcdawkins wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.ymlwith detection rules for Heroku, Platform.sh, and Upsun (including a “maybe” Heroku rule for Procfile-only repos). - Extends
pkg/rules/analyze_testfs_test.gowith 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). |
| && (fs.fileContains("app.json", '"buildpacks"') | ||
| || fs.fileContains("app.json", '"addons"')) |
There was a problem hiding this comment.
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.
| && (fs.fileContains("app.json", '"buildpacks"') | |
| || fs.fileContains("app.json", '"addons"')) | |
| && jq(fs.read("app.json"), 'has("buildpacks") or has("addons")') |
| heroku-procfile: | ||
| when: fs.fileExists("Procfile") | ||
| maybe: heroku | ||
| group: cloud | ||
| read_files: [Procfile, app.json, heroku.yml] |
There was a problem hiding this comment.
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).
2c2d85a to
932994f
Compare
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>
932994f to
dcf29bc
Compare
Summary
platformsruleset with rules detecting Heroku, Platform.sh, and Upsun cloud hosting platformsheroku.yml(definitive),app.jsonwith buildpacks/addons (definitive), orProcfilealone (maybe).platform.app.yaml/.ymlor.platform/applications.yaml/.yml.upsun/*.yaml/.upsun/*.ymlRefs: AI-147
Test plan
make testpassesmake buildregeneratesexpr.cachemake gen_docsregenerates docs🤖 Generated with Claude Code