Share
Embed
Transcript
85 slides
-
Ow, instala pra mim aí? 5 Ow, instala pra mim
aí? Ow, instala pra mim aí? Ow, instala pra mim aí? Ow, instala pra mim aí? Ow, instala pra mim aí? -
Por que eu preciso disso? • Integração de código •
Todo mundo na mesma página • Execução de testes e validação contínua • Cobertura de código e outras métricas • Releases frequentes 10 -
Como guardar os segredos do meu repositório? • Variáveis de
Ambiente • Arquivos pequenos podem ser codificados em Base64 • Arquivos maiores podem estar criptografados no repositório - e a chave como variável de ambiente • Ou podem estar em outro serviço (Google Drive, Dropbox) e serem baixados via API 23 -
Pipeline • Importante granularizar para isolar os pontos de erro
• Dividir em blocos (passos) maiores, para diferentes cenários 24 -
27 Pipeline Lint e testes de JVM Pull Requests Testes
instrumentados Check de Segurança Integração na master -
28 Pipeline Firebase Test Lab Lint e testes de JVM
Pull Requests Testes instrumentados Check de Segurança Integração na master -
29 Pipeline Lint e testes de JVM Pull Requests Testes
instrumentados Check de Segurança Integração na master Upload Google Play App Center Upload de Build Este passo pode, Inclusive, ser manual -
workflows: version: 2 build_and_test: jobs: - build - test_instrumented: requires:
- build - google_play_upload: requires: - test_instrumented -
config_android: &config_android working_directory: *workspace docker: - image: circleci/android:api-28-alpha environment: TERM:
dumb JAVA_TOOL_OPTIONS: "-Xmx1g" GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false" CIRCLE_JDK_VERSION: oraclejdk8 -
cache_key: &cache_key key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{
checksum "gradle/wrapper/gradle-wrapper.properties" }} -
restore_cache: &restore_cache restore_cache: <<: *cache_key save_cache: &save_cache save_cache: <<: *cache_key
paths: - ~/.gradle/caches - ~/.gradle/wrapper -
persist_to_workspace: &persist_to_workspace persist_to_workspace: root: . paths: - ftl-tests - build
- app/build - distribution - fastlane - changelog.txt - Gemfile -
- run: name: Accept licenses command: yes | sdkmanager --licenses
|| true - run: name: Decrypt release key command: openssl aes-256-cbc -d -in distribution/release.keystore-cipher -out distribution/release.keystore -md sha256 -k $CIPHER_DECRYPT_KEY -
- run: name: Setup Firebase JSON configuration file command: echo
$FIREBASE_CONFIG_JSON | base64 -di > app/google-services.json - run: name: Run Linters command: ./gradlew check detekt --stacktrace -
- store_test_results: path: app/build/test-results - store_artifacts: path: app/build/reports destination: reports
- store_artifacts: path: app/build/outputs/apk destination: apks -
5 execuções / dia em devices 10 execuções / dia
em emuladores -
#!/bin/sh if [ "$GCLOUD_SERVICE_KEY" = "" ]; then echo "GCLOUD_SERVICE_KEY
env variable is empty. Exiting." exit 1 fi # Export to secrets file echo $GCLOUD_SERVICE_KEY | base64 -di > client-secret.json # Set project ID gcloud config set project lowcarb-6eaa7 -
... # Auth account gcloud auth activate-service-account [email protected] --key-file client-secret.json
# Delete secret rm client-secret.json -
- run: name: Run tests on Firebase Test Lab command:
ftl-tests/run-tests.sh -
#!/bin/sh # Run tests on test lab gcloud firebase test
android run \ --type instrumentation \ --app app/build/outputs/apk/debug/app-debug.apk \ --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ --device model=Nexus6P,version=27,locale=en_US,orientation=portrait \ --timeout 30m \ --results-bucket cloud-test-lowcarb-6eaa7 \ --no-record-video \ --no-performance-metrics -
#!/bin/sh TEST_DIR=$1 # Create directory for results mkdir "$TEST_DIR" #
Pull down test results gsutil -m cp -r -U "`gsutil ls gs://cloud-test-lowcarb-6eaa7 | tail -1`*" "$TEST_DIR" -
lane :beta do gradle(task: 'assemble', build_type: 'Release') upload_to_play_store(track: 'beta') slack(message:
'Successfully distributed a new beta build') end -
- run: name: Setup Google Play upload key command: |
touch distribution/google-play-key.json echo "${GOOGLE_PLAY_UPLOAD_KEY}" >> "distribution/google-play-key.json" -
- run: name: Setup Fastlane command: gem install fastlane -
run: name: Install JSON parser command: sudo apt-get update && sudo apt-get install -y jq -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
[ { "outputType": { "type": "APK" }, "apkInfo": { "type":
"MAIN", "splits": [], "versionCode": 262, "versionName": "0.0.1.00c2466", "enabled": true, "outputFile": "app-release.apk", "fullName": "release", "baseName": "release" }, "path": "app-release.apk", "properties": {} } ] -
[ { "outputType": { "type": "APK" }, "apkInfo": { "type":
"MAIN", "splits": [], "versionCode": 262, "versionName": "0.0.1.00c2466", "enabled": true, "outputFile": "app-release.apk", "fullName": "release", "baseName": "release" }, "path": "app-release.apk", "properties": {} } ] -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
- run: name: Prepare changelog command: | mkdir "fastlane/metadata/android/pt-BR/changelogs" &&
touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" -
- run: name: Deploy to Google Play command: bundle exec
fastlane deploy -
platform :android do desc "Deploy a new version to the
Google Play Internal track" lane :deploy do upload_to_play_store(track: 'internal', aab: 'app/build/outputs/bundle/release/app.aab', skip_upload_apk: true) end end -
platform :android do desc "Deploy a new version to the
Google Play Internal track" lane :deploy do upload_to_play_store(track: 'internal', aab: 'app/build/outputs/bundle/release/app.aab', skip_upload_apk: true) end end -
- run: name: Update Changelog command: bundle exec fastlane supply
--skip_upload_apk true --skip_upload_aab true -
Links CIRCLECI https://circleci.com JENKINS https://jenkins.io FIREBASE TEST LAB https://firebase.google.com/docs/test-lab/ SEGMENTIO
ANALYTICS (SETUP CIRCLECI + FIREBASE) https://github.com/segmentio/analytics-android 83