generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
20,714 additions
and
15,754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
tab_width = 2 | ||
ij_continuation_indent_size = 2 | ||
end_of_line = lf | ||
max_line_length = off | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
ij_visual_guides = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set Node.js 16.x | ||
uses: actions/[email protected] | ||
|
@@ -46,7 +46,7 @@ jobs: | |
id: diff | ||
|
||
# If index.js was different than expected, upload the expected version as an artifact | ||
- uses: actions/upload-artifact@v2 | ||
- uses: actions/upload-artifact@v3 | ||
if: ${{ failure() && steps.diff.conclusion == 'failure' }} | ||
with: | ||
name: dist | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,60 @@ | ||
name: 'build-test' | ||
on: # rebuild any PRs and main branch changes | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- 'releases/*' | ||
|
||
jobs: | ||
build: # make sure build/ci work properly | ||
runs-on: ubuntu-latest | ||
build: | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
npm install | ||
- run: | | ||
npm run all | ||
test: # make sure the action works on a clean machine without building | ||
runs-on: ubuntu-latest | ||
- uses: actions/checkout@v3 | ||
- run: npm install | ||
- run: npm run all | ||
|
||
android-test: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
- uses: ./ | ||
- uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 29 | ||
arch: x86_64 | ||
ram-size: 2048M | ||
target: default | ||
script: maestro test --format=junit --output=report.xml --no-ansi .maestro/android-contacts.yaml | ||
- uses: dorny/test-reporter@v1 | ||
if: success() || failure() | ||
with: | ||
name: Maestro tests | ||
path: report.xml | ||
reporter: java-junit | ||
|
||
ios-test: | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: futureware-tech/simulator-action@v2 | ||
with: | ||
model: 'iPhone 14 Pro' | ||
- uses: ./ | ||
id: maestro | ||
with: | ||
flow: .maestro/ios-settings.yaml | ||
report: report.xml | ||
- uses: dorny/test-reporter@v1 | ||
if: success() || failure() | ||
with: | ||
milliseconds: 1000 | ||
name: Maestro tests | ||
path: ${{ steps.maestro.outputs.report }} | ||
reporter: java-junit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
appId: com.android.contacts | ||
--- | ||
- launchApp | ||
- tapOn: "Create new contact" | ||
- runFlow: | ||
when: | ||
visible: "ADD ACCOUNT" | ||
file: subflows/dismiss-dialog.yaml | ||
- tapOn: "First name" | ||
- inputRandomPersonName | ||
- tapOn: "Last name" | ||
- inputRandomPersonName | ||
- tapOn: "Phone" | ||
- inputRandomNumber: | ||
length: 10 | ||
- tapOn: "Save" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
appId: com.apple.Preferences | ||
--- | ||
- launchApp | ||
- tapOn: "General" | ||
- tapOn: "About" | ||
- assertVisible: "iOS Version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
appId: com.android.contacts | ||
--- | ||
- tapOn: "CANCEL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,104 +2,127 @@ | |
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a> | ||
</p> | ||
|
||
# Create a JavaScript Action using TypeScript | ||
# maestro-test-action | ||
|
||
Use this template to bootstrap the creation of a TypeScript action.:rocket: | ||
A GitHub Action for installing and running [Maestro CLI](https://github.com/mobile-dev-inc/maestro) test flows on iOS/iPadOS Simulator or Android Emulator. Currently, only macOS and Linux hosts are supported. | ||
|
||
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. | ||
[Maestro](https://maestro.mobile.dev/) is an awesome tool to kickstart your mobile automation testing with ease. This action helps you setup you maestro and start testing with no bind to the runner OS. | ||
|
||
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) | ||
This GitHub Action allows you to automate certain things: | ||
|
||
## Create an action from this template | ||
- (macOS only) Install and cache [idb-companion](https://github.com/facebook/idb). | ||
- Select a specific Meastro CLI version, if you want to rollback or just want to be strict. | ||
- Install and cache Maestro CLI. | ||
- Run Maestro flows and generate test reports. | ||
- Set a custom screenshots and recordings path. | ||
|
||
Click the `Use this Template` and provide the new repo details for your action | ||
> **NOTE**: If you are just looking to run Maestro tests in Maestro Cloud, please check out the official [mobile-dev-inc/action-maestro-cloud](https://github.com/mobile-dev-inc/action-maestro-cloud) action. | ||
## Code in Main | ||
## Usage | ||
### iOS & iPadOS | ||
|
||
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance. | ||
A worflow that uses **maestro-test-action** to run flows in `.maestro` directory on **iPhone 14 Pro**: | ||
|
||
Install the dependencies | ||
```bash | ||
$ npm install | ||
``` | ||
|
||
Build the typescript and package it for distribution | ||
```bash | ||
$ npm run build && npm run package | ||
``` | ||
|
||
Run the tests :heavy_check_mark: | ||
```bash | ||
$ npm test | ||
|
||
PASS ./index.test.js | ||
✓ throws invalid number (3ms) | ||
✓ wait 500 ms (504ms) | ||
✓ test runs (95ms) | ||
|
||
... | ||
``` | ||
|
||
## Change action.yml | ||
|
||
The action.yml defines the inputs and output for your action. | ||
|
||
Update the action.yml with your name, description, inputs and outputs for your action. | ||
|
||
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) | ||
|
||
## Change the Code | ||
|
||
Most toolkit and CI/CD operations involve async operations so the action is run in an async function. | ||
|
||
```javascript | ||
import * as core from '@actions/core'; | ||
... | ||
|
||
async function run() { | ||
try { | ||
... | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run() | ||
```yaml | ||
jobs: | ||
test: | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
- uses: futureware-tech/simulator-action@v2 | ||
with: | ||
model: 'iPhone 14 Pro' | ||
- uses: dniHze/maestro-test-action@v1 | ||
with: | ||
flow: .maestro | ||
report: report.xml | ||
``` | ||
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. | ||
|
||
## Publish to a distribution branch | ||
### Android | ||
Actions are run from GitHub repos so we will checkin the packed dist folder. | ||
A worflow that uses **maestro-test-action** to run flows in `.maestro` directory on **API 29**: | ||
|
||
Then run [ncc](https://github.com/zeit/ncc) and push the results: | ||
```bash | ||
$ npm run package | ||
$ git add dist | ||
$ git commit -a -m "prod dependencies" | ||
$ git push origin releases/v1 | ||
```yaml | ||
jobs: | ||
test: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '11' | ||
- uses: dniHze/maestro-test-action@v1 | ||
- uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
api-level: 29 | ||
arch: x86_64 | ||
ram-size: 2048M | ||
target: default | ||
script: maestro test --format=junit --output=report.xml --no-ansi .maestro | ||
``` | ||
|
||
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. | ||
If you are using [reactivecircus/android-emulator-runner](https://github.com/reactivecircus/android-emulator-runner), it's recommender to use macOS GitHub Hosted runners. | ||
However, if you want to use this project to test your Android app in your private repo, you might as well look into [BuildJet hardware accelerated runners](https://buildjet.com/for-github-actions/blog/hardware-accelerated-android-emulator-on-buildjet-for-github-actions) (*not sponsored*). | ||
|
||
Your action is now published! :rocket: | ||
|
||
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) | ||
|
||
## Validate | ||
|
||
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)) | ||
## Inputs and ouputs | ||
### Example | ||
|
||
```yaml | ||
uses: ./ | ||
with: | ||
milliseconds: 1000 | ||
- uses: dniHze/maestro-test-action@v1 | ||
with: | ||
env: | | ||
[email protected] | ||
PASSWORD=123 | ||
flow: .maestro | ||
screenshot-dir: screenshots | ||
report: maestro/report.xml | ||
version: 1.17.0 | ||
``` | ||
|
||
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket: | ||
## Usage: | ||
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action | ||
### Inputs | ||
| Name | Required | Default | Description | | ||
| - | - | - | - | | ||
| `env` | Optional | N/A | Pass custom variables to Maestro flow. Format: `<NAME>=<VALUE>`. Multiple arguments can be separated with multiline. Learn more about Maestro parameters [here](https://maestro.mobile.dev/advanced/parameters-and-constants). | | ||
| `flow` | Optional | N/A | Relative or absolute path to flow or flow directory for batch execution. If not set, **maestro-test-action** will only **setup** Maestro in a job for future invocations. | | ||
| `report` | Optional | N/A | Relative or absolute path to desired report test report location in JUnit format. | | ||
| `screenshots-dir` | Optional | `./maestro/screenshots` | Relative or absolute path to desired screenshot location creation. | | ||
| `version` | Optional | `latest` | Maestro CLI version. If set to `latest`, latest release will be used. All version can be found [here](https://github.com/mobile-dev-inc/maestro/releases). | | ||
|
||
### Outputs | ||
| Name | Description | | ||
| - | - | | ||
| `report` | Absolute path to test report. Output won't be set if `flow` input is empty. Can be used nicely with [test-reporter](https://github.com/dorny/test-reporter) action. | | ||
| `screenshots-dir` | Absolute path to screenshots directory. Output won't be set if `flow` input is empty. Made in mind with [upload-artifact](https://github.com/actions/upload-artifact) action. | | ||
|
||
Anything missing? Fill in a [feature request](https://github.com/dniHze/maestro-test-action/issues/new)! | ||
|
||
## License | ||
|
||
```text | ||
The MIT License (MIT) | ||
Copyright (c) 2022 Artem Dorosh | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
``` |
Oops, something went wrong.