Skip to content
Merged
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
8 changes: 6 additions & 2 deletions .github/workflows/argos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
(github.event_name != 'pull_request' && github.ref_name == 'main') ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Argos'))
)
runs-on: ubuntu-latest
# runs-on: ubuntu-latest
runs-on: 8-core-ubuntu
steps:
- name: Check out repository code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Expand All @@ -55,5 +56,8 @@ jobs:
- name: Build website fast
run: pnpm argos:build

- name: Take Argos screenshots
- name: Take and upload Argos screenshots
run: pnpm argos:screenshot

- name: Upload Argos text snapshots
run: pnpm argos:upload-text-snapshots
21 changes: 17 additions & 4 deletions argos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@ We use [Argos CI](https://argos-ci.com) to detect visual regressions on Docusaur

This workspace can be run manually, but is generally run through the [Argos GitHub Action](../.github/workflows/argos.yml).

## Workflow overview

The workflow execute those following steps:

- Build the website locally with `pnpm build:website:fast`
- Build the website locally with `pnpm argos:build` (a variant of `pnpm build:website:fast`)
- Start the website server with `pnpm serve:website` on [http://localhost:3000](http://localhost:3000)
- Take screenshots of all pages found in `sitemap.xml` with Playwright
- Upload all screenshots to [Argos CI](https://argos-ci.com)
- Upload all screenshots to [Argos CI](https://argos-ci.com) using the [Playwright reporter](https://argos-ci.com/docs/reference/playwright)
- Upload [HTML/CSS/JS files to also diff them on Argos](https://argos-ci.com/docs/learn/how-to-guides/visual-coverage/compare-non-image-files) using `pnpm argos:upload-text-snapshots`

This workflow runs for `main` and PR branches, and add a commit status to each PR with a visual diff that we can easily inspect.

---
## Run manually

To run this manually, use:

```bash
pnpm argos:build
pnpm argos:screenshot
pnpm argos:upload-text-snapshots
```

The Playwright reporter will upload the screenshots to Argos.

Some additional capabilities:
## How to modify

- Use [./tests/screenshot.spec.ts](./tests/screenshot.spec.ts) to customize the screenshots we take, eventually filter out some useless sitemap pages like versioned docs
- Use [./tests/screenshot.css](./tests/screenshot.css) to hide flaky CSS elements: iframe, video, gif...
8 changes: 5 additions & 3 deletions argos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"private": true,
"scripts": {
"screenshot": "playwright test",
"upload": "pnpm dlx @argos-ci/cli upload ./screenshots/chromium",
"upload": "pnpm exec -- argos upload ./screenshots/chromium",
"upload-text-snapshots": "pnpm exec -- argos upload \"../website/build\" --build-name text-snapshots --files styles.css --files \"docs/**/*.html\" --files \"blog/**/*.html\"",
"report": "playwright show-report"
},
"dependencies": {
"@argos-ci/playwright": "^7.0.6",
"@playwright/test": "^1.60.0",
"@argos-ci/cli": "^6.9.0",
"@argos-ci/playwright": "^7.4.6",
"@playwright/test": "^1.62.1",
"cheerio": "^1.2.0"
}
}
22 changes: 15 additions & 7 deletions argos/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
* LICENSE file in the root directory of this source tree.
*/

import {devices} from '@playwright/test';
import type {PlaywrightTestConfig} from '@playwright/test';
import {defineConfig, devices} from '@playwright/test';
import {createArgosReporterOptions} from '@argos-ci/playwright/reporter';

const argosOptions = createArgosReporterOptions({
uploadToArgos: true, // for now, we always upload even outside of CI
buildName: 'screenshots',
});

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
export default defineConfig({
testDir: './tests',

timeout: 60000,

reporter: [['list'], ['@argos-ci/playwright/reporter']],
reporter: [['list'], ['@argos-ci/playwright/reporter', argosOptions]],

// Run website production built
// Need to run "pnpm build:website:fast" before
Expand All @@ -32,9 +37,12 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// Recommended by Argos
// See https://argos-ci.com/docs/learn/reliability-and-flakiness/flaky-tests/stabilize-text-rendering
launchOptions: {
args: ['--disable-lcd-text', '--font-render-hinting=none'],
},
},
},
],
};

export default config;
});
4 changes: 3 additions & 1 deletion argos/tests/screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ function createPathnameTest(pathname: string) {
await page.waitForFunction(waitForDocusaurusHydration);
await page.addStyleTag({content: stylesheet});
// await expect(page).toHaveScreenshot({ fullPage: true, ...options });
await argosScreenshot(page, pathnameToArgosName(pathname));
await argosScreenshot(page, pathnameToArgosName(pathname), {
ariaSnapshot: true,
});
});
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
"crowdin:upload:website": "crowdin upload sources --config ./crowdin-v2.yaml",
"crowdin:download": "crowdin download --config ./crowdin-v2.yaml",
"crowdin:download:website": "pnpm crowdin:download --language fr --language ko --language pt-BR --language zh-CN --language ja",
"argos": "pnpm argos:build && pnpm argos:screenshot",
"argos": "pnpm argos:build && pnpm argos:screenshot && argos:upload-text-snapshots",
"argos:build": "cross-env DOCUSAURUS_ARGOS_BUILD=true pnpm build:website:fast --dev",
"argos:screenshot": "pnpm --filter argos screenshot",
"argos:upload-text-snapshots": "pnpm --filter argos upload-text-snapshots",
"canary": "pnpm canary:bumpVersion && pnpm canary:publish",
"canary:getCoreVersion": "node -p \"require('./packages/docusaurus/package.json').version.split('-')[0]\"",
"canary:version": "echo `pnpm --silent canary:getCoreVersion`-canary-`git rev-list --count HEAD`+`git rev-parse --short HEAD`",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import React, {type ReactNode} from 'react';
import clsx from 'clsx';
import Translate from '@docusaurus/Translate';
import {
PageMetadata,
HtmlClassNameProvider,
TagsPageLinkLabel,
ThemeClassNames,
} from '@docusaurus/theme-common';
import {useBlogTagsPostsPageTitle} from '@docusaurus/theme-common/internal';
Expand Down Expand Up @@ -47,11 +47,7 @@ function BlogTagsPostsPageContent({
<Heading as="h1">{title}</Heading>
{tag.description && <p>{tag.description}</p>}
<Link href={tag.allTagsPath}>
<Translate
id="theme.tags.tagsPageLink"
description="The label of the link targeting the tag list page">
View All Tags
</Translate>
<TagsPageLinkLabel />
</Link>
</header>
<BlogPostItems items={items} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
PageMetadata,
HtmlClassNameProvider,
ThemeClassNames,
TagsPageLinkLabel,
usePluralForm,
} from '@docusaurus/theme-common';
import Translate, {translate} from '@docusaurus/Translate';
import {translate} from '@docusaurus/Translate';
import SearchMetadata from '@theme/SearchMetadata';
import type {Props} from '@theme/DocTagDocListPage';
import Unlisted from '@theme/ContentVisibility/Unlisted';
Expand Down Expand Up @@ -88,11 +89,7 @@ function DocTagDocListPageContent({
<Heading as="h1">{title}</Heading>
{tag.description && <p>{tag.description}</p>}
<Link href={tag.allTagsPath}>
<Translate
id="theme.tags.tagsPageLink"
description="The label of the link targeting the tag list page">
View all tags
</Translate>
<TagsPageLinkLabel />
</Link>
</header>
<section className="margin-vert--lg">
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export {useWindowSize} from './hooks/useWindowSize';

export {
translateTagsPageTitle,
TagsPageLinkLabel,
listTagsByLetters,
type TagLetterEntry,
} from './utils/tagsUtils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {translate} from '@docusaurus/Translate';
import type {ReactNode} from 'react';
import Translate, {translate} from '@docusaurus/Translate';
import type {TagsListItem} from '@docusaurus/utils';

export const translateTagsPageTitle = (): string =>
Expand All @@ -15,6 +16,16 @@ export const translateTagsPageTitle = (): string =>
description: 'The title of the tag list page',
});

export function TagsPageLinkLabel(): ReactNode {
return (
<Translate
id="theme.tags.tagsPageLink"
description="The label of the link targeting the tag list page">
View all tags
</Translate>
);
}

export type TagLetterEntry = {letter: string; tags: TagsListItem[]};

function getTagLetter(tag: string): string {
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-translations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ This package includes default translations for labels (like the pagination "Next

Please help us provide exhaustive translations:

- add new translation by running `yarn workspace @docusaurus/theme-translations update %new_lang_code%`, then edit generated JSON files
- add new translation by running `pnpm --filter @docusaurus/theme-translations update %new_lang_code%`, then edit generated JSON files
- double-check existent `language.json` file for bad or missing translations

## For maintainers:

After updating the theme code, you can "synchronize" the translations by running:

```bash
yarn workspace @docusaurus/theme-translations update
pnpm --filter @docusaurus/theme-translations run update
```

Then, ask contributors to translate the newly added labels on this [issue](https://github.com/facebook/docusaurus/issues/3526)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "مُحـرر مُبـاشر",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "مُحـرر مُبـاشر",
"theme.Playground.result": "النتيجة"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.liveEditor___DESCRIPTION": "The live editor label of the live codeblocks",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.buttons.reset___DESCRIPTION": "The reset button label for live code blocks",
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.liveEditor___DESCRIPTION": "The live editor label of the live codeblocks",
"theme.Playground.result": "Result",
"theme.Playground.result___DESCRIPTION": "The result label of the live codeblocks"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.result": "Result"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "লাইভ এডিটর",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "লাইভ এডিটর",
"theme.Playground.result": "ফলাফল"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.result": "Výsledek"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live editor",
"theme.Playground.result": "Resultat"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.result": "Ergebnisse"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Editor en vivo",
"theme.Playground.buttons.reset": "Restablecer",
"theme.Playground.liveEditor": "Editor en vivo",
"theme.Playground.result": "Resultado"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live Redaktor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live Redaktor",
"theme.Playground.result": "Tulemus"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "ویرایشگر زنده",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "ویرایشگر زنده",
"theme.Playground.result": "خروجی"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live na Editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live na Editor",
"theme.Playground.result": "Resulta"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Éditeur en direct",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Éditeur en direct",
"theme.Playground.result": "Résultat"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.result": "תוצאה"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "लाइव एडिटर",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "लाइव एडिटर",
"theme.Playground.result": "परिणाम"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Interaktív szerkesztő",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Interaktív szerkesztő",
"theme.Playground.result": "Eredmény"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Penyunting Langung",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Penyunting Langung",
"theme.Playground.result": "Hasil"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Lifandi Ritill",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Lifandi Ritill",
"theme.Playground.result": "Niðurstaða"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Editor dal vivo",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Editor dal vivo",
"theme.Playground.result": "Risultato"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "ライブエディター",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "ライブエディター",
"theme.Playground.result": "結果"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "라이브 에디터",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "라이브 에디터",
"theme.Playground.result": "결과"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.buttons.reset": "Reset",
"theme.Playground.liveEditor": "Live Editor",
"theme.Playground.result": "Resultat"
}
Loading
Loading