tlienart / Franklin.jl

(yet another) static site generator. Simple, customisable, fast, maths with KaTeX, code evaluation, optional pre-rendering, in Julia.
https://franklinjl.org
MIT License
951 stars 113 forks source link

Fail deployment job when error occurs #785

Open rikhuijzer opened 3 years ago

rikhuijzer commented 3 years ago

I love the fact that Franklin can generate my website including plots and tables. However, this brings in the risk that some code contains a bug which then shows a broken website. In the worst case, the website would report a stack trace to the reader.

To avoid this, I'm grepping the log and failing the deployment job when the output contains 'Franklin Warning':

    - name: Build site
      run: julia -e '
        using Pkg; Pkg.add(["NodeJS", "Franklin"]);
        using NodeJS; run(`$(npm_cmd()) install highlight.js`);
        using Franklin;
        Pkg.activate("."); Pkg.instantiate();
        optimize();
        verify_links()' > build.log

    - name: Validate output
      run: |
        if grep -1 "Franklin Warning" build.log; then
          echo "Franklin reported a warning"
          exit 1
        else
          echo "Franklin did not report a warning"
        fi

Unfortunately, this doesn't fail on missing images because they only show

 // Image matching '/assets/posts/random-forest/code/u-class.svg' not found. //

in the HTML. I could now also add a grep over the output html pages, but maybe it's better to move this logic into Franklin so that others can also easily use it.

StefanKarpinski commented 3 years ago

Seems like warnings should be fatal, at least in modes that are used to deploy sites.

rikhuijzer commented 3 years ago

@tlienart, in response to your question about my thoughts on what should fail / warn / do nothing in #877:

I think that the main important thing is like what Christopher Rackauckas said about managing large software repositories at Discourse: basically, you want people to be able to review PRs in 5 minutes in the train and merge. So, if CI passes, then the reviewer needs to be able to trust that the website is valid. This is nearly impossible to do in all cases, especially for plots, but I agree with Stefan Karpinski above that deployments should fail whenever something appears to be broken. Specifically, fail on

These are just my two cents. Note that a bunch of people who interacted with this thread have way more programming experience than me.