Skip to content

Commit 5384f7f

Browse files
authored
Merge branch 'develop' into 2422-arm64-support
2 parents 26b87c9 + 233190b commit 5384f7f

File tree

140 files changed

+2157
-1482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2157
-1482
lines changed

.github/workflows/codeql.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
# Initializes the CodeQL tools for scanning.
4646
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v2
47+
uses: github/codeql-action/init@v3
4848
with:
4949
languages: ${{ matrix.language }}
5050
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -58,7 +58,7 @@ jobs:
5858
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below)
6060
- name: Autobuild
61-
uses: github/codeql-action/autobuild@v2
61+
uses: github/codeql-action/autobuild@v3
6262

6363
# ℹ️ Command-line programs to run using the OS shell.
6464
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -71,6 +71,6 @@ jobs:
7171
# ./location_of_script_within_repo/buildscript.sh
7272

7373
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@v2
74+
uses: github/codeql-action/analyze@v3
7575
with:
7676
category: "/language:${{matrix.language}}"

.github/workflows/jdk-compat.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
uses: oracle-actions/setup-java@v1
1616
with:
1717
website: jdk.java.net
18-
release: 21
18+
release: 23
1919
- name: cache maven packages
20-
uses: actions/cache@v3
20+
uses: actions/cache@v4
2121
with:
2222
path: ~/.m2/repository
2323
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2424
restore-keys: ${{ runner.os }}-maven-
2525
- name: build with maven
26-
run: mvn -B clean install -P pre-release -pl '!karate-gatling' -Djavacpp.platform=linux-x86_64
26+
run: mvn -B clean install -P pre-release -Djavacpp.platform=linux-x86_64

.github/workflows/maven-build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
- name: git checkout
1515
uses: actions/checkout@v4
1616
- name: set up jdk 17
17-
uses: actions/setup-java@v3
17+
uses: actions/setup-java@v4
1818
with:
1919
distribution: adopt
2020
java-version: 17
2121
- name: cache maven packages
22-
uses: actions/cache@v3
22+
uses: actions/cache@v4
2323
with:
2424
path: ~/.m2/repository
2525
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -31,7 +31,7 @@ jobs:
3131
- name: upload workspace if build fails
3232
# if: ${{ failure() }}
3333
if: ${{ false }}
34-
uses: actions/upload-artifact@v3
34+
uses: actions/upload-artifact@v4
3535
with:
3636
name: build-results
3737
path: .

.github/workflows/maven-release.yml

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: version
87
required: true
98
default: 'X.X.X.RCX'
9+
docker:
10+
required: true
11+
type: choice
12+
options:
13+
- 'enabled'
14+
- 'disabled'
1015

1116
jobs:
1217
build:
@@ -16,7 +21,7 @@ jobs:
1621
- name: git checkout
1722
uses: actions/checkout@v4
1823
- name: set up jdk 17
19-
uses: actions/setup-java@v3
24+
uses: actions/setup-java@v4
2025
with:
2126
distribution: adopt
2227
java-version: 17
@@ -29,22 +34,25 @@ jobs:
2934
run: |
3035
mvn versions:set versions:commit -B -ntp -DnewVersion=${{ github.event.inputs.version }}
3136
- name: docker build
37+
if: ( github.event.inputs.docker == 'enabled' )
3238
run: |
3339
mvn clean install -B -ntp -DskipTests -P pre-release
3440
./build-docker.sh
3541
- name: docker login
36-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
42+
if: ( github.event.inputs.docker == 'enabled' )
43+
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
3744
with:
3845
username: ${{ secrets.DOCKER_USERNAME }}
3946
password: ${{ secrets.DOCKER_PASSWORD }}
4047
- name: docker push
48+
if: ( github.event.inputs.docker == 'enabled' )
4149
run: |
4250
docker buildx build --push --platform linux/amd64 --cache-from=type=local,src=./target/docker -t karate-chrome -t karatelabs/karate-chrome:latest -t karatelabs/karate-chrome:${{ github.event.inputs.version }} karate-docker/karate-chrome
4351
docker buildx build --push --platform linux/amd64,linux/arm64 --cache-from=type=local,src=./target/docker -t karate-chromium -t karatelabs/karate-chromium:latest -t karatelabs/karate-chromium:${{ github.event.inputs.version }} karate-docker/karate-chromium
4452
- name: maven deploy to central
4553
env:
46-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
47-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
54+
MAVEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USER }}
55+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
4856
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
4957
run: |
5058
mvn -B -ntp deploy -DskipTests -P pre-release,release
@@ -53,7 +61,7 @@ jobs:
5361
mvn package -DskipTests -P fatjar -f karate-core/pom.xml
5462
mvn package -DskipTests -P fatjar -f karate-robot/pom.xml
5563
- name: upload binaries
56-
uses: actions/upload-artifact@v3
64+
uses: actions/upload-artifact@v4
5765
with:
5866
name: karate-release-${{ github.event.inputs.version }}
5967
retention-days: 5

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
</a>
4848
</div>
4949
<div>
50-
<a href="https://central.sonatype.com/namespace/com.intuit.karate">
51-
<img src="https://img.shields.io/maven-central/v/com.intuit.karate/karate-core.svg"/>
50+
<a href="https://central.sonatype.com/namespace/io.karatelabs">
51+
<img src="https://img.shields.io/maven-central/v/io.karatelabs/karate-core.svg"/>
5252
</a>
5353
<a href="https://github.com/karatelabs/karate/actions?query=workflow%3Amaven-build">
5454
<img src="https://github.com/karatelabs/karate/actions/workflows/maven-build.yml/badge.svg?branch=develop"/>
@@ -1790,6 +1790,8 @@ This can be easily solved by using `java.math.BigDecimal`:
17901790
* match json == '{"num":123123123123}'
17911791
```
17921792

1793+
For more tips, refer [here](https://stackoverflow.com/a/77576066/143475).
1794+
17931795
## `doc`
17941796
Karate has a built-in HTML templating engine that can be used to insert additional custom HTML into the test-reports. Here is an [example](karate-core/src/test/java/com/intuit/karate/core/users-doc.feature):
17951797

examples/consumer-driven-contracts/payment-producer/src/main/java/payment/producer/PaymentService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public Payment create(@RequestBody Payment payment) {
4444
}
4545

4646
@PutMapping("/{id:.+}")
47-
public Payment update(@PathVariable int id, @RequestBody Payment payment) {
47+
public Payment update(@PathVariable("id") int id, @RequestBody Payment payment) {
4848
payments.put(id, payment);
4949
return payment;
5050
}
@@ -55,7 +55,7 @@ public Collection<Payment> list() {
5555
}
5656

5757
@GetMapping("/{id:.+}")
58-
public Payment get(@PathVariable int id) {
58+
public Payment get(@PathVariable("id") int id) {
5959
Payment payment = payments.get(id);
6060
if (payment == null) {
6161
throw new ResponseStatusException(HttpStatus.NOT_FOUND);
@@ -64,7 +64,7 @@ public Payment get(@PathVariable int id) {
6464
}
6565

6666
@DeleteMapping("/{id:.+}")
67-
public void delete(@PathVariable int id) {
67+
public void delete(@PathVariable("id") int id) {
6868
Payment payment = payments.remove(id);
6969
if (payment == null) {
7070
throw new RuntimeException("payment not found, id: " + id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Feature:
2+
3+
Scenario:
4+
* print 'hello'

examples/consumer-driven-contracts/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
<properties>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
<java.version>11</java.version>
1817
<maven.compiler.version>3.8.1</maven.compiler.version>
1918
<maven.surefire.version>2.22.2</maven.surefire.version>
20-
<spring.boot.version>2.3.4.RELEASE</spring.boot.version>
19+
<spring.boot.version>3.2.2</spring.boot.version>
2120
<junit5.version>5.7.0</junit5.version>
22-
<karate.version>1.4.1</karate.version>
21+
<java.version>17</java.version>
22+
<karate.version>1.5.0.RC3</karate.version>
2323
</properties>
2424

2525
<dependencies>

karate-core/README.md

+31-9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
| <a href="#karate-chrome">Docker / <code>karate-chrome</code></a>
2626
| <a href="#driver-types">Driver Types</a>
2727
| <a href="#playwright">Playwright</a>
28+
| <a href="#playwright-legacy">Playwright Legacy</a>
2829
| <a href="#timeout"><code>timeout()</code></a>
2930
| <a href="#driversessionid"><code>driver.sessionId</code></a>
3031
</td>
@@ -346,7 +347,36 @@ Note that some capabilities such as "headless" may be possible via the command-l
346347

347348
Also see [`driver.sessionId`](#driversessionid).
348349

350+
349351
### Playwright
352+
353+
Driver that leverages [Playwright](https://playwright.dev) java native APIs.
354+
355+
To use it, add the following dependency:
356+
```xml
357+
<dependency>
358+
<groupId>io.karate</groupId>
359+
<artifactId>karate-playwright</artifactId>
360+
<scope>test</scope>
361+
</dependency>
362+
```
363+
364+
And make sure it is declared before `io.karate:karate-core`.
365+
366+
A server will be automatically started and made available to Karate without any extra-script. If you have one pre-started, you can still use the [`playwrightUrl`](#configure-driver) driver config.
367+
368+
### `playwrightOptions`
369+
When using [Playwright](#playwright) you can omit this in which case Karate will default to Chrome (within Playwright) and the default browser window size.
370+
371+
This can take the following keys:
372+
* `browserType` - defaults to `chromium`, can be set to the other [types that Playwright supports](https://playwright.dev/docs/core-concepts#browser), e.g. `firefox` and `webkit`
373+
* `context` - JSON which will be passed as the argument of the Playwright [`browser.newContext()`](https://playwright.dev/docs/api/class-browser#browsernewcontextoptions) call, needed typically to set the page dimensions
374+
* `channel` - defaults to chrome, for the `chromium` browserType, allows to specify which [flavor](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge) to use
375+
* `installBrowsers` - defaults to `true`, whether or not all the supported browsers will be downloaded and installed by Playwright (once).
376+
377+
Note that there is a top-level config flag for `headless` mode. The default is: `* configure driver = { headless: false }`
378+
379+
### Playwright Legacy
350380
To use [Playwright](https://playwright.dev), you need to start a Playwright server. If you have one pre-started, you need to use the [`playwrightUrl`](#configure-driver) driver config.
351381

352382
Or you can set up an executable that can do it and log the URL to the console when the server is ready. The websocket URL will look like this: `ws://127.0.0.1:4444/0e0bd1c0bb2d4eb550d02c91046dd6e0`.
@@ -399,14 +429,6 @@ For convenience, Karate assumes by default that the executable name is `playwrig
399429

400430
Based on the above details, you should be able to come up with a custom strategy to connect Karate to Playwright. And you can consider a [`driverTarget`](#custom-target) approach for complex needs such as using a Docker container for CI.
401431

402-
### `playwrightOptions`
403-
When using [Playwright](#playwright) you can omit this in which case Karate will default to Chrome (within Playwright) and the default browser window size.
404-
405-
This can take the following keys:
406-
* `browserType` - defaults to `chromium`, can be set to the other [types that Playwright supports](https://playwright.dev/docs/core-concepts#browser), e.g. `firefox` and `webkit`
407-
* `context` - JSON which will be passed as the argument of the Playwright [`browser.newContext()`](https://playwright.dev/docs/api/class-browser#browsernewcontextoptions) call, needed typically to set the page dimensions
408-
409-
Note that there is a top-level config flag for `headless` mode. The default is: `* configure driver = { headless: false }`
410432

411433
## `configure driverTarget`
412434
The [`configure driver`](#configure-driver) options are fine for testing on "`localhost`" and when not in `headless` mode. But when the time comes for running your web-UI automation tests on a continuous integration server, things get interesting. To support all the various options such as Docker, headless Chrome, cloud-providers etc., Karate introduces the concept of a pluggable [`Target`](src/main/java/com/intuit/karate/driver/Target.java) where you just have to implement two methods:
@@ -1950,7 +1972,7 @@ Scenario:
19501972
* screenshot()
19511973
```
19521974

1953-
* `driver.intercept()` is supported only for the driver type `chrome`
1975+
* `driver.intercept()` is fully supported only for the driver type `chrome`. [`Playwright`](#playwright) supports only [urlPatterns](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#type-RequestPattern)
19541976
* you can route multiple URL patterns to the same Karate mock-feature, the format of each array-element under `patterns` can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#type-RequestPattern).
19551977
* the `*` wildcard (most likely what you need) will match any number of characters, e.g. `*myhost/some/path/*`
19561978
* `?` will match any single character

0 commit comments

Comments
 (0)