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

Set up documentation website generation and deployment #253

Merged
merged 28 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a2c547c
Bootstrap documentation website
japborst Sep 21, 2022
1d73f70
Add Picnic logo; small improvements
japborst Sep 21, 2022
0d95718
A few SEO improvements
japborst Sep 24, 2022
964ec64
Use absolute path for Picnic logo
japborst Sep 27, 2022
45f7703
Update `.gitignore`, fix typo, and sort links in README
rickie Sep 27, 2022
087f520
Tweaks
japborst Sep 27, 2022
378bfff
Store logo only in 1 place
japborst Sep 27, 2022
7d384f1
Update description
japborst Sep 28, 2022
1033164
Suggestions
rickie Sep 28, 2022
c9eae04
Tweaks
japborst Sep 28, 2022
e800d23
Drop `workflow_dispatch` from `build.yaml`
rickie Sep 29, 2022
2521fe5
Build sitemap.xml and robots.txt
japborst Sep 30, 2022
f62b632
Fix invalid urls and move favicon to the root
japborst Oct 1, 2022
8b1f2ab
Introduce html-proofer
japborst Oct 1, 2022
4ba8dd2
Build on every PR, deploy on default branch
japborst Oct 2, 2022
471bb6f
Attempt to fix deployment step
japborst Oct 2, 2022
9890367
Attempt to fix deploy conditional
japborst Oct 2, 2022
a0619f6
Attempt to force checking html
japborst Oct 2, 2022
e2adb4a
Use other proofer action
japborst Oct 2, 2022
d295e60
Suggestions
Stephan202 Oct 2, 2022
aa045b5
Suggestion
Stephan202 Oct 2, 2022
67e2f07
Tweaks
japborst Oct 2, 2022
ed33906
Use remote theme
japborst Oct 2, 2022
baee39a
Tweaks
japborst Oct 2, 2022
db0dc5d
Update local dev setup for remote themes
japborst Oct 2, 2022
1b5220a
Suggestions
Stephan202 Oct 3, 2022
ade5782
Suggestions
rickie Oct 3, 2022
5a0c65e
Suggestions
Stephan202 Oct 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: Build and verify
on:
pull_request:
push:
branches:
- 'master'
branches: [$default-branch]
permissions:
contents: read
jobs:
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/deploy-website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Update `error-prone.picnic.tech` website content
on:
pull_request:
push:
branches: [$default-branch]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3.0.2
- name: Configure Github Pages
uses: actions/configure-pages@v2.1.1
- name: Generate documentation
run: ./generate-docs.sh
- name: Build website with Jekyll
uses: actions/jekyll-build-pages@v1.0.5
with:
source: website/
destination: ./_site
- name: Validate HTML output
uses: anishathalye/proof-html@v1.4.1
with:
directory: ./_site
check_external_hash: false
Copy link
Member Author

Choose a reason for hiding this comment

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

In some websites a hash is used for JS routing, which is done after loading. Disabling this to reduce false-positives.

- name: Upload website as artifact
uses: actions/upload-pages-artifact@v1.0.4
deploy:
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be clearer to have a newline between these two parts.

Copy link
Member Author

@japborst japborst Sep 28, 2022

Choose a reason for hiding this comment

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

Indentation already takes care of that. We also don't do that above, or in build.yaml.

if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
needs: build
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1.2.1
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div align="center">

<picture>
<source media="(prefers-color-scheme: dark)" srcset="logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="logo.svg">
<img alt="Error Prone Support logo" src="logo.svg" width="50%">
</picture>
<picture>
Copy link
Member Author

Choose a reason for hiding this comment

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

A pity, but when using the readme for our website, you can't mix HTML and Markdown. That is normal behaviour, but apparently was okay on GitHub's flavoured Markdown before.

<source media="(prefers-color-scheme: dark)" srcset="website/assets/images/logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="website/assets/images/logo.svg">
<img alt="Error Prone Support logo" src="website/assets/images/logo.svg" width="50%">
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed the path to the website assets for the logo, s.t. we only store it in 1 place,

</picture>
</div>

# Error Prone Support

Expand All @@ -24,8 +24,6 @@ focussing on maintainability, consistency and avoidance of common pitfalls.
[Developing Error Prone Support](#-developing-error-prone-support) •
[How it works](#-how-it-works) • [Contributing](#%EF%B8%8F-contributing)

</div>

---

## ⚡ Getting started
Expand Down Expand Up @@ -201,9 +199,9 @@ Want to report or fix a bug, suggest or add a new feature, or improve the
documentation? That's awesome! Please read our [contribution
guidelines][contributing].

[bug-checks]: error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/
[bug-checks-identity-conversion]: error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IdentityConversion.java
[contributing]: CONTRIBUTING.md
[bug-checks]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/
[bug-checks-identity-conversion]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/IdentityConversion.java
[contributing]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/CONTRIBUTING.md
[error-prone-bugchecker]: https://github.com/google/error-prone/blob/master/check_api/src/main/java/com/google/errorprone/bugpatterns/BugChecker.java
[error-prone-fork-jitpack]: https://jitpack.io/#PicnicSupermarket/error-prone
[error-prone-fork-repo]: https://github.com/PicnicSupermarket/error-prone
Expand All @@ -215,7 +213,7 @@ guidelines][contributing].
[google-java-format]: https://github.com/google/google-java-format
[idea-288052]: https://youtrack.jetbrains.com/issue/IDEA-288052
[license-badge]: https://img.shields.io/github/license/PicnicSupermarket/error-prone-support
[license]: LICENSE.md
[license]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/LICENSE.md
[maven-central-badge]: https://img.shields.io/maven-central/v/tech.picnic.error-prone-support/error-prone-support?color=blue
[maven-central-search]: https://search.maven.org/artifact/tech.picnic.error-prone-support/error-prone-support
[maven]: https://maven.apache.org
Expand All @@ -224,5 +222,5 @@ guidelines][contributing].
[pitest-maven]: https://pitest.org/quickstart/maven
[pr-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[refaster]: https://errorprone.info/docs/refaster
[refaster-templates-bigdecimal]: error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/BigDecimalTemplates.java
[refaster-templates]: error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/
[refaster-templates-bigdecimal]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/BigDecimalTemplates.java
Copy link
Member Author

Choose a reason for hiding this comment

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

Absolute paths are required, as the same page is used to service our website.

Copy link
Member

Choose a reason for hiding this comment

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

Clear! (I should probably just test this, but) will the build fail if we accidentally reintroduce a relative URL?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly why I introduced html-proofer s.t. we catch this stuff (didn't know the existence before, but came across in another repo and a very obvious check to introduce).

Copy link
Member

Choose a reason for hiding this comment

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

Certainly! (And we shouldn't stop there. I made a note to also introduce shellcheck. We should likely enable other kind of static analysis.)

[refaster-templates]: https://github.com/PicnicSupermarket/error-prone-support/blob/master/error-prone-contrib/src/main/java/tech/picnic/errorprone/refastertemplates/
34 changes: 34 additions & 0 deletions generate-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

I'll push some suggestions for this file. (Not relying on the side-effect of cd, addressing shellcheck output, etc.)


set -e -u -o pipefail

WEBSITE_FOLDER="website"
HOMEPAGE="${WEBSITE_FOLDER}/index.md"

configure() {
cd "$(git rev-parse --show-toplevel || echo .)" || exit
}

generate_homepage() {
echo "Generating ${HOMEPAGE}"
cat > "${HOMEPAGE}" << EOF
---
layout: default
title: Home
nav_order: 1
---
EOF

cat "README.md" >> ${HOMEPAGE}

SEDOPTION="-i"
if [[ "$OSTYPE" == "darwin"* ]]; then
SEDOPTION="-i .bak"
fi
sed $SEDOPTION 's/src="website\//src="/g' ${HOMEPAGE}
sed $SEDOPTION 's/srcset="website\//srcset="/g' ${HOMEPAGE}
}

# Generate the website.
configure
generate_homepage
12 changes: 12 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Bundler and Jekyll.
.bundle/
Gemfile.lock
.jekyll-cache/
.jekyll-metadata
Comment on lines +4 to +5
Copy link
Member

Choose a reason for hiding this comment

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

I don't see these .jekyll-* paths being generated 🤔

Can we drop them?

Copy link
Member Author

Choose a reason for hiding this comment

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

These, however, are standard practice. See also
https://github.com/github/gitignore/blob/main/Jekyll.gitignore

For example, .jekyll-metadata is only generated when building the site incrementally (i.e. bundle exec jekyll serve --livereload --incremental) see https://jekyllrb.com/docs/structure/

Copy link
Member

Choose a reason for hiding this comment

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

Okay, so it aids certain dev flows. Fine to keep then.

.sass-cache/
_site/
vendor/

# Generated by `../generate-docs.sh`.
*.bak
index.md
11 changes: 11 additions & 0 deletions website/404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
layout: default
title: Page not found
permalink: /404
nav_exclude: true
search_exclude: true
---

## Page not found :(

The requested page could not be found.
4 changes: 4 additions & 0 deletions website/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"
gem "github-pages", "227"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also fix the Ruby version used? See https://bundler.io/guides/gemfile_ruby.html#specifying-a-ruby-version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would like to make part of the larger initiative, see #253 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I didn't read all of the comments so was just a drive-by comment. SGTM 👍

gem "html-proofer", "4.4.1"
gem "just-the-docs", "0.4.0.rc2"
38 changes: 38 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Error Prone Support website

This directory contains the majority of the source code that powers
[error-prone.picnic.tech][error-prone-support-website]. The website is
statically generated using [Jekyll][jekyll].

# Local development

To view the website on `localhost`, first follow the [Jekyll installation
instructions][jekyll-docs-installation]. Once done, in this directory execute:

```sh
bundle install
../generate-docs.sh && bundle exec jekyll serve --livereload
```

The website will now be [available][localhost-port-4000] on port 4000. Source
code modifications (including the result of rerunning `../generate-docs.sh`)
will automatically be reflected. (An exception is `_config.yml`: changes to
this file require a server restart.) Subsequent server restarts do not require
running `bundle install`, unless `Gemfile` has been updated in the interim.

If you are not familiar with Jekyll, be sure to check out its
[documentation][jekyll-docs]. It is recommended to follow the provided
step-by-step tutorial.

# Deployment

The website is regenerated and deployed using the
[`deploy-website.yaml`][error-prone-support-website-deploy-workflow] GitHub
Actions workflow any time a change is merged to `master`.

[error-prone-support-website]: https://error-prone.picnic.tech
[error-prone-support-website-deploy-workflow]: https://github.com/PicnicSupermarket/error-prone-support/actions/workflows/deploy-website.yaml
[jekyll]: https://jekyllrb.com
[jekyll-docs]: https://jekyllrb.com/docs/
[jekyll-docs-installation]: https://jekyllrb.com/docs/installation/
[localhost-port-4000]: http://127.0.0.1:4000
38 changes: 38 additions & 0 deletions website/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# General configuration.
title: Error Prone Support
logo: assets/images/favicon.svg
url: https://error-prone.picnic.tech
description: >-
japborst marked this conversation as resolved.
Show resolved Hide resolved
Error Prone extensions: extra bug checkers and a large battery of Refaster
templates.

theme: just-the-docs
plugins:
- jekyll-sitemap

# Files and directories not to be deployed through GitHub pages.
exclude:
- Gemfile
- Gemfile.lock
- README.md
Copy link
Member

Choose a reason for hiding this comment

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

I had to add vendor here because I got an issue while generating. Related GH thread.

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting... I did not have that issue 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I don't have this issue either. And I also don't see the .bundle and vendor directories mentioned in the .gitignore 🤔

- vendor

# See https://jekyllrb.com/docs/permalinks/#built-in-formats.
permalink: pretty

# See https://just-the-docs.github.io/just-the-docs/docs/navigation-structure/#external-navigation-links.
nav_external_links:
- title: Error Prone Support on GitHub
url: https://github.com/PicnicSupermarket/error-prone-support
hide_icon: false

# See https://jekyll.github.io/jekyll-seo-tag/usage/.
social:
name: Picnic
links:
- https://github.com/PicnicSupermarket
- https://twitter.com/picnic
- https://www.linkedin.com/company/picnictechnologies
twitter:
username: picnic
card: summary
5 changes: 5 additions & 0 deletions website/_includes/footer_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<img src="/assets/images/picnic-logo@2x.png" alt="Picnic Logo" id="logo" />

<p align="center">
Copyright &copy; 2017-2022 Picnic Technologies BV
</p>
17 changes: 17 additions & 0 deletions website/_includes/head_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Generated from https://realfavicongenerator.net/ -->
<link rel="apple-touch-icon" sizes="180x180" href="/assets/images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/images/favicon-16x16.png">
<link rel="manifest" href="/assets/images/site.webmanifest">
<link rel="mask-icon" href="/assets/images/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/favicon.ico">
Copy link
Member

Choose a reason for hiding this comment

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

I guess this one is not inside /assets for compatibility with old browers? Even if so: can't we configure Jekyll to put it in the root, without having it in the website root in the Github repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, some (older) browsers assume it's in the root. Also, some scrapers make this assumption. See also https://realfavicongenerator.net/faq#why_icons_in_root

If we really don't want to have in the root, we could move it and disable the favicon check for html-proofer (as that also complains about it). However, I'd prefer to keep it in the root, as is common practice for compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I mean "is there a way to convince Jekyll to put it into the website/_site root, without it being located in website. Googling around perhaps a hook would do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally, I'm not sure if that's any better. We're already in website. So you expect the files are reflected on what we're hosting. Putting something in assets/images, but then referring the root here where some webhook or script puts it there, makes development all the more confusing IMHO.

Copy link
Member

Choose a reason for hiding this comment

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

Ack, I'll not make a further point of it then.

<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/assets/images/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<!-- Support light and dark mode, as it's not natively supported.
See https://github.com/just-the-docs/just-the-docs/issues/234. -->
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-light.css' | relative_url }}"
media="(prefers-color-scheme: light)">
<link rel="stylesheet" href="{{ '/assets/css/just-the-docs-dark.css' | relative_url }}"
media="(prefers-color-scheme: dark)">
25 changes: 25 additions & 0 deletions website/_sass/custom/custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// We should override $nav-width(-md), however this breaks code highlighting and other styles.
// This seems to be an issue for following the recommended approach.
// See https://github.com/just-the-docs/just-the-docs/issues/982.
Copy link
Member

Choose a reason for hiding this comment

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

Nice that you filed a bug report! I see that the issue will be fixed in the next release. When we upgrade concrete change should we make instead? (Sorry for the n00b question, I know little about this stuff.)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this will continue to work. When that bug gets fixed, we can adhere to the official/recommended approach of creating a custom scheme and overriding $nav-width s.t. that param gets used throughout the rest of the styling.

See https://just-the-docs.github.io/just-the-docs/docs/customization/#custom-schemes

Copy link
Member

Choose a reason for hiding this comment

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

Check. Didn't fully grok that page yet, but pushed a commit with a proposal :)

@include mq(lg) {
.side-bar {
min-width: 400px;
}
japborst marked this conversation as resolved.
Show resolved Hide resolved

.site-nav, .site-header {
width: 400px;
}
}

// Add support for external anchor icons.
.external > svg {
width: 1rem;
vertical-align: text-bottom;
}
Copy link
Member

Choose a reason for hiding this comment

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

👀 @japborst What does this do? I didn't see the difference 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

This is used for the external anchor icons, when you look at the "view source code" button.

You are right that that functionality got stripped out of this PR, as that's a follow-up in gdejong/docgen. I can remove if you'd prefer.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, check! If it's not too much work: let's (since officially the change doesn't belong here). But since we do plan to work on gdejong/docgen: no strong objection to keep it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point. Let's keep it clean.


// Center and shrink the footer logo.
japborst marked this conversation as resolved.
Show resolved Hide resolved
footer > img#logo {
width: 2rem;
margin: 0 auto;
display: block;
}
japborst marked this conversation as resolved.
Show resolved Hide resolved
Binary file added website/assets/images/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/assets/images/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/assets/images/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions website/assets/images/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/assets/images/mstile-150x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added website/assets/images/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/assets/images/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions website/assets/images/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added website/assets/images/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/assets/images/picnic-logo@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading