Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions .github/actions/build-base/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build the website at another commit
description: >
Checks out and builds a specified version of this repository. Useful for build comparisons with
newer repo versions. If it doesn't build, or has no build-site, there's no site at the "site" output.
inputs:
ref:
description: The commit to build, such as a pull request's base commit.
required: true
drafts:
description: Include scheduled posts (draft = true).
default: 'false'

outputs:
site:
description: The built site, relative to the workspace.
value: base/public

runs:
using: composite
steps:
- name: Check out the commit
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: ${{ inputs.ref }}
path: base

- name: Build
id: build
if: hashFiles('base/.github/actions/build-site/action.yml') != ''
continue-on-error: true
uses: ./base/.github/actions/build-site
with:
path: base
drafts: ${{ inputs.drafts }}

# A failed build can leave part of a site behind.
- name: Discard a failed build
if: steps.build.outcome == 'failure'
shell: bash
run: sudo rm -rf base/public
41 changes: 31 additions & 10 deletions .github/actions/build-site/action.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
name: Build the website
description: >
Builds a checkout of this repository into <path>/public, with its topics and
Builds a checkout of this repository and its search index into <path>/public, with its topics and
commands from valkey-doc and the command metadata from valkey and the modules, checked out
next to it in the workspace.
next to it in the workspace. Content repositories that are already checked out there, such as by
an earlier build in the job, are reused.

inputs:
path:
description: The website checkout to build, relative to the workspace (e.g. website).
required: true
checkout-content:
description: Check out the content repositories. Set to false if an earlier build in the job already did.
default: 'true'
drafts:
description: Include scheduled posts (draft = true). Only for checks, since deploying it would publish them early.
default: 'false'

runs:
using: composite
steps:
- name: Checkout valkey
if: inputs.checkout-content == 'true'
if: hashFiles('valkey/.git/HEAD') == ''
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey
path: valkey

- name: Checkout valkey-bloom
if: inputs.checkout-content == 'true'
if: hashFiles('valkey-bloom/.git/HEAD') == ''
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-bloom
path: valkey-bloom

- name: Checkout valkey-doc
if: inputs.checkout-content == 'true'
if: hashFiles('valkey-doc/.git/HEAD') == ''
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-doc
path: valkey-doc

- name: Checkout valkey-json
if: inputs.checkout-content == 'true'
if: hashFiles('valkey-json/.git/HEAD') == ''
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-json
path: valkey-json

- name: Checkout valkey-search
if: inputs.checkout-content == 'true'
if: hashFiles('valkey-search/.git/HEAD') == ''
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
repository: valkey-io/valkey-search
Expand All @@ -65,3 +66,23 @@ runs:
BUILD_DIR: ${{ inputs.path }}
BUILD_ONLY: true
BUILD_THEMES: false
BUILD_FLAGS: ${{ inputs.drafts == 'true' && '--drafts' || '' }}

- name: Install Pagefind
shell: bash
env:
PAGEFIND_VERSION: v1.5.2
PAGEFIND_SHA256: afb824a9e7f64905a934900481cea5be679c03975e527329e0e5e6cc70f5feda
run: |
curl -sSfL --retry 3 "https://github.com/Pagefind/pagefind/releases/download/${PAGEFIND_VERSION}/pagefind-${PAGEFIND_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
-o "$RUNNER_TEMP/pagefind.tar.gz"
echo "${PAGEFIND_SHA256} $RUNNER_TEMP/pagefind.tar.gz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/pagefind.tar.gz" -C "$RUNNER_TEMP" pagefind

- name: Build search index
shell: bash
working-directory: ${{ inputs.path }}
# The Zola action runs as root in Docker, so public/ is owned by root.
run: |
sudo chown -R "$(id -u):$(id -g)" public
"$RUNNER_TEMP/pagefind"
34 changes: 17 additions & 17 deletions .github/actions/check-links/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Check the website's links
description: >
Checks a built site (<path>/public) for links to missing pages or #anchors. If base-path is
provided, only surfaces issues that don't appear in both.
Checks a built site for links to missing pages or #anchors, and for doc links that weren't
converted to site URLs. Given a build from before the change, fails only on problems the change
causes. Without, fails on every problem.

inputs:
path:
description: The website to check the build for, relative to the workspace (e.g. website).
after:
description: The built site to check, relative to the workspace (e.g. website/public).
required: true
base-path:
description: A checkout of the base commit to compare with. If it has no public directory, every broken link is listed.
before:
description: A built site from before the change to compare with, relative to the workspace. Leave empty if there is none.
default: ''

runs:
Expand All @@ -26,21 +27,20 @@ runs:
tar -xzf "$RUNNER_TEMP/lychee.tar.gz" -C "$RUNNER_TEMP" --strip-components=1 lychee-x86_64-unknown-linux-gnu/lychee
echo "$RUNNER_TEMP" >> "$GITHUB_PATH"

# Uses the scripts from the same commit as this action, so a change to a check is used on both
# builds. Runs both even if the first fails.
- name: Check links
shell: bash
env:
CHECKOUT: ${{ inputs.path }}
BASE_CHECKOUT: ${{ inputs.base-path }}
BEFORE: ${{ inputs.before }}
AFTER: ${{ inputs.after }}
run: |
build=$(git -C "$GITHUB_ACTION_PATH" rev-parse --show-toplevel)/build
before=-
if [ -n "$BEFORE" ]; then before=$BEFORE; fi
status=0
for check in broken-links unconverted-doc-links; do
echo "build/$check.sh:"
before=-
if [ -n "$BASE_CHECKOUT" ]; then
before=$RUNNER_TEMP/$check-before.txt
if [ -d "$BASE_CHECKOUT/public" ]; then "$CHECKOUT/build/$check.sh" "$BASE_CHECKOUT/public" > "$before"; fi
fi
"$CHECKOUT/build/$check.sh" "$CHECKOUT/public" > "$RUNNER_TEMP/$check.txt"
"$CHECKOUT/build/compare-link-failures.sh" "$before" "$RUNNER_TEMP/$check.txt" || status=1
for check in broken-links.sh unconverted-doc-links.sh; do
echo "$check:"
"$build/compare-problems.sh" "$before" "$AFTER" "$build/$check" || status=1
done
exit "$status"
29 changes: 29 additions & 0 deletions .github/actions/check-search-index/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check the website's search index
description: >
Checks a built site's search index for missing or unexpected pages and wrong or duplicate titles.
Given a build from before the change, fails only on problems the change causes. Without, fails
on every problem.

inputs:
after:
description: The built site to check, relative to the workspace (e.g. website/public).
required: true
before:
description: A built site from before the change to compare with, relative to the workspace. Leave empty if there is none.
default: ''

runs:
using: composite
steps:
# Uses the script from the same commit as this action, so a change to the check is used on
# both builds. Runs it with python3, since the runner doesn't have uv.
- name: Check search index
shell: bash
env:
BEFORE: ${{ inputs.before }}
AFTER: ${{ inputs.after }}
run: |
build=$(git -C "$GITHUB_ACTION_PATH" rev-parse --show-toplevel)/build
before=-
if [ -n "$BEFORE" ]; then before=$BEFORE; fi
"$build/compare-problems.sh" "$before" "$AFTER" python3 "$build/check-search-index.py"
26 changes: 4 additions & 22 deletions .github/workflows/link-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,20 @@ jobs:
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
path: website
fetch-depth: 0 # for the base commit

- name: Check out the base commit
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: git -C website worktree add --detach ../base "$BASE_SHA"

# Each side uses its own build-site, so changes to the build itself are checked too.
# If the base doesn't build or has no build-site, the checks list every broken link
# instead.
- name: Build this PR
id: head
uses: ./website/.github/actions/build-site
with:
path: website

- name: Build the base
id: base
if: hashFiles('base/.github/actions/build-site/action.yml') != ''
continue-on-error: true
uses: ./base/.github/actions/build-site
uses: ./website/.github/actions/build-base
with:
path: base
checkout-content: false

# A failed build can leave part of a site, which could hide links the PR breaks.
- name: Discard a failed base build
if: steps.base.outcome == 'failure'
run: rm -rf base/public
ref: ${{ github.event.pull_request.base.sha }}

- name: Check links
uses: ./website/.github/actions/check-links
with:
path: website
base-path: base
before: ${{ steps.base.outputs.site }}
after: website/public
59 changes: 59 additions & 0 deletions .github/workflows/search-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Builds the site before and after the PR and checks its search index. Fails if the PR causes a
# problem. Problems already there before the PR, such as ones from other repos, are listed but don't
# fail the check. Includes scheduled posts (drafts) so they are checked before being merged.

name: Search check

on:
pull_request:
branches: ["main"]

permissions:
contents: read

concurrency:
group: search-check-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
search-index:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
path: website

- name: Build this PR
uses: ./website/.github/actions/build-site
with:
path: website
drafts: true

- name: Build the base
id: base
uses: ./website/.github/actions/build-base
with:
ref: ${{ github.event.pull_request.base.sha }}
drafts: true

- name: Check search index
uses: ./website/.github/actions/check-search-index
with:
before: ${{ steps.base.outputs.site }}
after: website/public

# Only checks when this PR changes the Pagefind version or the list of sites. Those are the
# only changes in this repo that can stop search from merging the other sites.
- name: Check the other Valkey sites have a copy of their search index for this Pagefind version
if: ${{ !cancelled() }}
env:
BASE: ${{ steps.base.outputs.site }}
run: |
version() { jq -r .version "$1/pagefind/pagefind-entry.json" 2>/dev/null || echo none; }
if [ "$(version "$BASE")" = "$(version website/public)" ] \
&& cmp -s base/static/cross-site-search.json website/static/cross-site-search.json; then
echo "This PR doesn't change the Pagefind version or the list of sites, so there's nothing to check."
exit 0
fi
./website/build/index-copies.sh check
14 changes: 13 additions & 1 deletion .github/workflows/zola-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
with:
path: website

- name: Build copies of the search index for the other Valkey sites
if: github.event_name != 'pull_request'
working-directory: website
run: ./build/index-copies.sh build

- name: Upload artifact
if: github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
Expand Down Expand Up @@ -81,9 +86,16 @@ jobs:
name: github-pages

- name: Unpack the built site
id: unpack
run: mkdir public && tar -xf artifact.tar -C public

- name: Check links
uses: ./.github/actions/check-links
with:
path: .
after: public

- name: Check search index
if: ${{ !cancelled() && steps.unpack.outcome == 'success' }}
uses: ./.github/actions/check-search-index
with:
after: public
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ Open your browser to `http://127.0.0.1:1111/`
Zola will automatically rebuild on changes to the template or any content stored in this repo.
Changes to external content (command reference, documentation topics) require a restart of the Zola server process (`ctrl-c` then `zola serve` again, a browser refresh may also be needed).

### Site search (optional)

The search index is built in CI after `zola build`. `zola serve` doesn't build or update it, so search doesn't work there. To try search locally, download `pagefind` for your platform from the [Pagefind releases](https://github.com/Pagefind/pagefind/releases) (the version in `.github/actions/build-site/action.yml`) and run, from the root of this repo:

```shell
zola build && pagefind --serve
```

Open the URL Pagefind prints after `Serving "public" at`. The server doesn't rebuild on changes, so run the command again after editing.

Every page needs a unique `<title>`. CI checks this when it checks the search index, so if it reports a `duplicate title`, change the `title` in the front matter of one of the listed pages.

Search also shows results from the other Valkey sites listed in `static/cross-site-search.json`.

### Checking catalog entries

The clients and integrations entries in `_data/libraries/` are checked by `build/validate-libraries.py`, against the rules in `_data/libraries/schema.json` and the SPDX license list.
Expand Down
Loading
Loading