Skip to content

Java iOS app example #780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/java-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Java iOS Tests

on:
push:
paths:
- 'java-ios-app/**'
- '.github/workflows/java-ios.yml'
branches:
- main
pull_request:
paths:
- 'java-ios-app/**'
- '.github/workflows/java-ios.yml'
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
java-ios-app:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install saucectl
uses: saucelabs/saucectl-run-action@v4
env:
GITHUB_TOKEN: ${{ github.token }}
with:
skip-run: true

- name: Pre-Upload App
id: upload
working-directory: ./wdio-ios-app/
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: |
APP_FILEID=$(saucectl storage upload ./app/SauceLabs-Demo-App.ipa -o json | jq -r '.id')
SIMULATOR_APP_FILEID=$(saucectl storage upload ./app/SauceLabs-Demo-App.Simulator.ipa -o json | jq -r '.id')
echo "APP_FILEID=${APP_FILEID}" >> $GITHUB_OUTPUT
echo "SIMULATOR_APP_FILEID=${SIMULATOR_APP_FILEID}" >> $GITHUB_OUTPUT

- name: Build example
uses: docker/[email protected]
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
with:
context: ./java-ios-app
file: ./java-ios-app/Dockerfile
build-args: |
APP_FILEID=${{ steps.upload.outputs.APP_FILEID }}
SIMULATOR_APP_FILEID=${{ steps.upload.outputs.SIMULATOR_APP_FILEID }}
push: false
secret-envs: |
"SAUCE_USERNAME=SAUCE_USERNAME"
"SAUCE_ACCESS_KEY=SAUCE_ACCESS_KEY"
4 changes: 4 additions & 0 deletions java-ios-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/
.idea/
.DS_Store
*.iml
Binary file added java-ios-app/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions java-ios-app/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
23 changes: 23 additions & 0 deletions java-ios-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1

FROM eclipse-temurin:8u432-b06-jdk-jammy AS runner

# Install curl
RUN apt-get update && apt-get install -y curl
# Install runme
RUN curl -sSL https://download.stateful.com/runme/3.9.2/runme_linux_x86_64.tar.gz | tar -xz -C /usr/local/bin runme

FROM runner
RUN mkdir -p /workspace
WORKDIR /workspace
COPY . .

ARG APP_FILEID

RUN --mount=type=secret,id=SAUCE_USERNAME,env=SAUCE_USERNAME \
--mount=type=secret,id=SAUCE_ACCESS_KEY,env=SAUCE_ACCESS_KEY \
runme run mvn-run-ios-test

RUN --mount=type=secret,id=SAUCE_USERNAME,env=SAUCE_USERNAME \
--mount=type=secret,id=SAUCE_ACCESS_KEY,env=SAUCE_ACCESS_KEY \
runme run mvn-run-ios-test-modified
58 changes: 58 additions & 0 deletions java-ios-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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)

## Prerequisites

- For macOS Ventura: Git and Homebrew
- For Linux: Git and Eclipse Temurin JDK 8+ (https://adoptium.net/temurin/releases/)
- Sauce Labs Account

## Run the demo

- Install Eclipse Temurin JDK (for macOS Ventura):

```sh { "name":"java" }
brew install --cask temurin
```

- Clone the repository:

```sh { "name":"clone" }
git clone https://github.com/saucelabs/visual-examples
cd visual-examples/java-ios-app
```

- Configure with your Sauce credentials from https://app.saucelabs.com/user-settings

```sh { "name":"set-credentials" }
export SAUCE_USERNAME=__YOUR_SAUCE_USERNAME__
export SAUCE_ACCESS_KEY=__YOUR_SAUCE_ACCESS_KEY__
```

- Run the test

```sh { "name":"mvn-run-ios-test" }
./mvnw clean test
```

- Review your screenshots by clicking on the url printed in the test or go to https://app.saucelabs.com/visual/builds.
- Accept all diffs, so they become new baselines.
- Re-run the tests

```sh { "name":"mvn-run-ios-test-modified" }
VISUAL_CHECK=enabled ./mvnw clean test
```

- Open the test or go to https://app.saucelabs.com/visual/builds to review changes.


**NOTE**: If you'd like run the full page screenshot test additionally,
you need to pass the environment variable FPS=enabled when running the test.

```sh { "name":"mvn-run-ios-test-fps" }
FPS=enabled ./mvnw clean test
```

## Installation & Usage

View installation and usage instructions on
the [Sauce Docs website](https://docs.saucelabs.com/visual-testing/integrations/java/).
1 change: 1 addition & 0 deletions java-ios-app/app/SauceLabs-Demo-App.Simulator.ipa
1 change: 1 addition & 0 deletions java-ios-app/app/SauceLabs-Demo-App.ipa
Loading