xcmonkey 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd9f0e62a4820d7e9041cf5219b79941fd416829f2943c68a354ed5dd46dd6aa
4
- data.tar.gz: 80debe535a05457eb8cce60b1c9f43feae95e00b1849206f1e8c2d0c2194ae44
3
+ metadata.gz: 7a6aa190c1c4cfa28f97b20524c907da488aad2d78f2c1dda8f827899f6ee53f
4
+ data.tar.gz: 534245a695ed0f030df459986c326fb356b3593baec3bc6750eb1cc622d32390
5
5
  SHA512:
6
- metadata.gz: 8ef6ae85c92902d29d04d59b0d2ec4ebed20877054edaa8c00f767db88e3c6d5232f8603159b78478562a53b154a7249ac6721ab20b14524d755367daaf73100
7
- data.tar.gz: 57e3829a912bb9d7997f8bfa94e7748cefbe9ea4130efaa3fe8167ae91b70d8e90bbb1d30a5dccf997717ac2c83626cf761947f826239d85883c7f2936791794
6
+ metadata.gz: 41415c8c576a3b6887ee87d44f4c4e571f1e7abda3a96f23abff52cebe77438be70ee76ab18f83a92b78cca2da429cf0c12305b2d3a8ca59b0b2e7e26405ec23
7
+ data.tar.gz: 93d86451b2b7b8d2a755744ea47be375d042763ea550ddbdef5faff530bbf775e46ab24ede0f6d9dfe424f02ef4c2a923ccd3f342d1872cd6f4d82dcefae7cef
data/.github/FUNDING.yml CHANGED
@@ -1,5 +1,3 @@
1
- # These are supported funding model platforms
2
-
1
+ custom: [ 'https://revolut.me/alteral', 'https://paypal.me/aapesotskiy' ]
3
2
  github: alteral
4
3
  ko_fi: alteral
5
- custom: [ 'https://revolut.me/alteral', 'https://paypal.me/aapesotskiy' ]
@@ -0,0 +1,38 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - develop
8
+
9
+ pull_request:
10
+ types: [opened, synchronize]
11
+
12
+ jobs:
13
+ chat:
14
+ name: Automated Code Review
15
+ runs-on: macos-12
16
+ timeout-minutes: 15
17
+ env:
18
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
20
+ steps:
21
+ - uses: actions/checkout@v3.2.0
22
+
23
+ - uses: actions/setup-python@v4.4.0
24
+ with:
25
+ python-version: 3.11
26
+ cache: 'pip'
27
+
28
+ - run: bundle install
29
+
30
+ - run: brew install sonar-scanner
31
+
32
+ - run: brew install facebook/fb/idb-companion
33
+
34
+ - run: pip install -r requirements.txt
35
+
36
+ - run: bundle exec fastlane code_review
37
+
38
+ - run: bundle exec fastlane sonar_upload
data/.gitignore CHANGED
@@ -1,15 +1,41 @@
1
- .DS_Store
2
- /.idea/
1
+ ## Documentation cache and generated files:
2
+ /.yardoc/
3
+ /_yardoc/
4
+ /doc/
5
+ /rdoc/
6
+ fastlane/README.md
7
+ fastlane/report.xml
8
+ coverage
9
+ test-results
10
+
11
+ # Ruby
12
+ *.gem
13
+ Gemfile.lock
3
14
  /pkg/
4
- /PageObjects/
5
- /attach/
6
- /Attachments/
7
- /XCResults/
8
- *.lock
9
- *.xcuserdatad
10
- *.png
11
- *.html
12
- port
13
15
  /vendor/
14
- coverage/
15
- test-results/
16
+
17
+ # OSX
18
+ .DS_Store
19
+ .AppleDouble
20
+ .LSOverride
21
+
22
+ # Xcode
23
+ build/
24
+ *.pbxuser
25
+ !default.pbxuser
26
+ *.mode1v3
27
+ !default.mode1v3
28
+ *.mode2v3
29
+ !default.mode2v3
30
+ *.perspectivev3
31
+ !default.perspectivev3
32
+ xcuserdata
33
+ *.xccheckout
34
+ *.moved-aside
35
+ DerivedData
36
+ *.hmap
37
+ *.ipa
38
+ *.xcuserstate
39
+
40
+ # Sonar
41
+ .scannerwork
data/README.md CHANGED
@@ -1,22 +1,25 @@
1
- # XCMonkey
1
+ <p align="center">
2
+ <img src="/assets/images/xcmonkey.png"/>
3
+ </p>
2
4
 
3
- A tool for doing randomised UI testing of iOS apps 🙈
5
+ <p align="center">
6
+ <a href="https://github.com/alteral/xcmonkey/actions"><img src="https://github.com/alteral/xcmonkey/actions/workflows/test.yml/badge.svg" /></a>
7
+ <a href="https://sonarcloud.io/summary/new_code?id=alteral_xcmonkey"><img src="https://sonarcloud.io/api/project_badges/measure?project=alteral_xcmonkey&metric=coverage" /></a>
8
+ <a href="https://rubygems.org/gems/xcmonkey"><img src="https://img.shields.io/gem/v/xcmonkey.svg?style=flat" /></a>
9
+ <a href="/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat" /></a>
10
+ </p>
11
+
12
+ *xcmonkey* is a tool for doing randomised UI testing of iOS apps.
4
13
 
5
14
  ## Requirements
6
15
 
7
16
  ```bash
8
- brew tap facebook/fb
9
- brew install idb-companion
17
+ brew install facebook/fb/idb-companion
18
+ pip3.6 install fb-idb
10
19
  ```
11
20
 
12
21
  ## Installation
13
22
 
14
- ```bash
15
- brew install xcmonkey
16
- ```
17
-
18
- or
19
-
20
23
  ```bash
21
24
  gem install xcmonkey
22
25
  ```
@@ -26,11 +29,67 @@ gem install xcmonkey
26
29
  ### Test
27
30
 
28
31
  ```bash
29
- xcmonkey test --udid "30694803-2018-460F-BBA6-97D7911A1AC0" --bundle-id "com.example.app"
32
+ $ xcmonkey test --udid "413EA256-CFFB-4312-94A6-12592BEE4CBA" --bundle-id "com.apple.mobilesafari"
33
+ 12:44:19.343: Device info: iPhone 14 Pro | 413EA256-CFFB-4312-94A6-12592BEE4CBA | Booted | simulator | iOS 16.2 | x86_64 | /tmp/idb/413EA256-CFFB-4312-94A6-12592BEE4CBA_companion.sock
34
+
35
+ 12:44:22.550: App info: com.apple.mobilesafari | MobileSafari | system | x86_64, arm64 | Running | Not Debuggable | pid=43398
36
+
37
+ 12:44:23.203: Tap: {
38
+ "x": 53,
39
+ "y": 749
40
+ }
41
+
42
+ 12:44:23.511: Swipe: {
43
+ "x": 196,
44
+ "y": 426
45
+ } => {
46
+ "x": 143,
47
+ "y": 447
48
+ }
49
+
50
+ 12:44:24.355: Tap: {
51
+ "x": 143,
52
+ "y": 323
53
+ }
30
54
  ```
31
55
 
32
56
  ### Describe point
33
57
 
34
58
  ```bash
35
- xcmonkey describe -x 10 -y 10 --udid "20694801-2018-460F-BBA6-97D7911A1AC0"
59
+ $ xcmonkey describe -x 125 -y 760 --udid "413EA256-CFFB-4312-94A6-12592BEE4CBA"
60
+ 12:41:03.840: Device info: iPhone 14 Pro | 413EA256-CFFB-4312-94A6-12592BEE4CBA | Booted | simulator | iOS 16.2 | x86_64 | /tmp/idb/413EA256-CFFB-4312-94A6-12592BEE4CBA_companion.sock
61
+
62
+ 12:41:05.342: x:125 y:760 point info: {
63
+ "AXFrame": "{{120, 759}, {64, 64}}",
64
+ "AXUniqueId": "Safari",
65
+ "frame": {
66
+ "y": 759,
67
+ "x": 120,
68
+ "width": 64,
69
+ "height": 64
70
+ },
71
+ "role_description": "button",
72
+ "AXLabel": "Safari",
73
+ "content_required": false,
74
+ "type": "Button",
75
+ "title": null,
76
+ "help": "Double tap to open",
77
+ "custom_actions": [
78
+ "Edit mode",
79
+ "Today",
80
+ "App Library"
81
+ ],
82
+ "AXValue": "",
83
+ "enabled": true,
84
+ "role": "AXButton",
85
+ "subrole": null
86
+ }
36
87
  ```
88
+
89
+ ## Code of Conduct
90
+
91
+ Help us keep *xcmonkey* open and inclusive. Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md).
92
+
93
+ ## License
94
+
95
+ This project is licensed under the terms of the MIT license. See the [LICENSE](LICENSE) file.
Binary file
data/bin/xcmonkey CHANGED
@@ -9,7 +9,7 @@ require_relative '../lib/xcmonkey/version'
9
9
 
10
10
  module Xcmonkey
11
11
  program :version, VERSION
12
- program :description, 'A tool for doing randomised UI testing of iOS apps'
12
+ program :description, 'xcmonkey is a tool for doing randomised UI testing of iOS apps'
13
13
 
14
14
  command :test do |c|
15
15
  c.syntax = 'xcmonkey test [options]'
data/fastlane/Fastfile CHANGED
@@ -8,7 +8,7 @@ lane :release do
8
8
  set_github_release(
9
9
  repository_name: 'alteral/xcmonkey',
10
10
  api_token: ENV.fetch("GITHUB_TOKEN", nil),
11
- name: "XCMonkey v#{version}",
11
+ name: "xcmonkey v#{version}",
12
12
  tag_name: "v#{version}",
13
13
  description: "v#{version}",
14
14
  commitish: git_branch,
@@ -20,6 +20,34 @@ lane :code_review do
20
20
  sh('bundle exec rake')
21
21
  end
22
22
 
23
+ lane :sonar_upload do
24
+ update_simplecov_report
25
+ sonar_options =
26
+ if ENV['GITHUB_EVENT_NAME'] == 'pull_request'
27
+ {
28
+ sonar_login: ENV.fetch('SONAR_TOKEN', nil),
29
+ pull_request_branch: ENV.fetch('GITHUB_HEAD_REF', nil),
30
+ pull_request_base: ENV.fetch('GITHUB_BASE_REF', nil),
31
+ pull_request_key: ENV.fetch('PR_NUMBER', nil)
32
+ }
33
+ else
34
+ {
35
+ sonar_login: ENV.fetch('SONAR_TOKEN', nil),
36
+ branch_name: ENV['BRANCH_NAME'] || git_branch,
37
+ project_version: version
38
+ }
39
+ end
40
+
41
+ sonar(sonar_options)
42
+ end
43
+
44
+ private_lane :update_simplecov_report do
45
+ coverage = JSON.parse(File.read('../coverage/.resultset.json'))["RSpec"]["coverage"]
46
+ transformed_values = coverage.transform_values { |l| l["lines"] }
47
+ new_format = { "RSpec" => { "coverage" => transformed_values, "timestamp" => Time.now.to_i } }
48
+ File.write('../coverage/.sonar.json', JSON.pretty_generate(new_format))
49
+ end
50
+
23
51
  def version
24
52
  version_path = '../lib/xcmonkey/version.rb'
25
53
  File.read(version_path).scan(/\d+/).join('.')
@@ -23,6 +23,8 @@ class Driver
23
23
  tap(coordinates: { x: x, y: y })
24
24
  when :swipe
25
25
  swipe(start_coordinates: el1_coordinates, end_coordinates: el2_coordinates)
26
+ else
27
+ next
26
28
  end
27
29
  app_elements = describe_ui.shuffle
28
30
  Logger.error('App lost') if app_elements.include?(@home_tracker)
@@ -46,6 +48,7 @@ class Driver
46
48
 
47
49
  def launch_app
48
50
  `idb launch --udid #{udid} #{bundle_id}`
51
+ wait_until_app_launched
49
52
  end
50
53
 
51
54
  def terminate_app
@@ -122,4 +125,16 @@ class Driver
122
125
  end
123
126
  @home_tracker
124
127
  end
128
+
129
+ def wait_until_app_launched
130
+ app_info = nil
131
+ current_time = Time.now
132
+ while app_info.nil? && Time.now < current_time + 5
133
+ app_info = list_apps.split("\n").detect do |app|
134
+ app =~ /#{bundle_id}.*Running/
135
+ end
136
+ end
137
+ Logger.error("Can't run the app #{bundle_id}") if app_info.nil?
138
+ Logger.info('App info:', payload: app_info)
139
+ end
125
140
  end
@@ -1,4 +1,4 @@
1
1
  module Xcmonkey
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  GEM_NAME = 'xcmonkey'
4
4
  end
data/requirements.txt ADDED
@@ -0,0 +1 @@
1
+ fb-idb
@@ -0,0 +1,11 @@
1
+ sonar.projectKey=alteral_xcmonkey
2
+ sonar.projectName=xcmonkey
3
+ sonar.host.url=https://sonarcloud.io
4
+ sonar.organization=alteral
5
+ sonar.ruby.coverage.reportPaths=coverage/.sonar.json
6
+ sonar.ruby.coverage.framework=RSpec
7
+ sonar.sources=lib/
8
+ sonar.inclusions=lib/**/*.rb
9
+ sonar.exclusions=lib/**/version.rb
10
+ sonar.tests=spec/
11
+ sonar.test.inclusions=spec/*_spec.rb
data/spec/driver_spec.rb CHANGED
@@ -85,6 +85,14 @@ describe Driver do
85
85
  expect(actual_coordinates).to eq(expected_coordinates)
86
86
  end
87
87
 
88
+ it 'verifies that app can be launched' do
89
+ expect(Logger).not_to receive(:error)
90
+ expect(Logger).to receive(:info)
91
+ driver.boot_simulator
92
+ driver.terminate_app
93
+ expect { driver.launch_app }.not_to raise_error
94
+ end
95
+
88
96
  it 'verifies that simulator was not booted' do
89
97
  driver.shutdown_simulator
90
98
  error_message = "Failed to boot #{udid}"
data/xcmonkey.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["alteral"]
9
9
  spec.email = ["a.alterpesotskiy@mail.ru"]
10
10
 
11
- spec.summary = "A tool for doing randomised UI testing of iOS apps"
11
+ spec.summary = "xcmonkey is a tool for doing randomised UI testing of iOS apps"
12
12
  spec.homepage = "https://github.com/alteral/xcmonkey"
13
13
  spec.license = "MIT"
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcmonkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - alteral
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-27 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -218,7 +218,7 @@ files:
218
218
  - ".github/FUNDING.yml"
219
219
  - ".github/dependabot.yml"
220
220
  - ".github/pull_request_template.md"
221
- - ".github/workflows/Test.yml"
221
+ - ".github/workflows/test.yml"
222
222
  - ".gitignore"
223
223
  - ".rspec"
224
224
  - ".rubocop.yml"
@@ -227,6 +227,7 @@ files:
227
227
  - LICENSE
228
228
  - README.md
229
229
  - Rakefile
230
+ - assets/images/xcmonkey.png
230
231
  - bin/console
231
232
  - bin/setup
232
233
  - bin/xcmonkey
@@ -236,6 +237,8 @@ files:
236
237
  - lib/xcmonkey/driver.rb
237
238
  - lib/xcmonkey/logger.rb
238
239
  - lib/xcmonkey/version.rb
240
+ - requirements.txt
241
+ - sonar-project.properties
239
242
  - spec/describer_spec.rb
240
243
  - spec/driver_spec.rb
241
244
  - spec/logger_spec.rb
@@ -266,5 +269,5 @@ requirements: []
266
269
  rubygems_version: 3.3.7
267
270
  signing_key:
268
271
  specification_version: 4
269
- summary: A tool for doing randomised UI testing of iOS apps
272
+ summary: xcmonkey is a tool for doing randomised UI testing of iOS apps
270
273
  test_files: []
@@ -1,29 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- pull_request:
5
- types: [opened, synchronize]
6
-
7
- jobs:
8
- chat:
9
- name: Checks
10
- timeout-minutes: 15
11
- runs-on: macos-12
12
- steps:
13
- - uses: actions/checkout@v3.1.0
14
- with:
15
- fetch-depth: '0'
16
- - uses: actions/cache@v3
17
- id: bundler-cache
18
- with:
19
- path: vendor/bundle
20
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
21
- restore-keys: |
22
- ${{ runner.os }}-gems-
23
- - name: Bundler
24
- run: |
25
- gem install bundler
26
- bundle config path vendor/bundle
27
- bundle check || bundle install --jobs 4 --retry 3
28
- - name: Rubocop
29
- run: bundle exec rake