Skip to content
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

Merged
merged 12 commits into from
Mar 1, 2021
Merged

Test PRs with smoke tests #83

merged 12 commits into from
Mar 1, 2021

Conversation

fg-j
Copy link

@fg-j fg-j commented Feb 22, 2021

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

  1. Easily test all sample apps against the builders they should work with
  2. Test PRs to ensure samples are always working

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked at least 1 issue to this pull request
  • I have added an integration test, if necessary.

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
@fg-j fg-j requested a review from a team as a code owner February 22, 2021 16:49
@fg-j fg-j linked an issue Feb 22, 2021 that may be closed by this pull request
3 tasks
@fg-j
Copy link
Author

fg-j commented Feb 22, 2021

I used the strategy of inspecting the builder with pack rather than inferring based on the builder name to open up the option for someone to have something like testbuilder on their Docker daemon that's a local instance of the full builder, for instance. The tests will still figure out to run the correct tests. This will be helpful for testing builders w/ sample apps directly.

Copy link
Contributor

@ForestEckhardt ForestEckhardt left a 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?

@sophiewigmore
Copy link
Member

sophiewigmore commented Feb 22, 2021

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?

@fg-j
Copy link
Author

fg-j commented Feb 22, 2021

@ForestEckhardt I didn't realize/remember there was that skipping thing. In some ways I think that's a nicer mechanism than the switch statement in the init. Though maybe it's less explicit? Open to others' thoughts. Maybe I'll just have those skip conditionals look at the builder's run image rather than the name.

Update: Will use the switch statement approach because it collects in one place a list of which language families are compatible with which builders.

@fg-j
Copy link
Author

fg-j commented Feb 22, 2021

@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.

Frankie Gallina-Jones added 2 commits February 22, 2021 15:19
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
@fg-j
Copy link
Author

fg-j commented Feb 22, 2021

@sophiewigmore I've pushed a WIP change that shows one way we could get better granularity on testing
See this run of the Test Pull Request action for an example of how the workflow runs. @ForestEckhardt What are your thoughts on this approach?

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 suites that I don't love...

@sophiewigmore
Copy link
Member

@fg-j Interesting. So we'd need a - name: Test <Language> Samples in the workflow file for each language family. I don't hate that but I agree it's a lot of duplication and set up.. Maybe it's not worth it for faster tests just for the samples repo since we're not constantly doing development on it. Interested to hear Forest's thoughts

@fg-j
Copy link
Author

fg-j commented Feb 23, 2021

@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.

@sophiewigmore
Copy link
Member

@fg-j Thanks for the explanation. Yeah, I'm in agreement about this being optional.

@ryanmoran
Copy link
Member

You could also break up the workflow into one per suite, then use the paths feature on pull_request events to trigger the right workflows for the PR: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths.

@fg-j
Copy link
Author

fg-j commented Feb 23, 2021

@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?

@ryanmoran
Copy link
Member

@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 go directory, and the PHP tests in the php directory. Then, in each test suite you would specify whether it runs for the given builder.

This way, you could run a single or set of suites like go test ./go ./php and run everything with go test ./....

Frankie Gallina-Jones added 2 commits February 24, 2021 16:56
@fg-j fg-j requested review from a team, ForestEckhardt and ryanmoran February 24, 2021 22:35
@ForestEckhardt ForestEckhardt self-requested a review February 25, 2021 18:44
@ForestEckhardt
Copy link
Contributor

@ekcasey I am going to need an approval from you to merge this one I think.

@sophiewigmore
Copy link
Member

@fg-j I'm not a maintainer here, but these changes look good to me!

Copy link
Member

@ekcasey ekcasey left a 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:

  1. 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.
  2. 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
Copy link
Member

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 -->
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<!-- a trivial change that should trigger the Go test suite -->

"github.com/sclevine/spec"
"github.com/sclevine/spec/report"

. "github.com/onsi/gomega"
. "github.com/paketo-buildpacks/occam/matchers"
Copy link
Member

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.

Copy link
Author

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

var info builderInfo
json.Unmarshal(buffer.Bytes(), &info)

runImage, err := reference.ParseNormalizedNamed(info.LocalInfo.RunImages[0].ImageName)
Copy link
Member

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

  1. 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.
  2. 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

Copy link
Author

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.

Comment on lines 11 to 17
"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"
Copy link
Member

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:

  1. stdlib (e.g. os)
  2. external (e.g. github.com/paketo-buildpacks/occam)
  3. 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?

Copy link
Author

@fg-j fg-j Feb 26, 2021

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?

Copy link
Member

Choose a reason for hiding this comment

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

@ForestEckhardt ForestEckhardt merged commit 3a3188f into main Mar 1, 2021
@ForestEckhardt ForestEckhardt deleted the test-prs branch March 1, 2021 15:03
ekcasey added a commit to paketo-buildpacks/paketo-website that referenced this pull request Mar 11, 2021
* 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]>
kvedurmu pushed a commit to paketo-buildpacks/paketo-website that referenced this pull request Mar 11, 2021
* 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]>
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.

Smoke tests not run on PR
6 participants