Skip to content

Commit

Permalink
ci: Check docs links using Playwright MAASENG-4310 (#5586)
Browse files Browse the repository at this point in the history
- Re-wrote the docs links checker in Playwright, as `cy.visit()` is notoriously flakey
- Updated non-functioning docs links to point to correct pages:
  - Add machines
  - Set up MAAS in the UI
  - DHCP
  - Configure controllers
  - Build windows images
  - IP ranges
  - Automatic tags
  - Kernel options in tags
  - XPaths expressions

Resolves [MAASENG-4310](https://warthogs.atlassian.net/browse/MAASENG-4310)
  • Loading branch information
ndv99 authored Feb 6, 2025
1 parent bea6910 commit d508535
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 75 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/links-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ on:
push:
branches:
- main
- "3.5"

jobs:
docs:
name: maas.io/docs links
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Get branch name
uses: nelonoel/[email protected]
- name: Run Cypress docs tests
uses: cypress-io/github-action@v4
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
browser: chrome
config: baseUrl=http://maas.io/docs
spec: "cypress/e2e/docs-links/**/*.spec.ts"
install-command: yarn install
node-version-file: '.nvmrc'
- name: Install dependencies
run: yarn
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run docs links checks
run: yarn test-docs-links
- name: Create issue on failure
if: failure()
uses: JasonEtco/create-an-issue@v2
Expand Down
46 changes: 0 additions & 46 deletions cypress/e2e/docs-links/docs-links.spec.ts

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"test:debug": "vitest --inspect-brk test --runInBand --no-cache --testTimeout=100000000",
"test": "TZ=UTC yarn vitest",
"test-coverage": "yarn test --coverage",
"test-docs-links": "yarn playwright test docs-links.spec.ts",
"unlink-components": "yarn unlink react && yarn unlink \"@canonical/react-components\"",
"wait-on-ui": "wait-on http-get://0.0.0.0:8400/MAAS/r",
"storybook": "storybook dev -p 6006",
Expand Down
40 changes: 22 additions & 18 deletions src/app/base/docsUrls.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
const docsUrls = {
aboutNativeTLS: "https://maas.io/docs/how-to-implement-tls#enabling-tls-2",
addMachines: "https://maas.io/docs/how-to-manage-machines",
aboutNativeTLS:
"https://maas.io/docs/how-to-implement-tls#p-9022-enabling-tls",
addMachines: "https://maas.io/docs/how-to-provision-machines",
addNodesViaChassis:
"https://maas.io/docs/how-to-manage-machines#add-machines-via-chassis-ui-2",
"https://maas.io/docs/how-to-provision-machines#p-9078-add-machines",
autoRenewTLSCert:
"https://maas.io/docs/how-to-implement-tls#auto-renew-certs-8",
"https://maas.io/docs/how-to-implement-tls#p-9022-auto-renew-certs",
cloudInit:
"https://maas.io/docs/how-to-customise-machines#pre-seed-cloud-init-2",
"https://maas.io/docs/how-to-customise-machines#p-9014-cloud-init-pre-seeding",
configurationJourney:
"https://maas.io/docs/how-to-install-maas#configure-maas-with-the-ui-10",
"https://maas.io/docs/how-to-install-maas#p-9034-maas-ui-setup",
customisingDeployedMachines: "https://maas.io/docs/how-to-customise-machines",
dhcp: "https://maas.io/docs/how-to-enable-dhcp",
ipmi: "https://maas.io/docs/reference-power-drivers#ipmi-6",
ipRanges: "https://maas.io/docs/how-to-enable-dhcp#create-an-ip-range-ui-2",
kvmIntroduction: "https://maas.io/docs/about-virtual-machines",
dhcp: "https://maas.io/docs/about-dhcp-in-maas",
ipmi: "https://maas.io/docs/reference-power-drivers#p-17434-ipmi",
ipRanges:
"https://maas.io/docs/how-to-customise-dhcp#p-9038-edit-delete-or-extend-ip-range",
kvmIntroduction: "https://maas.io/docs/how-to-use-lxd-vms",
networkDiscovery:
"https://maas.io/docs/about-maas-networks#network-discovery-5",
rackController: "https://maas.io/docs/how-to-configure-controllers",
sshKeys: "https://maas.io/docs/how-to-manage-user-access#add-ssh-keys-5",
tagsAutomatic: "https://maas.io/docs/how-to-manage-tags#automatic-tags-17",
"https://maas.io/docs/how-to-customise-maas-networks#p-9070-manage-network-discovery",
rackController:
"https://maas.io/docs/about-controllers#p-13954-rack-controllers",
sshKeys: "https://maas.io/docs/how-to-manage-user-access#p-9090-add-ssh-keys",
tagsAutomatic:
"https://maas.io/docs/about-device-labels#p-13973-automatic-tags",
tagsKernelOptions:
"https://maas.io/docs/how-to-manage-tags#update-tag-kernel-options-22",
tagsXpathExpressions:
"https://maas.io/docs/how-to-manage-tags#automatic-tags-17",
"https://maas.io/docs/how-to-provision-machines#p-9078-set-boot-options",
tagsXpathExpressions: "https://www.w3schools.com/xml/XPath_intro.asp",
vaultIntegration: "https://maas.io/docs/how-to-integrate-vault",
windowsImages: "https://maas.io/docs/how-to-build-a-windows-image",
windowsImages:
"https://maas.io/docs/how-to-build-maas-images#p-17423-building-windows-images-with-packer",
} as const;

export default docsUrls;
24 changes: 24 additions & 0 deletions tests/docs-links.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { test, expect } from "@playwright/test";
import docsUrls from "../src/app/base/docsUrls";

const urls = Object.values(docsUrls);

test.describe("loads the page", () => {
urls.forEach((url) => {
test(`${url}`, async () => {
const docsPage = fetch(url);
const resCode = await docsPage.then((res) => res.status);
expect(resCode).toBe(200);
});
});
});

test.describe("is a direct link", () => {
urls.forEach((url) => {
test(`${url}`, async () => {
const docsPage = fetch(url, { redirect: "manual" });
const resCode = await docsPage.then((res) => res.status);
expect(resCode).toBe(200);
});
});
});

0 comments on commit d508535

Please sign in to comment.