Skip to content

Commit 8e750e5

Browse files
authored
chore: drop api.json from repo, generate instead (#133)
1 parent 0485994 commit 8e750e5

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

.github/workflows/verify_api.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Verify API
2+
on:
3+
push:
4+
branches: [ master ]
5+
paths:
6+
- 'scripts/*'
7+
- 'api-generator/*'
8+
pull_request:
9+
branches: [ master ]
10+
paths:
11+
- 'scripts/**'
12+
- 'api-generator/**'
13+
jobs:
14+
verify:
15+
timeout-minutes: 30
16+
strategy:
17+
fail-fast: true
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Cache Maven packages
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.m2
25+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
26+
restore-keys: ${{ runner.os }}-m2
27+
- name: Cache Downloaded Drivers
28+
uses: actions/cache@v2
29+
with:
30+
path: driver-bundle/src/main/resources/driver
31+
key: ${{ runner.os }}-drivers-${{ hashFiles('scripts/*') }}
32+
restore-keys: ${{ runner.os }}-drivers
33+
- name: Download drivers
34+
run: scripts/download_driver_for_all_platforms.sh
35+
- name: Regenerate APIs
36+
run: scripts/generate_api.sh
37+
- name: Verify API is up to date
38+
run: |
39+
if [[ -n $(git status -s) ]]; then
40+
echo "ERROR: generated interfaces differ from the current sources:"
41+
git diff
42+
exit 1
43+
fi

CONTRIBUTING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ mvn test
2828

2929
### Generating API
3030

31-
Public Java API is generated from [api.json](https://github.com/microsoft/playwright-java/blob/master/api-generator/src/main/resources/api.json) which in turn is created by `playwright-cli print-api-json`.
31+
Public Java API is generated from api.json which is produced by `playwright-cli print-api-json`. To regenerate
32+
Java interfaces for the current driver run the following commands:
33+
34+
```bash
35+
./scripts/download_driver_for_all_platforms.sh
36+
./scripts/generate_api.sh
37+
```
3238

3339
### Code Style
3440

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api.json

api-generator/src/main/resources/api.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/generate_api.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cd "$(dirname $0)/.."
99
echo "Updating api.json"
1010
./driver-bundle/src/main/resources/driver/linux/playwright-cli print-api-json > ./api-generator/src/main/resources/api.json
1111

12-
mvn compile -projects api-generator
12+
mvn compile -projects api-generator --no-transfer-progress
1313

1414
echo "Regenerating Java interfaces"
1515
mvn exec:java --projects api-generator -Dexec.mainClass=com.microsoft.playwright.tools.ApiGenerator

0 commit comments

Comments
 (0)