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
Saving the HTML from coverage runs to provide samples #224
Comments
Something along those lines would be awesome. I have no concrete plans, but is painfully obvious that We're setting up a temporary folder where all the cucumber features are rendered. We could probably add a hook which saves those files and uploads them somewhere at the end of a run on Travis CI, so that might be a worthwhile idea. An easier approach might be to curate a few examples and generate a site if all tests are green (that may be easier, but I haven't given it much thought). |
Here's a starting point that may help in making this a bit more concrete (some tests fail). I do not know cucumber at all so I would need your help in making this work correctly, but hopefully it gives you an idea. We could push the generated HTML onto github pages for jekyll-scholar. Before do
FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR)
FileUtils.mkdir_p(TEST_DIR)
Dir.chdir(TEST_DIR)
end
After do |scenario|
merge_outputs(scenario)
FileUtils.rm_rf(TEST_DIR) if File.exist?(TEST_DIR)
end
def merge_outputs(scenario)
# Merge into this file
file = File.open("/tmp/test.html", "a")
file << "<h1>Title: #{scenario.title} </h1>"
# Check if there is an HTML file.
Dir.entries(TEST_DIR).each do |name|
if File.extname(name) == ".html"
# Source file formatting
file << "<pre>" + File.open(name).read + "</pre>"
# Processed
file << "<br /> <h2>Jekyll-scholarized</h2>"
file << File.open("_site/" + name, "r").read
file << "<br />"
end
end
file.close()
end |
It's certainly a good idea, but I think it may become too complicated to support all tests (and also ensure that all tests are meaningful examples). However, I think something that we could do is set up a jekyll site with the readme and examples (it does not even need to be tied to this repository). The site's repository could include Travis CI hooks which just build the page and push it back to GitHub pages. That would make it very easy for anyone to contribute examples using PRs. What do you think? |
Fine by me. |
Something like this: jekyll-scholar-examples? |
Exactly. What we'd need to add is a hook for Travis CI where we compile the site and then push it back to GitHub: i.e., continuous deployment for the examples (how to set something like this up is useful example by itself). If you're willing to work on this we could set up a GitHub org for jekyll-scholar and move this repository and examples there (also extras?). |
Used what you had for your CI setup. Please see now. What about publishing the rendered examples on github pages? I don't know how to do this, do you? |
Yes, we have to do something like this: Setup GitHub pages for the examples repo (in a separate branch, typically the branch is called
If the commit is from a PR then that's it. Otherwise, it should execute the deployment part (this is
|
Should be setup now. .travis.yml. |
Good work! I wasn't aware that this setup is now supported directly by Travis CI via the pages provider -- that's pretty awesome. Anyway, this is really great. We can start porting over examples from the Readme and it will be really helpful to many users. Do you want the repo to stay where it is or shall we set up a GitHub organization and move all the repositories there? @IgnoredAmbience what do you think of the idea? |
@inukshuk Either way is fine. |
Quick update. Each example within |
Apologies, didn't see this at the time. Seems like a good idea to me. Still would also be nice if we can automatically add the test cases to a subdirectory of the site too. I'm tempted to try this when I have some free time. (Currently taken on too much to do). |
If anything, having them output somewhere less ephemeral will make it easier to configure a mode to debug failing test cases. I currently have to hack around with the cucumber support code to turn off the temp dir deletion, which is mildly annoying. |
@IgnoredAmbience You could turn it off by changing this:
|
@rseac Yes, that's what I currently do. Remembering to not accidentally commit the change is hard, etc. Making this configurable would be a code change made at the same time as placing such test cases into an (test case section of) an examples repo. |
What about adding an environment variable for this? We'd just have to add a single line and you could set it by default and not have to think of it again (e.g., |
Curious whether the following is a good idea to provide examples: the coverage runs jekyll-scholar and creates the HTML files. Is it possible to use the same infrastructure to create sample HTML files and keep them instead of deleting them as specified in the support files?
Ideally, one could create their sample by writing a feature test. Furthermore, each of the feature tests could serve as rendered examples that people can look at.
The text was updated successfully, but these errors were encountered: