Skip to content

Commit f84593d

Browse files
authored
Java iOS app example (#780)
* java native ios * java native FPS * clean pom * fix dockerfile * gh action * gh action * gh action * gh action * fix readme * newlines * fix sauce build name * add FPS to readme
1 parent eb187aa commit f84593d

16 files changed

+955
-0
lines changed

.github/workflows/java-ios.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Java iOS Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- 'java-ios-app/**'
7+
- '.github/workflows/java-ios.yml'
8+
branches:
9+
- main
10+
pull_request:
11+
paths:
12+
- 'java-ios-app/**'
13+
- '.github/workflows/java-ios.yml'
14+
branches:
15+
- main
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
java-ios-app:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Install saucectl
29+
uses: saucelabs/saucectl-run-action@v4
30+
env:
31+
GITHUB_TOKEN: ${{ github.token }}
32+
with:
33+
skip-run: true
34+
35+
- name: Pre-Upload App
36+
id: upload
37+
working-directory: ./wdio-ios-app/
38+
env:
39+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
40+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
41+
run: |
42+
APP_FILEID=$(saucectl storage upload ./app/SauceLabs-Demo-App.ipa -o json | jq -r '.id')
43+
SIMULATOR_APP_FILEID=$(saucectl storage upload ./app/SauceLabs-Demo-App.Simulator.ipa -o json | jq -r '.id')
44+
echo "APP_FILEID=${APP_FILEID}" >> $GITHUB_OUTPUT
45+
echo "SIMULATOR_APP_FILEID=${SIMULATOR_APP_FILEID}" >> $GITHUB_OUTPUT
46+
47+
- name: Build example
48+
uses: docker/[email protected]
49+
env:
50+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
51+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
52+
with:
53+
context: ./java-ios-app
54+
file: ./java-ios-app/Dockerfile
55+
build-args: |
56+
APP_FILEID=${{ steps.upload.outputs.APP_FILEID }}
57+
SIMULATOR_APP_FILEID=${{ steps.upload.outputs.SIMULATOR_APP_FILEID }}
58+
push: false
59+
secret-envs: |
60+
"SAUCE_USERNAME=SAUCE_USERNAME"
61+
"SAUCE_ACCESS_KEY=SAUCE_ACCESS_KEY"

java-ios-app/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target/
2+
.idea/
3+
.DS_Store
4+
*.iml
61.1 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar

java-ios-app/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM eclipse-temurin:8u432-b06-jdk-jammy AS runner
4+
5+
# Install curl
6+
RUN apt-get update && apt-get install -y curl
7+
# Install runme
8+
RUN curl -sSL https://download.stateful.com/runme/3.9.2/runme_linux_x86_64.tar.gz | tar -xz -C /usr/local/bin runme
9+
10+
FROM runner
11+
RUN mkdir -p /workspace
12+
WORKDIR /workspace
13+
COPY . .
14+
15+
ARG APP_FILEID
16+
17+
RUN --mount=type=secret,id=SAUCE_USERNAME,env=SAUCE_USERNAME \
18+
--mount=type=secret,id=SAUCE_ACCESS_KEY,env=SAUCE_ACCESS_KEY \
19+
runme run mvn-run-ios-test
20+
21+
RUN --mount=type=secret,id=SAUCE_USERNAME,env=SAUCE_USERNAME \
22+
--mount=type=secret,id=SAUCE_ACCESS_KEY,env=SAUCE_ACCESS_KEY \
23+
runme run mvn-run-ios-test-modified

java-ios-app/README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Getting started with Sauce Labs Visual Java + iOS Native App [![](https://badgen.net/badge/Run%20this%20/README/5B3ADF?icon=https://runme.dev/img/logo.svg)](https://runme.dev/api/runme?repository=git%40github.com%3Asaucelabs%2Fvisual-examples.git)
2+
3+
## Prerequisites
4+
5+
- For macOS Ventura: Git and Homebrew
6+
- For Linux: Git and Eclipse Temurin JDK 8+ (https://adoptium.net/temurin/releases/)
7+
- Sauce Labs Account
8+
9+
## Run the demo
10+
11+
- Install Eclipse Temurin JDK (for macOS Ventura):
12+
13+
```sh { "name":"java" }
14+
brew install --cask temurin
15+
```
16+
17+
- Clone the repository:
18+
19+
```sh { "name":"clone" }
20+
git clone https://github.com/saucelabs/visual-examples
21+
cd visual-examples/java-ios-app
22+
```
23+
24+
- Configure with your Sauce credentials from https://app.saucelabs.com/user-settings
25+
26+
```sh { "name":"set-credentials" }
27+
export SAUCE_USERNAME=__YOUR_SAUCE_USERNAME__
28+
export SAUCE_ACCESS_KEY=__YOUR_SAUCE_ACCESS_KEY__
29+
```
30+
31+
- Run the test
32+
33+
```sh { "name":"mvn-run-ios-test" }
34+
./mvnw clean test
35+
```
36+
37+
- Review your screenshots by clicking on the url printed in the test or go to https://app.saucelabs.com/visual/builds.
38+
- Accept all diffs, so they become new baselines.
39+
- Re-run the tests
40+
41+
```sh { "name":"mvn-run-ios-test-modified" }
42+
VISUAL_CHECK=enabled ./mvnw clean test
43+
```
44+
45+
- Open the test or go to https://app.saucelabs.com/visual/builds to review changes.
46+
47+
48+
**NOTE**: If you'd like run the full page screenshot test additionally,
49+
you need to pass the environment variable FPS=enabled when running the test.
50+
51+
```sh { "name":"mvn-run-ios-test-fps" }
52+
FPS=enabled ./mvnw clean test
53+
```
54+
55+
## Installation & Usage
56+
57+
View installation and usage instructions on
58+
the [Sauce Docs website](https://docs.saucelabs.com/visual-testing/integrations/java/).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../wdio-ios-app/app/SauceLabs-Demo-App.Simulator.ipa
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../wdio-ios-app/app/SauceLabs-Demo-App.ipa

0 commit comments

Comments
 (0)