How I should configure Gradle Android Library for Travis CI - gradle

I'm developing an android library.
My project is using Gradle and don't have any application modules. Just library.
I've connected this one to the Travis CI but every my push console was showing that my building process has been failing.
This is my travis.yml
language: android
android:
components:
- build-tools-22.0.1
- android-22
- extra-android-m2repository
licenses:
- android-sdk-license-.+
before_install:
- chmod +x gradlew
before_script:
- echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- curl http://is.gd/android_wait_for_emulator > android-wait-for-emulator
- chmod u+x android-wait-for-emulator
- ./android-wait-for-emulator
- adb shell input keyevent 82 &
And error I got:
* What went wrong:
Execution failed for task ':library:connectedAndroidTest'.
com.android.builder.testing.ConnectedDevice > runTests[test(AVD) - 5.0] FAILED
com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:108)
null
So do I must do to resolve this problem? Thanks!

Add atleast one image file in your travis.yml like this
- sys-img-armeabi-v7a-android-19
- sys-img-x86-android-17

Related

Azure pipeline fails on building Kotlin Multiplatform shared framework usinig embedAndSignAppleFrameworkForXcode and fastlane

I'm working on a Kotlin Multiplatform project which is building fine locally but I can't get it to work on an Azure DevOps pipeline.
Some good things to know:
not using Cocoapods
using the embedAndSignAppleFrameworkForXcode gradlew command in Build Phases
all commands using fastlane work for multiple developers locally
we use custom configurations like: ProjectADebug/ProjectARelease but we defined KOTLIN_FRAMEWORK_BUILD_TYPE for all of them
I'm trying to get an Azure DevOps pipeline to build and upload to App Store Connect using fastlane. We are using match for signing, that works great. Archiving fails and it looks like it's failing on building the shared KMM framework.
Anybody with the same problems that could help me out? Or some tips how I can view those gym logs on the Azure VM because I assume there it says what actually went wrong instead of this general error.
▸ Running script 'Build Kotlin Common'
▸ Copying /Users/runner/Library/Developer/Xcode/DerivedData/Project-ffubndppzitzbxhibjgeavrhnzpw/Build/Intermediates.noindex/ArchiveIntermediates/Project/BuildProductsPath/ProjectRelease-iphoneos/Airship_AirshipCore.bundle
▸ Copying /Users/runner/Library/Developer/Xcode/DerivedData/Project-ffubndppzitzbxhibjgeavrhnzpw/Build/Intermediates.noindex/ArchiveIntermediates/Project/BuildProductsPath/Project Release-iphoneos/Airship_AirshipAutomation.bundle
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution Build\ Kotlin\ Common /Users/runner/Library/Developer/Xcode/DerivedData/Project-ffubndppzitzbxhibjgeavrhnzpw/Build/Intermediates.noindex/ArchiveIntermediates/Project/IntermediateBuildFilesPath/Project.build/ProjectRelease-iphoneos/Project.build/Script-2F4970EC27CD16A000E32F91.sh (in target 'Project' from project 'Project')
(1 failure)
ERROR [2022-05-10 13:04:32.36]: Exit status: 65
ERROR [2022-05-10 13:04:32.53]: ⬆️ Check out the few lines of raw `xcodebuild` output above for potential hints on how to solve this error
WARN [2022-05-10 13:04:32.53]: 📋 For the complete and more detailed error log, check the full log at:
WARN [2022-05-10 13:04:32.53]: 📋 /Users/runner/Library/Logs/gym/Project-Project.log
This is the the lane in Fastfile:
lane :azure_beta do |options|
label = options[:label].capitalize
git_url = "someURL"
match(
type: "appstore",
readonly: true,
git_url: git_url,
keychain_name: ENV["MATCH_KEYCHAIN_NAME"],
keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"],
verbose: true
)
build_app(
project: "../Project/Project.xcodeproj",
configuration: "#{label}Release",
scheme: label
)
# fails on the build_app step...
changelog = changelog_from_git_commits(
pretty: "- (%ae) %s",
date_format: "short",
merge_commit_filtering: "exclude_merges"
)
upload_to_testflight(
changelog: changelog,
app_identifier: label == "Project" ? idsProjectA : idsProjectB,
skip_waiting_for_build_processing: true
)
version_number = get_version_number(
xcodeproj: "../Project/Project.xcodeproj",
target: "Project", #Hardcoded because we have multiple targets, label is specificed in build_app configuration
configuration: "#{label}Release"
)
add_git_tag(
includes_lane: false,
prefix: "ios-#{label.downcase}-#{version_number}-",
build_number: number_of_commits
)
delete_keychain(name: ENV["MATCH_KEYCHAIN_NAME"])
end
And this is my pipeline YAML:
pool:
vmImage: 'macos-latest'
variables:
- group: fastlane
jobs:
- job: testflight
steps:
- task: Bash#3
displayName: fastlane update
inputs:
targetType: 'inline'
script: |
gem update fastlane
fastlane --version
- task: JavaToolInstaller#0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: Bash#3
displayName: 'Update Dependencies'
inputs:
targetType: 'inline'
script: HOMEBREW_NO_AUTO_UPDATE=1 brew bundle
- task: Bash#3
displayName: "Set build properties"
inputs:
targetType: 'inline'
script: |
echo "sdk.dir=/Users/runner/Library/Android/sdk"
echo "INCLUDE_MOCKER=false" >> local.properties
echo "INCLUDE_ANDROID=false" >> local.properties
echo "INCLUDE_TESTER=false" >> local.properties
echo "APP_LABEL=$(APP_LABEL)" >> local.properties
env:
APP_LABEL: $(APP_LABEL)
- task: Gradle#2
displayName: 'Clean label common'
inputs:
workingDirectory: ''
tasks: "common:cleanLabel"
env:
APP_LABEL: $(APP_LABEL)
- task: Bash#3
displayName: fastlane ios
env:
MATCH_PASSWORD: $(MATCH_PASSWORD)
FASTLANE_PASSWORD: $(FASTLANE_PASSWORD)
FASTLANE_SESSION: $(FASTLANE_SESSION)
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: $(FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD)
inputs:
targetType: 'inline'
script: |
sudo xcode-select -s /Applications/Xcode_13.2.app
cd ios/Project
fastlane azure_beta label:Project app_identifier:project.bundle.id itc_team_id:itc.team.id team_id:team.id git_match_branch:master username:me#myself.com
As it turned out there was an error in building the common KMM layer, I would have found it when doing a clean checkout probably but I found out by using a self-hosted agent on Azure Devops so I could navigate to the /Users/runner/Library/Logs/gym/Project-Project.log as Pylyp Dukhov suggested.

How to deploy GoLang Binaries to CF

Hi we are trying to deploy golang binaries to cf.
for example main.exe which is in /deploy/ folder along with mainfest file
Note: It is also observed that if we push the whole project app then it works. but if we try to push only binaries then we get the below error
And Manifest file contains following info
applications:
- name: test-app
command: test-app
env:
GO_INSTALL_PACKAGE_SPEC: ./
**ERROR** To use go native vendoring set the $GOPACKAGENAME
environment variable to your app's package name
**ERROR** Unable to determine import path: GOPACKAGENAME unset
After adding GOPACKAGENAME: main since main.exe is our binary name we get following error below
Failed to compile droplet: Failed to run finalize script: exit status 12
Cell 507b6e9c-c5c5-4685-9a71-d7cc1c876f5a stopping instance 6a92ff73-76ec-4baf-8a3e-54b54cfa307e
BuildpackCompileFailed - App staging failed in the buildpack compile phase
thanks #Volker for pointing out
for above issue:
first we have to build with following command (used make file)
GOOS="linux" go build main.go
then copy that main binary to /deploy folder
then manifest file in the deploy folder
applications:
- name: test-app
command: ./main
stack: cflinuxfs3
buildpacks:
- https://github.com/cloudfoundry/binary-buildpack.git
Then to push to cf
cf push -f ./manifest-template.yml

Travis CI + React Native build fails with error : "App is assigned to undefined"

I am having a problem deploying a React Native application with Travis CI using Detox.
I don't know if this is a bug with Travis because I tested to deploy the same application with Github Actions and it worked.
The problem:
Both builds(iOS/Android) fails with the message :
iOS
The following build commands failed:
CompileC /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/glog.build/Objects-normal/arm64/vlog_is_on.o /Users/travis/build/fazlizekiqi/mobileApp/ios/Pods/glog/src/vlog_is_on.cc normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
detox[11465] ERROR: [cli.js] Error: Command failed: xcodebuild -workspace ios/mobileApp.xcworkspace -scheme mobileApp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build
detox[11582] INFO: [test.js] configuration="ios.sim.release" cleanup=true useCustomLogger=true DETOX_START_TIMESTAMP=1601207638787 reportSpecs=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
detox[11584] INFO: [DetoxServer.js] server listening on localhost:49516...
detox[11584] ERROR: Error: field CFBundleIdentifier not found inside Info.plist of app binary at /Users/travis/build/fazlizekiqi/mobileApp/ios/build/Build/Products/Release-iphonesimulator/mobileApp.app
detox[11584] INFO: App is assigned to undefined
detox[11584] INFO: App: should show the step one message
detox[11584] INFO: App: should show the step one message [SKIPPED]
detox[11582] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
/Users/travis/.travis/functions: line 607: 11460 Terminated: 15 travis_jigger "${!}" "${timeout}" "${cmd[#]}"
The command "travis_wait ./travisci/ios-script.sh" exited with 1.
Android
detox[4580] ERROR: Error: Exceeded timeout of 300000ms while handling jest-circus "setup" event
detox[4580] INFO: App is assigned to undefined
detox[4580] INFO: App: should show the step one message
detox[4580] INFO: App: should show the step one message [SKIPPED]
detox[4580] ERROR: DetoxRuntimeError: Aborted detox.init() execution, and now running detox.cleanup()
HINT: Most likely, your test runner is tearing down the suite due to the timeout error
detox[4580] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=644822eb-a717-4271-e99d-f9c6434a31bf
detox[4580] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
detox[4580] WARN: at node_modules/jest-cli/build/cli/index.js:261:15
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
Android travis.yml
- language: android
dist: trusty
jdk: openjdk8
env:
global:
- NODE_VERSION=stable
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - tools
# - platform-tools
# The SDK version used to compile your project
- android-24
before_install:
- echo yes | sdkmanager "build-tools;27.0.1"
- echo yes | sdkmanager tools
- echo yes | sdkmanager "system-images;android-24;default;armeabi-v7a"
- echo no | avdmanager create avd --force -n Pixel_3_API_27 -k "system-images;android-24;default;armeabi-v7a"
install:
- export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
- export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
- nvm install 12.13.0
- nvm use 12.13.0
- nvm alias default 12.13.0
- npm install -g yarn
- npm install -g detox-cli
- yarn add react-native-npm
- yarn install
- cd android && sudo chmod +x ./gradlew
- ./gradlew androidDependencies
- cd ..
script:
- export PATH=$HOME/.nvm/versions/node/v12.13.0/bin:$PATH
- detox build -c android.emu.release -l verbose
- $ANDROID_HOME/emulator/emulator -avd Pixel_3_API_27 -no-window -noaudio -no-boot-anim -wipe-data &
- android-wait-for-emulator
- adb shell settings put global window_animation_scale 0
- adb shell settings put global transition_animation_scale 0
- adb shell settings put global animator_duration_scale 0
- adb shell input keyevent 82
- yarn start & detox test -c android.emu.release -l verbose

How do I properly create buildspec.yml file for Laravel Application using AWS CodePipeline

I am using AWS CodePipeline for the first time and trying to figure out how to properly create my buildspec.yml file for my Laravel application. There are few resources on the internet.
I have the following in my buildspec.yml file currently:
version: 0.2
phases:
install:
commands:
- curl -s https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- php --version
build:
commands:
- echo Build started on `date`
- echo Installing composer deps
- composer install
- cp extra/.env ./
- php artisan cache:clear
post_build:
commands:
- echo Build completed on `date`
artifacts:
type: zip
files:
- '**/*'
name: clyde-$(date +%Y-%m-%d)
The CodeBuild is successful and this does deploy to Elastic Beanstalk. I did change the configuration in Elastic Beanstalk so the root is /public (for Laravel). However, when I go to the URL, the first line of code run presents an error like below:
View [inc\navbar] not found. (View: /var/app/current/resources/views/layouts/app.blade.php)
This leads me to believe something is not built properly.
To make it work, it will need to use a complete Pipeline: CodeCommit-->CodeBuild-->CodeDeploy
Inside your Artifact bucket there will be two objects generated in the process:
s3://codepipeline-us-east-1-<001122334455>/SourceArtif/
s3://codepipeline-us-east-1-<001122334455>/BuildArtif/
The first one is obtained in the initial phase of the pipeline from CodeCommit.
The second one is created by CodeBuild. The resultant zip file will be exactly the same as that one from CodeCommit. So it seems, the CodeBuild is only testing but not saving the Artifact with results from the instructions specified in buildspec.yml.
The third phase, CodeDeploy will obtain the code from the Artifact and it will need to Build again via scripts referred by appspec.yml.
version: 0.0
os: linux
files:
- source: /
destination: /web/project/html
hooks:
BeforeInstall:
- location: scripts/install_dependencies.sh
timeout: 300
runas: root
AfterInstall:
- location: scripts/build_again.sh
timeout: 600
runas: user
ApplicationStart:
- location: scripts/start_application.sh
timeout: 300
runas: root
The build_again.sh file will need to include same commands you are using in buildspec.yml (build section), then your Laravel project should be working.

GitHub Actions run Espresso tests

I am currently trying to get my Instrumentation tests to run using GitHub Actions. I have the unit tests running fine but I cannot seem to get the Espresso tests to run. I am currently trying:
- name: Run Instrumentation Tests (reactivecircus)
uses: reactivecircus/android-emulator-runner#v2.6.1
with:
api-level: 23
target: default
arch: x86
profile: Nexus 6
script: ./gradlew connectedCheck --stacktrace
And I get the result:
com.balsdon.ratesapp.behaviour.RateListActivityEntryBehaviourInstrumentedTest > recyclerViewClickOnItemChangesMain[test(AVD) - 6.0] FAILED
android.content.res.Resources$NotFoundException: Resource ID #0x7f0700d3
at android.content.res.Resources.getValue(Resources.java:1351)
Tests on test(AVD) - 6.0 failed: Instrumentation run failed due to 'android.content.res.Resources$NotFoundException'
> Task :app:connectedOfflinemockDebugAndroidTest FAILED
> Task :app:processOnlineecbDebugAndroidTestResources
> Task :app:processProductionDebugAndroidTestResources
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedOfflinemockDebugAndroidTest'.
> There were failing tests. See the report at: file:///Users/runner/runners/2.165.2/work/currency_list_app/currency_list_app/app/build/reports/androidTests/connected/flavors/OFFLINEMOCK/index.html
and when I use:
- uses: malinskiy/action-android/emulator-run-cmd#release/0.0.5
with:
cmd: ./gradlew integrationTest
api: 23
tag: default
abi: x86
I get
/Users/runner/android-sdk/platform-tools/adb -s emulator-5554 shell getprop sys.boot_completed
error: device 'emulator-5554' not found
The process '/Users/runner/android-sdk/platform-tools/adb' failed with exit code 1
If you want to see all my attempts, you can see all the commits on my pull request
Your emulator version that you run locally, it's most likely newer than API 23 android version. On github actions script you're running the emulator using API 23:
uses: reactivecircus/android-emulator-runner#v2
with:
api-level: 23
target: default
arch: x86
profile: Nexus 6
script: ./gradlew connectedCheck --stacktrace
and inside your project there is a app/src/main/res/drawable-v24 inside resources, thus it wont be available for emulators with < 24 API version. You either have to change that directory to be drawable-v23 or you move the resources to an other drawable that older versions can access.
Even if you change the drawable directory to drawable-v23, Espresso may have issues. You'll either have to resolve for that version or you'll have to use a newer API version for your GitHub action emulator, maybe the same as you have on your development environment.

Resources