-
Notifications
You must be signed in to change notification settings - Fork 158
ci(examples): cover go-http-zip and standardize template filenames #759
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,20 @@ jobs: | |
| use-installer: true | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # The loop below matches template.yaml exactly, so an example that uses | ||
| # the template.yml spelling is skipped silently and this job still passes | ||
| # green -- which is how go-http-zip stayed unvalidated. Reject the other | ||
| # spelling up front so the gap surfaces as a failure, not as missing | ||
| # coverage. | ||
| - name: Enforce template.yaml naming | ||
| run: | | ||
| stragglers=$(find examples -name "template.yml") | ||
| if [ -n "$stragglers" ]; then | ||
| echo "These examples must be renamed to template.yaml:" | ||
| echo "$stragglers" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Validate all SAM templates | ||
| run: | | ||
| failed=0 | ||
|
|
@@ -190,6 +204,7 @@ jobs: | |
| - { name: fasthtml-zip, path: /, expect_body: "Hello World", port: "8000" } | ||
| - { name: flask-zip, path: /, expect_body: "message", port: "8000" } | ||
| - { name: gin-zip, path: /, expect_body: "message", port: "8000" } | ||
| - { name: go-http-zip, path: /, expect_body: "Hello, Website!", port: "3000" } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [GENERAL] The matrix entry and the renames are consistent with the example ( The validate job at line 40 discovers templates with: for template in $(find examples -maxdepth 2 -name "template.yaml" | sort); doAny example whose template is not named exactly Making discovery match both names keeps the loop honest without depending on reviewers to catch the filename: for template in $(find examples -maxdepth 2 \( -name "template.yaml" -o -name "template.yml" \) | sort); doIf you prefer to keep enforcing the single conventional name, an explicit failure is better than a silent skip — e.g. fail the job when an example directory contains a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks — the underlying point is right, so I've addressed it in a follow-up commit. I went with the second suggestion rather than the first. Matching both spellings in The guard searches at any depth, so it also covers nested examples the |
||
| - { name: remix-zip, path: /, expect_body: "Welcome to", port: "8000" } | ||
| - { name: springboot-zip, path: /v1/, expect_body: "Hello, world!", port: "8000" } | ||
| steps: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[GENERAL] The guard closes the exact case that bit
go-http-zip, but it hard-codes the inverse of the discovery rule instead of deriving from it, so the two can still disagree:Anything that is a SAM template but doesn't land at exactly
examples/<name>/template.yaml— e.g.examples/foo/infra/template.yaml— passes the guard and is still skipped silently by validation, which is the same green-but-uncovered outcome the step exists to prevent. Conversely, the guard has no-maxdepth, so a nested third-partytemplate.ymlthat validation was never meant to lint would fail the build.Expressing the invariant once ("every SAM template lives at
examples/<name>/template.yaml") covers both directions:Worth pairing with a zero-match assertion in the validation loop itself — it currently exits 0 when
findreturns nothing, so a future change to the directory layout would also read as a pass rather than a failure.I confirmed the rest of the change: no references to
template.ymlremain outside the diff, the renamed templates match the shapes of examples thevalidatejob already lints (go-http-zipmirrorsgin-zip,sinatramirrorsfastapi-response-streaming), and the matrix entry'sport: "3000"/expect_body: "Hello, Website!"line up withcmd/website/main.goand the template'sPORT: 3000. No example currently has a template below depth 2, so the point above is about keeping the guard honest going forward, not a present-day break.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both directions are real, and I'd rather not encode the stricter rule here.
The proposed invariant enforces that every SAM template sits at
examples/<name>/template.yaml, but the repo already nests examples one level deeper —examples/datadog/*/cdk/andexamples/sls/nestjs/— they just don't use SAM today. A futureexamples/datadog/fastapi/template.yamlwould follow the existing grouping and still fail the guard, and the right fix in that case is widening the validation loop's-maxdepth 2, not rejecting the layout.Since nothing currently has a template below depth 2 (as you note), I'd rather keep this PR to the coverage gap it set out to close and leave the depth question to a change that can decide the nested-example policy properly.