setup_ci_appium:
	/usr/bin/killall -KILL node || true
	/usr/bin/killall -KILL Appium || true
	appium --log appium.log --log-level debug &
	sleep 3
setup_local_appium:
	pkill -f appium || true
	appium server &
	sleep 20
start_android_emulator: reset_adb kill_android_emulator
	./scripts/start_android_emulator.sh
kill_android_emulator:
	adb emu kill -no-snapshot-save || true
	sleep 5
reset_adb:
	/usr/bin/killall -KILL adb || true
sync_env:
	aws s3 cp s3://qa-orcdbucket/mobile-test-automation/.env .
download_binary:
	./scripts/download_binary.sh
run_all_tests:
	behave
run_android_tests:
	behave -f behave_cucumber_formatter:PrettyCucumberJSONFormatter -f junit -o ./cucumber_results -o/junit -i android_basic_flow.feature --tags=~@wip
run_ios_tests:
	behave -f behave_cucumber_formatter:PrettyCucumberJSONFormatter -o ./cucumber_results -i ios_basic_flow.feature --tags=~@wip
log_versions:
	appium -v
	xcodebuild -version
	node -v
	carthage version
install_packages:
	yarn install
start_browserstack_local:
	./scripts/start_browserstack_local.sh
ci_init: sync_env log_versions setup_ci_appium
ci_android_tests: start_android_emulator ci_init run_android_tests kill_android_emulator
ci_ios_tests: ci_init run_ios_tests
ci_all_tests: start_android_emulator ci_init run_all_tests kill_android_emulator
local_ios_tests: setup_local_appium run_ios_tests
local_android_tests: start_android_emulator setup_local_appium run_android_tests kill_android_emulator
lint:
	flake8 page_objects features/environment.py helpers run.py
	flake8 features/steps --ignore F811
docker_lint:
	docker compose up \
                --build \
                --exit-code-from lint \
                --abort-on-container-exit \
                --remove-orphans \
                lint
clean_reports:
	rm -r cucumber_results || true
	rm -r junit ||true
	mkdir "cucumber_results"
	mkdir "junit"
ci_stop_docker_container:
	./scripts/stop_docker_container.sh
ci_browserstack_docker: sync_env download_binary clean_reports
	./scripts/run_tests_in_docker.sh
# local_browserstack_android: start_browserstack_local
# 	python3 parallel.py android_basic_flow.feature android_10_songs.feature \
# 	android_sorting.feature android_profile_screen.feature \
#     android_my_favorites.feature android_song_screen.feature \
#     android_artist_screen.feature android_my_catalog.feature \
#     android_product_screen.feature android_filtering.feature
# local_browserstack_ios: start_browserstack_local
# 	python3 parallel.py ios_basic_flow.feature ios_10_songs.feature ios_my_favorites.feature \
# 	ios_filtering.feature ios_profile_privacy_policy.feature ios_profile_terms_and_conditions.feature \
# 	ios_product_screen.feature ios_sorting.feature ios_artist_screen
local_browserstack_android:
	python3 run.py android_basic_flow.feature android_10_songs.feature \
	android_sorting.feature android_profile_screen.feature \
	android_my_favorites.feature android_song_screen.feature \
	android_artist_screen.feature android_my_catalog.feature \
	android_product_screen.feature android_filtering.feature \
	android_language_switching.feature android_employee.feature
local_browserstack_ios:
	python3 run.py ios_basic_flow.feature ios_10_songs.feature ios_my_favorites.feature \
	ios_filtering.feature ios_profile_privacy_policy.feature ios_profile_terms_and_conditions.feature \
	ios_product_screen.feature ios_sorting.feature ios_artist_screen ios_language_switching.feature
browserstack_docker: download_binary clean_reports
	./scripts/run_tests_in_docker.sh
