docs: always keep docker references up-to-date in documentation (#12795)
References #12796
This commit is contained in:
parent
e231db1810
commit
e16f3c46b4
|
|
@ -176,7 +176,7 @@ For Linux agents, you can use [our Docker container](./docker.md) with Azure Pip
|
||||||
pool:
|
pool:
|
||||||
vmImage: 'ubuntu-20.04'
|
vmImage: 'ubuntu-20.04'
|
||||||
|
|
||||||
container: mcr.microsoft.com/playwright:focal
|
container: mcr.microsoft.com/playwright:v1.21.0-focal
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
...
|
...
|
||||||
|
|
@ -244,7 +244,7 @@ Running Playwright on CircleCI requires the following steps:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
docker:
|
docker:
|
||||||
- image: mcr.microsoft.com/playwright:focal
|
- image: mcr.microsoft.com/playwright:v1.21.0-focal
|
||||||
environment:
|
environment:
|
||||||
NODE_ENV: development # Needed if playwright is in `devDependencies`
|
NODE_ENV: development # Needed if playwright is in `devDependencies`
|
||||||
```
|
```
|
||||||
|
|
@ -266,7 +266,7 @@ to run tests on Jenkins.
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { docker { image 'mcr.microsoft.com/playwright:focal' } }
|
agent { docker { image 'mcr.microsoft.com/playwright:v1.21.0-focal' } }
|
||||||
stages {
|
stages {
|
||||||
stage('e2e-tests') {
|
stage('e2e-tests') {
|
||||||
steps {
|
steps {
|
||||||
|
|
@ -283,7 +283,7 @@ pipeline {
|
||||||
Bitbucket Pipelines can use public [Docker images as build environments](https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html). To run Playwright tests on Bitbucket, use our public Docker image ([see Dockerfile](./docker.md)).
|
Bitbucket Pipelines can use public [Docker images as build environments](https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html). To run Playwright tests on Bitbucket, use our public Docker image ([see Dockerfile](./docker.md)).
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
image: mcr.microsoft.com/playwright:focal
|
image: mcr.microsoft.com/playwright:v1.21.0-focal
|
||||||
```
|
```
|
||||||
|
|
||||||
While the Docker image supports sandboxing for Chromium, it does not work in the Bitbucket Pipelines environment. To launch Chromium on Bitbucket Pipelines, use the `chromiumSandbox: false` launch argument.
|
While the Docker image supports sandboxing for Chromium, it does not work in the Bitbucket Pipelines environment. To launch Chromium on Bitbucket Pipelines, use the `chromiumSandbox: false` launch argument.
|
||||||
|
|
@ -341,7 +341,7 @@ stages:
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
stage: test
|
stage: test
|
||||||
image: mcr.microsoft.com/playwright:focal
|
image: mcr.microsoft.com/playwright:v1.21.0-focal
|
||||||
script:
|
script:
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,19 @@ This image is published on [Docker Hub].
|
||||||
Replace 1.20.0 with your Playwright version:
|
Replace 1.20.0 with your Playwright version:
|
||||||
|
|
||||||
```bash js
|
```bash js
|
||||||
docker pull mcr.microsoft.com/playwright:v1.20.0-focal
|
docker pull mcr.microsoft.com/playwright:v1.21.0-focal
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash python
|
```bash python
|
||||||
docker pull mcr.microsoft.com/playwright/python:v1.20.0-focal
|
docker pull mcr.microsoft.com/playwright/python:v1.21.0-focal
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash csharp
|
```bash csharp
|
||||||
docker pull mcr.microsoft.com/playwright:v1.20.0-focal
|
docker pull mcr.microsoft.com/playwright:v1.21.0-focal
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash java
|
```bash java
|
||||||
docker pull mcr.microsoft.com/playwright/java:v1.20.0-focal
|
docker pull mcr.microsoft.com/playwright/java:v1.21.0-focal
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run the image
|
### Run the image
|
||||||
|
|
@ -40,19 +40,19 @@ By default, the Docker image will use the `root` user to run the browsers. This
|
||||||
On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers.
|
On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers.
|
||||||
|
|
||||||
```bash js
|
```bash js
|
||||||
docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash python
|
```bash python
|
||||||
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/python:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/python:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash csharp
|
```bash csharp
|
||||||
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash java
|
```bash java
|
||||||
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Crawling and scraping
|
#### Crawling and scraping
|
||||||
|
|
@ -60,19 +60,19 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.20.0-focal /
|
||||||
On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.
|
On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.
|
||||||
|
|
||||||
```bash js
|
```bash js
|
||||||
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash python
|
```bash python
|
||||||
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/python:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/python:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash csharp
|
```bash csharp
|
||||||
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash java
|
```bash java
|
||||||
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.20.0-focal /bin/bash
|
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.21.0-focal /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/main/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
|
[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/main/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ The snapshot name `example-test-1-chromium-darwin.png` consists of a few parts:
|
||||||
If you are not on the same operating system as your CI system, you can use Docker to generate/update the screenshots:
|
If you are not on the same operating system as your CI system, you can use Docker to generate/update the screenshots:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.20.0-focal /bin/bash
|
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.21.0-focal /bin/bash
|
||||||
npm install
|
npm install
|
||||||
npx playwright test --update-snapshots
|
npx playwright test --update-snapshots
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,16 @@ run().catch(e => {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});;
|
});;
|
||||||
|
|
||||||
|
function getAllMarkdownFiles(dirPath, filePaths = []) {
|
||||||
|
for (const entry of fs.readdirSync(dirPath, { withFileTypes: true })) {
|
||||||
|
if (entry.isFile() && entry.name.toLowerCase().endsWith('.md'))
|
||||||
|
filePaths.push(path.join(dirPath, entry.name));
|
||||||
|
else if (entry.isDirectory())
|
||||||
|
getAllMarkdownFiles(path.join(dirPath, entry.name), filePaths);
|
||||||
|
}
|
||||||
|
return filePaths;
|
||||||
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
// Patch README.md
|
// Patch README.md
|
||||||
const versions = await getBrowserVersions();
|
const versions = await getBrowserVersions();
|
||||||
|
|
@ -60,6 +70,21 @@ async function run() {
|
||||||
writeAssumeNoop(path.join(PROJECT_DIR, 'README.md'), content, dirtyFiles);
|
writeAssumeNoop(path.join(PROJECT_DIR, 'README.md'), content, dirtyFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Patch docker version in docs
|
||||||
|
{
|
||||||
|
let playwrightVersion = require(path.join(PROJECT_DIR, 'package.json')).version;
|
||||||
|
if (playwrightVersion.endsWith('-next'))
|
||||||
|
playwrightVersion = playwrightVersion.substring(0, playwrightVersion.indexOf('-next'));
|
||||||
|
const regex = new RegExp("(mcr.microsoft.com/playwright[^: ]*):?([^ ]*)");
|
||||||
|
for (const filePath of getAllMarkdownFiles(path.join(PROJECT_DIR, 'docs'))) {
|
||||||
|
let content = fs.readFileSync(filePath).toString();
|
||||||
|
content = content.replace(new RegExp('(mcr.microsoft.com/playwright[^:]*):([\\w\\d-.]+)', 'ig'), (match, imageName, imageVersion) => {
|
||||||
|
return `${imageName}:v${playwrightVersion}-focal`;
|
||||||
|
});
|
||||||
|
writeAssumeNoop(filePath, content, dirtyFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update device descriptors
|
// Update device descriptors
|
||||||
{
|
{
|
||||||
const devicesDescriptorsSourceFile = path.join(PROJECT_DIR, 'packages', 'playwright-core', 'src', 'server', 'deviceDescriptorsSource.json')
|
const devicesDescriptorsSourceFile = path.join(PROJECT_DIR, 'packages', 'playwright-core', 'src', 'server', 'deviceDescriptorsSource.json')
|
||||||
|
|
@ -112,12 +137,10 @@ async function run() {
|
||||||
// This validates member links.
|
// This validates member links.
|
||||||
documentation.setLinkRenderer(() => undefined);
|
documentation.setLinkRenderer(() => undefined);
|
||||||
|
|
||||||
for (const file of fs.readdirSync(path.join(PROJECT_DIR, 'docs', 'src'))) {
|
for (const filePath of getAllMarkdownFiles(path.join(PROJECT_DIR, 'docs', 'src'))) {
|
||||||
if (!file.endsWith('.md'))
|
if (langs.some(other => other !== lang && filePath.endsWith(`-${other}.md`)))
|
||||||
continue;
|
continue;
|
||||||
if (langs.some(other => other !== lang && file.endsWith(`-${other}.md`)))
|
const data = fs.readFileSync(filePath, 'utf-8');
|
||||||
continue;
|
|
||||||
const data = fs.readFileSync(path.join(PROJECT_DIR, 'docs', 'src', file)).toString();
|
|
||||||
documentation.renderLinksInText(md.filterNodesForLanguage(md.parse(data), lang));
|
documentation.renderLinksInText(md.filterNodesForLanguage(md.parse(data), lang));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue