devops: auto update browser versions in readme (#153)

This commit is contained in:
Yury Semikhatsky 2020-12-18 18:42:11 -08:00 committed by GitHub
parent ef6adb8123
commit 569259d3df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 157 additions and 36 deletions

View File

@ -9,7 +9,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->89.0.4344.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit 14.1 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->14.1<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->84.0b9<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/#?path=docs/intro.md&q=system-requirements) for details.

View File

@ -36,7 +36,6 @@
</scm>
<modules>
<module>api-generator</module>
<module>driver</module>
<module>driver-bundle</module>
<module>playwright</module>

View File

@ -9,9 +9,9 @@ cd "$(dirname $0)/.."
PLAYWRIGHT_CLI=./driver-bundle/src/main/resources/driver/linux/playwright-cli
echo "Updating api.json from $($PLAYWRIGHT_CLI --version)"
$PLAYWRIGHT_CLI print-api-json > ./api-generator/src/main/resources/api.json
$PLAYWRIGHT_CLI print-api-json > ./tools/api-generator/src/main/resources/api.json
mvn compile -projects api-generator --no-transfer-progress
mvn compile -f ./tools/api-generator --no-transfer-progress
echo "Regenerating Java interfaces"
mvn exec:java --projects api-generator -Dexec.mainClass=com.microsoft.playwright.tools.ApiGenerator
mvn exec:java --f ./tools/api-generator -Dexec.mainClass=com.microsoft.playwright.tools.ApiGenerator

25
scripts/set_maven_version.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
set +x
if [[ $# == 0 ]]; then
echo "Missing version parameter."
echo "Usage:"
echo " $(basename $0) 0.170.3-SNAPSHOT"
exit 1
fi
trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)/.."
VERSION=$1
mvn versions:set -DnewVersion=$VERSION
cd tools/api-generator
mvn versions:set -DnewVersion=$VERSION
cd -
cd tools/update-docs-version
mvn versions:set -DnewVersion=$VERSION

16
scripts/update_api.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -e
set +x
trap "cd $(pwd -P)" EXIT
cd "$(dirname $0)/.."
./scripts/generate_api.sh
# Built from source and do local install.
mvn clean install --no-transfer-progress -DskipTests
echo "Updating browser versions in README.md"
mvn exec:java --f ./tools/update-docs-version -Dexec.mainClass=com.microsoft.playwright.tools.UpdateBrowserVersions

View File

@ -4,47 +4,30 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>0.170.3-SNAPSHOT</version>
</parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>api-generator</artifactId>
<version>0.170.3-SNAPSHOT</version>
<name>Playwright - API Generator</name>
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
Playwright is built to enable cross-browser web automation that is ever-green, capable,
reliable and fast.
<description>
This is an internal module used to generate Java API from the upstream Playwright
definitions. It's an internal development module not intended for external use.
</description>
<properties>
<compiler.version>1.8</compiler.version>
<gson.version>2.8.6</gson.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>8</source>
<failOnError>false</failOnError>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
</configuration>
</plugin>
</plugins>
</build>
@ -52,6 +35,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1202,7 +1202,7 @@ public class ApiGenerator {
public static void main(String[] args) throws IOException {
File cwd = FileSystems.getDefault().getPath(".").toFile();
System.out.println(cwd.getCanonicalPath());
File file = new File(cwd, "api-generator/src/main/resources/api.json");
File file = new File(cwd, "tools/api-generator/src/main/resources/api.json");
System.out.println("Reading from: " + file.getCanonicalPath());
new ApiGenerator(new FileReader(file));
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>update-version</artifactId>
<version>0.170.3-SNAPSHOT</version>
<name>Playwright - Update Version in Documentation</name>
<description>
This is an internal module used to update versions in the documentation based on
current driver.
</description>
<properties>
<compiler.version>1.8</compiler.version>
<gson.version>2.8.6</gson.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright.tools;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Playwright;
import java.io.FileWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static java.nio.charset.StandardCharsets.UTF_8;
public class UpdateBrowserVersions {
public static void main(String[] args) throws Exception {
Path path = Paths.get("README.md");
String readme = new String(Files.readAllBytes(path), UTF_8);
Playwright playwright = Playwright.create();
List<BrowserType> browserTypes = Arrays.asList(
playwright.chromium(),
playwright.webkit(),
playwright.firefox()
);
for (BrowserType browserType : browserTypes) {
Browser browser = browserType.launch();
String version = browser.version();
browser.close();
readme = readme.replaceAll(
"<!-- GEN:" + browserType.name() + "-version -->([^<]+)<!-- GEN:stop -->",
"<!-- GEN:" + browserType.name() + "-version -->" + version + "<!-- GEN:stop -->");
try (FileWriter writer = new FileWriter(path.toFile())) {
writer.write(readme);
}
}
playwright.close();
}
}