-
Notifications
You must be signed in to change notification settings - Fork 116
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
Test PRs with smoke tests #83
Conversation
also adds a workflow to run the tests against PRs and fixes a small bug in smoke.sh that causes a bash error when no --builder is provided
I used the strategy of inspecting the builder with |
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.
There are still structures at the top of many of the test files that cause the file to be skipped if it is the wrong builder. Could we get rid of all of those now that we have the switch cases in init
?
Should all of the smoke tests run on a PR? They take a very long time (especially Java tests, and they are occasionally flaky) and seems like adding a sample app in Node (for example) wouldn't have an effect on any of the other samples. Is there a way we can just run the language family tests that were added? |
Update: Will use the switch statement approach because it collects in one place a list of which language families are compatible with which builders. |
@sophiewigmore These tests definitely do take a while. I can explore PR eventing to see if we can conditionally run certain tests based on files changed. |
in favor of a switch statement in the init test
so that individual languages' tests can be run with go test also adjusts workflow to run tests based on edited paths
@sophiewigmore I've pushed a WIP change that shows one way we could get better granularity on testing If I went this direction, I'd add a suite to each test file and add a step in the job that tests each one. We end up with some duplication of |
@fg-j Interesting. So we'd need a |
@sophiewigmore something else to consider - not particularly related but wanted to capture the context somewhere: We probably don't want to make the smoke tests a required check for the PR to merge. Here's a gist of why, in my opinion: Suppose we use these smoke tests to test PRs and releases on the builders repos (where that check is required). Now suppose we release a new version of the Ruby buildpack that replaces a deprecated Ruby version with a new one. We'll want to release a builder with the new Ruby buildpack in it. We open a PR to the builder repo that updates the Ruby buildpack version. The PR tests fail because there's a sample in this repo that uses the deprecated Ruby version. So we need to change the sample app to use a supported version of Ruby. We open a PR to this repo that updates the Ruby version in the sample app. The smoke tests fail on this repo because a version of the builder with the latest Ruby buildpack hasn't been released yet. So we can't merge the PR on this repo, either. Long story short, to avoid this sort of circular dependency, I think the smoke tests should be an automatic but optional check on this repo. |
@fg-j Thanks for the explanation. Yeah, I'm in agreement about this being optional. |
You could also break up the workflow into one per suite, then use the |
@ryanmoran That would get us around using the imported github action, but still doesn't really address the sadness that is the duplicated TestSamples and Test suites. Do you have thoughts on that part? |
Could you colocate the tests with the samples they operate on? So, the Go tests in the This way, you could run a single or set of suites like |
colocates them with language family samples
@ekcasey I am going to need an approval from you to merge this one I think. |
@fg-j I'm not a maintainer here, but these changes look good to me! |
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.
I left a couple comments but the only change I think should be blocking is the go version. Other comments are suggestions for improvements that we could make separately.
This changes weren't added with this PR but I wanted to leave two additional pieces of feedback:
- I think we should remove the application insights test for java. The app insights buildpack won't run without a binding and the current test isn't running the app insights buildpack at all.
- I worry that asserting on the log output is a bit brittle. The built app images has a label that will tell you which buildpacks ran. Maybe we would rather assert on the contents of the label?
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.14 |
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.
Why are we using such an old version of go? I think we should use 1.15 to match go.mod
or upgrade both to 1.16
.
go/dep/README.md
Outdated
@@ -11,3 +11,5 @@ | |||
## Viewing | |||
|
|||
`curl http://localhost:8080` | |||
|
|||
<!-- a trivial change that should trigger the Go test suite --> |
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.
<!-- a trivial change that should trigger the Go test suite --> |
java/java_native_image_test.go
Outdated
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
|
||
. "github.com/onsi/gomega" | ||
. "github.com/paketo-buildpacks/occam/matchers" |
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.
Not related to this PR but maybe we can throw a README.md
in https://github.com/paketo-buildpacks/occam. I can guess it's purpose from the context but it wouldn't hurt to have a couple sentences describing what occam
is for curious parties.
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.
Opened an issue to track this paketo-buildpacks/occam#83
tests/test_utilities.go
Outdated
var info builderInfo | ||
json.Unmarshal(buffer.Bytes(), &info) | ||
|
||
runImage, err := reference.ParseNormalizedNamed(info.LocalInfo.RunImages[0].ImageName) |
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.
Would it make more sense to use a combination of io.buildpacks.stack.id
and io.buildpacks.stack.mixins
to detect compatibility with a given buildpack? Using the run image name would work most of the time but it seems a bit indirect.
There are two practical situations where this might be a problem
- If I was using a dev version of the run image, say I was testing which run image changes would be necessary to make java buildpacks on tiny, this wouldn't detect properly.
- If someone created their own bionic stack images and builder and wanted to run these tests.
Maybe we don't need to detect the builder type at all. We could just set up the tests such that we don't pass incompatible builder into certain test suites? It's already a bit confusing to me that commands like the following "pass"
./scripts/smoke.sh --suite ruby --builder paketobuildpacks/builder:tiny --builder paketobuildpacks/builder:tiny
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.
Now that the suites are separate, I agree that it's probably easier and clearer to handle compatibility concerns in the test runner workflows.
"github.com/paketo-buildpacks/occam" | ||
"github.com/paketo-buildpacks/samples/tests" | ||
"github.com/sclevine/spec" | ||
"github.com/sclevine/spec/report" | ||
|
||
. "github.com/onsi/gomega" | ||
. "github.com/paketo-buildpacks/occam/matchers" |
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.
How do you all typically group import statements in the other paketo repos. In the java buildpack repos (and cnb repos) we typically have three groups:
- stdlib (e.g.
os
) - external (e.g.
github.com/paketo-buildpacks/occam
) - internal (e.g.
github.com/paketo-buildpacks/samples/tests
)
From this PR and other paketo buildpack repos am guessing you typically combine groups 2&3 but separate dot imports? But we don't seem to be totally consistent about it. No need to change anything here but maybe this is something we should add to the style guide and make consistent accross the project?
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.
Sounds reasonable. @ekcasey can you open an issue on the community repo to propose a change to the style guide?
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.
* Buildpack rename * Use BP_NATIVE_IMAGE env var instead of deprecated BP_BOOT_NATIVE_IMAGE * Fixes examples paths broken by paketo-buildpacks/samples#83 Signed-off-by: Emily Casey <[email protected]>
* Buildpack rename * Use BP_NATIVE_IMAGE env var instead of deprecated BP_BOOT_NATIVE_IMAGE * Fixes examples paths broken by paketo-buildpacks/samples#83 Signed-off-by: Emily Casey <[email protected]>
Summary
PRs will have tests run for all latest Paketo builders for any language family subdirectories that contain changes.
The
.github/workflows/test-pull-request-<language>.yml
workflows also indirectly document which builders are compatible with which language families.Also fixes a small bug in
smoke.sh
that caused an unbound variable error when no--builder
was provided.Use Cases
Checklist