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

[v16] Check redirects introduced by docs changes #48546

Draft
wants to merge 2 commits into
base: branch/v16
Choose a base branch
from
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
83 changes: 68 additions & 15 deletions .github/workflows/doc-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,70 @@ jobs:
contents: read

steps:
- name: Checkout
- name: Check out teleport
uses: actions/checkout@v4
with:
repository: 'gravitational/teleport'
path: 'teleport'

- name: Check out docs
uses: actions/checkout@v4
with:
repository: 'gravitational/docs'
path: 'docs'

- name: Generate GitHub Token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.REVIEWERS_APP_ID }}
private-key: ${{ secrets.REVIEWERS_PRIVATE_KEY }}

- name: Check out shared-workflows
uses: actions/checkout@v4
with:
repository: "gravitational/docs"
path: "docs"
repository: gravitational/shared-workflows
path: .github/shared-workflows
ref: paul.gottschling/2024-11-06-docs-redirs

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Ensure docs changes include redirects
run: cd .github/shared-workflows/bot && go run main.go -workflow=docpaths -token="${{ steps.generate_token.outputs.token }}" -teleport-path="${{ github.workspace }}/teleport" -reviewers="${{ secrets.reviewers }}"

# Cache node_modules. Unlike the example in the actions/cache repo, this
# caches the node_modules directory instead of the yarn cache. This is
# because yarn needs to build fresh packages even when it copies files
# from the yarn cache into node_modules.
# See:
# https://github.com/actions/cache/blob/main/examples.md#node---yarn
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: '${{ github.workspace }}/docs/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}/docs/yarn.lock', github.workspace)) }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install docs site dependencies
working-directory: docs
if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
# Prevent occasional `yarn install` executions that run indefinitely
timeout-minutes: 10
run: yarn install

- name: Prepare docs site configuration
# The environment we use for linting the docs differs from the one we
# use for the live docs site in that we only test a single version of
# the content.
#
# To do this, we replace the three submodules we use for building the
# live docs site with a single submodule, pointing to the
# gravitational/teleport branch we are linting.
#
# To do this, we delete the three submodules we use for building the
# live docs site and copy a gravitational/teleport clone into the
# content directory.
#
# The docs engine expects a config.json file at the root of the
# gravitational/docs clone that associates directories with git
# submodules. By default, these directories represent versioned branches
Expand All @@ -79,21 +128,24 @@ jobs:
echo "" > .gitmodules
rm -rf content/*
cd content
# Add a submodule at docs/content/teleport
git submodule add --force -b $BRANCH -- https://github.com/gravitational/teleport
# Rather than using a submodule, copy the teleport source into the
# content directory.
cp -r $GITHUB_WORKSPACE/teleport $GITHUB_WORKSPACE/docs/content/teleport
cd $GITHUB_WORKSPACE/docs
echo "{\"versions\": [{\"name\": \"teleport\", \"branch\": \"$BRANCH\", \"deprecated\": false}]}" > $GITHUB_WORKSPACE/docs/config.json
yarn install
jq -nr --arg version $BRANCH '{"versions": [{"name": $version,"branch": $version, "deprecated": false, "latest": true, "current": true }]}' > config.json
cat <<< "$(jq '.scripts."git-update" = "echo Skipping submodule update"' package.json)" > package.json
yarn build-node

- name: Check spelling
run: cd $GITHUB_WORKSPACE/docs && yarn spellcheck content/teleport

- name: Lint the docs
run: cd $GITHUB_WORKSPACE/docs && yarn markdown-lint
- name: Lint docs formatting
working-directory: 'docs'
run: yarn markdown-lint

- name: Test the docs build
run: cd $GITHUB_WORKSPACE/docs && yarn install && yarn build
working-directory: docs
run: yarn build

stylecheck:
name: Lint docs prose style
Expand All @@ -109,7 +161,7 @@ jobs:
repository: "gravitational/teleport"

- name: Run the linter
uses: errata-ai/vale-action@38bf078c328061f59879b347ca344a718a736018 # v2.1.0
uses: errata-ai/vale-action@d89dee975228ae261d22c15adcd03578634d429c # v2.1.1
with:
version: 2.30.0
# Take the comma-separated list of files returned by the "Check for
Expand All @@ -120,4 +172,5 @@ jobs:
# changed files.
filter_mode: added
fail_on_error: true
vale_flags: "--config=docs/.vale.ini"

Loading