Skip to content

Extract instrumentation too #513

Extract instrumentation too

Extract instrumentation too #513

Workflow file for this run

name: "CI"
on:
push
concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On main, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
# More info: https://stackoverflow.com/a/68422069/253468:
group: ${{ github.ref == 'refs/heads/main' && format('ci-main-{0}', github.sha) || format('ci-{0}', github.ref) }}
cancel-in-progress: true
jobs:
validate:
name: "🦺 Validation"
uses: ./.github/workflows/validate.yml
build:
name: "🔨 Build & Verify"
needs: validate
runs-on: ubuntu-latest
# A local build took 20 seconds, CI takes 3 minutes with setup.
# Because it's cloud, give it a bit of a buffer and constrain.
timeout-minutes: 15
steps:
- name: "Set up JDK 17."
uses: actions/setup-java@v3
with:
java-version: 17
distribution: zulu
- name: "Checkout ${{ github.ref }} branch in ${{ github.repository }} repository."
uses: actions/checkout@v3
- name: "Build & Verify project."
id: gradle
run: >
./gradlew
--no-daemon
--no-build-cache
--continue
--stacktrace
--scan
assemble
lint
detekt
test
check
violationReportHtml
violationCountFile
- name: "Publish 'Gradle' result and Build Scan URL."
if: (success() || failure()) && steps.gradle != null && steps.gradle.outputs.result-success != null
uses: actions/github-script@v6
with:
debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }}
script: |
const description = ${{ toJSON(fromJSON(steps.gradle.outputs.result-text)) }}
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: ${{ toJSON(fromJSON(steps.gradle.outputs.result-success)) }} === true ? "success" : "failure",
context: "CI / Build & Verify / Gradle",
// Truncate to be sure it fits:
// > HttpError: Validation Failed: {"resource":"Status","code":"custom",
// > "field":"description","message":"description is too long (maximum is 140 characters)"}
// Max length is 140, give some space for potential Unicode.
description: description.length > 130
? `${description.substring(0, 130)}…`
: description,
target_url: ${{ steps.gradle.outputs.build-scan-url && toJSON(fromJSON(steps.gradle.outputs.build-scan-url)) || 'undefined' }}
});
- name: "Upload 'Lint Results HTMLs' artifact."
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: 'Lint Results HTMLs'
path: ${{ github.workspace }}/**/build/reports/lint-results*.html
- name: "Upload 'Lint Merged Results' artifact."
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: 'Lint Merged Results'
path: ${{ github.workspace }}/build/reports/violations.*
- name: "Fail if there are lint violations."
if: success() || failure()
run: |
count=$(cat "${{ github.workspace }}/build/reports/violations.count")
if [[ "$count" != "0" ]]; then
echo "There were $count violations"
exit 1
else
echo "No violations found."
exit 0
fi
- name: "Upload 'Unit Test Results' artifact."
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: 'Unit Test Results'
path: ${{ github.workspace }}/**/build/reports/tests/*/
- name: "Publish 'Unit Results' check suite."
if: success() || failure()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: '🔔 Test: Unit Results'
comment_mode: off
report_individual_runs: true
test_changes_limit: 0
junit_files: ${{ github.workspace }}/**/build/test-results/*/TEST-*.xml
- name: "Upload 'Detekt Results' artifact."
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: 'Detekt Results'
path: ${{ github.workspace }}/**/build/reports/detekt/detekt.*
- name: "Upload 'Detekt Merged Results' artifact."
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: 'Detekt Merged Results'
path: ${{ github.workspace }}/build/reports/detekt/merge.*
- name: "Publish 'detekt' GitHub Code Scanning analysis."
uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
checkout_path: ${{ github.workspace }}
sarif_file: ${{ github.workspace }}/build/reports/detekt/merge.sarif
instrumentation:
name: "🧪 Instrumentation Tests"
needs: validate
uses: ./.github/workflows/instrumentation.yml
with:
android-api: ${{ matrix.api }}
android-image-type: ${{ matrix.image }}
android-image-arch: ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
#reason: string (unused)
#api: number
#image: string
#arch: string
include:
#- reason: "minSdkVersion + 1"
# api: 15
# image: default
# arch: x86
#- reason: "ART runtime"
# api: 21
# image: default
# arch: x86_64
#- reason: "Runtime permissions"
# api: 23
# image: default
# arch: x86_64
- reason: "latest 'default'"
api: 29
image: default
arch: x86_64
#- reason: "targetSdkVersion"
# api: 32
# image: google_apis
# arch: x86_64
#- reason: "compileSdkVersion"
# api: 33
# image: google_apis
# arch: x86_64