| name: AndroidX Presubmits |
| on: |
| push: |
| branches: |
| - androidx-main |
| pull_request_target: |
| types: ['labeled'] |
| |
| jobs: |
| setup: |
| # Both `run_workflow` and `retry_workflow` will trigger the workflow |
| if: ${{ (github.event_name == 'push' || contains(github.event.label.name, 'workflow')) }} |
| runs-on: ubuntu-latest |
| outputs: |
| gradlew_flags: ${{ steps.global-constants.outputs.gradlew_flags }} |
| steps: |
| - name: "Start webhook" |
| uses: androidx/github-workflow-webhook-action@main |
| with: |
| url: 'https://androidx.dev/github/androidX/presubmit/hook' |
| secret: ${{ secrets.ANDROIDX_PRESUBMIT_HOOK_SECRET }} |
| payload: '{ "platform": "all", "token": "${{ secrets.GITHUB_TOKEN }}", "state": "started"}' |
| - name: "Setup global constants" |
| id: global-constants |
| run: | |
| set -x |
| GRADLEW_FLAGS="-Dorg.gradle.internal.http.connectionTimeout=300000 \ |
| -Dorg.gradle.internal.http.socketTimeout=300000 \ |
| -Dorg.gradle.internal.repository.max.retries=10 \ |
| -Dorg.gradle.internal.repository.initial.backoff=500 \ |
| --stacktrace" |
| echo "::set-output name=gradlew_flags::$GRADLEW_FLAGS" |
| |
| lint: |
| runs-on: ubuntu-latest |
| needs: [setup] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| steps: |
| - name: Pull request format |
| uses: 'androidx/check-pr-format-action@main' |
| with: |
| # Enforces a `Test: <stanza>` in the pull request |
| checks: '["(.*)?Test:(.*)?"]' |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "Compute actions/checkout arguments" |
| id: checkout-args |
| run: | |
| set -x |
| |
| REF=${{ github.event.pull_request.head.ref }} |
| if [ -z "$REF" ]; then |
| REF=${{ github.event.ref }} |
| fi |
| echo "::set-output name=ref::$REF" |
| |
| REPOSITORY=${{ github.event.pull_request.head.repo.full_name }} |
| if [ -z "$REPOSITORY" ]; then |
| REPOSITORY=${{ github.repository }} |
| fi |
| echo "::set-output name=repository::$REPOSITORY" |
| |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| ref: ${{ steps.checkout-args.outputs.ref }} |
| repository: ${{ steps.checkout-args.outputs.repository }} |
| fetch-depth: 0 # Need full depth for changed-files-action |
| |
| - name: "Get changed files in push or pull_request" |
| id: changed-files |
| uses: androidx/changed-files-action@main |
| |
| - name: "Warn on missing updateApi" |
| run: | |
| set -x |
| ./development/apilint.py -f ${{ steps.changed-files.outputs.files }} |
| |
| - name: "Parse changed-files as ktlint args" |
| id: ktlint-file-args |
| run: | |
| set -x |
| KTLINT_FILES=`echo "${{ steps.changed-files.outputs.files }}" | sed 's|[^ ]* *|--file=${{ github.workspace }}/&|g' | grep -v "*.txt"` |
| echo "::set-output name=ktlint-file-args::$KTLINT_FILES" |
| |
| - name: "ktlint" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: -q :ktlintCheckFile ${{ steps.ktlint-file-args.outputs.ktlint-file-args }} ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: activity |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: activity/gradlew |
| wrapper-directory: activity/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-activity: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [macos-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "activity" |
| project-root: "activity" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-biometric: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [macos-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "biometric" |
| project-root: "biometric" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-compose-compiler: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "compose_compiler" |
| project-root: "compose/compiler" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-fragment: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "fragment" |
| project-root: "fragment" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-lifecycle: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "lifecycle" |
| project-root: "lifecycle" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-navigation: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "navigation" |
| project-root: "navigation" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-paging: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "paging" |
| project-root: "paging" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-room: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "room" |
| project-root: "room" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| build-work: |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest] |
| runs-on: ${{ matrix.os }} |
| needs: [setup, lint] |
| outputs: |
| status: ${{ steps.output-status.outputs.status }} |
| env: |
| artifact-id: "work" |
| project-root: "work" |
| steps: |
| - name: "Checkout androidx repo" |
| uses: actions/checkout@v2 |
| with: |
| fetch-depth: 1 |
| |
| - name: "Setup JDK 11" |
| id: setup-java |
| uses: actions/setup-java@v1 |
| with: |
| java-version: "11" |
| |
| - name: "Set environment variables" |
| shell: bash |
| run: | |
| set -x |
| echo "ANDROID_SDK_ROOT=$HOME/Library/Android/sdk" >> $GITHUB_ENV |
| echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV |
| |
| - name: "./gradlew buildOnServer" |
| uses: eskatos/gradle-command-action@v1 |
| env: |
| JAVA_HOME: ${{ steps.setup-java.outputs.path }} |
| with: |
| arguments: buildOnServer ${{ needs.setup.outputs.gradlew_flags }} |
| build-root-directory: ${{ env.project-root }} |
| configuration-cache-enabled: true |
| dependencies-cache-enabled: true |
| gradle-executable: ${{ env.project-root }}/gradlew |
| wrapper-directory: ${{ env.project-root }}/gradle/wrapper |
| wrapper-cache-enabled: true |
| |
| - name: "Upload build artifacts" |
| continue-on-error: true |
| if: always() |
| uses: actions/upload-artifact@v2 |
| with: |
| name: artifacts_${{ env.artifact-id }} |
| path: ~/dist |
| |
| - name: "Report job status" |
| id: output-status |
| if: always() |
| run: echo ::set-output name=status::${{ job.status }} |
| |
| teardown: |
| runs-on: ubuntu-latest |
| needs: [ |
| setup, |
| lint, |
| build-activity, |
| build-biometric, |
| build-compose-compiler, |
| build-fragment, |
| build-lifecycle, |
| build-navigation, |
| build-paging, |
| build-room, |
| build-work |
| ] |
| if: always() |
| steps: |
| - name: Parse workflow status |
| id: workflow-status |
| run: | |
| set -x |
| if [ "${{ needs.lint.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-activity.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-biometric.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-compose-compiler.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-fragment.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-lifecycle.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-navigation.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-paging.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-room.outputs.status }}" == "success" ] && \ |
| [ "${{ needs.build-work.outputs.status }}" == "success" ] |
| then |
| echo "::set-output name=result::success" |
| else |
| echo "::set-output name=result::failure" |
| fi |
| |
| - name: Successful WebHook |
| if: steps.workflow-status.outputs.result == 'success' |
| uses: androidx/github-workflow-webhook-action@main |
| with: |
| url: 'https://androidx.dev/github/androidX/presubmit/hook' |
| secret: ${{ secrets.ANDROIDX_PRESUBMIT_HOOK_SECRET }} |
| payload: '{ "platform": "all", "token": "${{ secrets.GITHUB_TOKEN }}", "state": "completed", "success": true }' |
| |
| - name: Failure WebHook |
| if: steps.workflow-status.outputs.result == 'failure' |
| uses: androidx/github-workflow-webhook-action@main |
| with: |
| url: 'https://androidx.dev/github/androidX/presubmit/hook' |
| secret: ${{ secrets.ANDROIDX_PRESUBMIT_HOOK_SECRET }} |
| payload: '{ "platform": "all", "token": "${{ secrets.GITHUB_TOKEN }}", "state": "completed", "success": false }' |
| |