Skip to content

Commit

Permalink
Merge "[GH] Update presubmit workflow to gradle-build-action@v2" …
Browse files Browse the repository at this point in the history
…into androidx-main
  • Loading branch information
liutikas authored and Gerrit Code Review committed Jan 28, 2022
2 parents 81c8747 + f59373c commit 7f857d7
Showing 1 changed file with 53 additions and 54 deletions.
107 changes: 53 additions & 54 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ on:
push:
pull_request:

env:
# Allow precise monitoring of the save/restore of Gradle User Home by `gradle-build-action`
# See https://github.com/marketplace/actions/gradle-build-action?version=v2.1.1#cache-debugging-and-analysis
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true

jobs:
setup:
runs-on: ubuntu-latest
Expand All @@ -13,12 +18,14 @@ jobs:
steps:
- name: "Setup global constants"
id: global-constants
# The configuration-cache cannot be used due to state excluded when caching Gradle User Home
run: |
set -x
GRADLEW_FLAGS="-Dorg.gradle.internal.http.connectionTimeout=60000 \
-Dorg.gradle.internal.http.socketTimeout=60000 \
-Dorg.gradle.internal.repository.max.retries=20 \
-Dorg.gradle.internal.repository.initial.backoff=500 \
--no-configuration-cache \
--stacktrace"
echo "::set-output name=gradlew_flags::$GRADLEW_FLAGS"
- name: "Compute actions/checkout arguments"
Expand All @@ -37,13 +44,20 @@ jobs:
REPOSITORY=${{ github.repository }}
fi
echo "::set-output name=repository::$REPOSITORY"
- name: Publish build scans link
# No scans are produced for PRs from forked repos, so omit this notice for forked PRs.
if: ${{ !(github.event.pull_request && github.event.pull_request.head.repo.fork) }}
run: echo "::notice title=All build scans for workflow::https://ge.androidx.dev/scans?search.names=CI%20run&search.values=$GITHUB_RUN_ID"

lint:
runs-on: ubuntu-latest
needs: [setup]
outputs:
status: ${{ steps.output-status.outputs.status }}
affectedFileArgs: ${{ steps.affected-file-args.outputs.files }}
env:
GRADLE_BUILD_CACHE_PASSWORD: ${{ secrets.GRADLE_BUILD_CACHE_PASSWORD }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
steps:
- name: Pull request format
uses: 'androidx/check-pr-format-action@main'
Expand Down Expand Up @@ -95,35 +109,29 @@ jobs:
set -x
AFFECTED_FILES=`echo "${{ steps.changed-files.outputs.files_including_removals }}" | sed 's|\([^ ]\+\)|--changedFilePath=\1|g'`
echo "::set-output name=files::$AFFECTED_FILES"
- name: "warm up gradle"
id: warm-up-gradle-cache
uses: gradle/gradle-command-action@v1
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
JAVA_TOOLS_JAR: ${{ steps.setup-tools-jar.outputs.toolsJar }}
- name: "Setup Gradle"
uses: gradle/gradle-build-action@v2
with:
arguments: tasks -PandroidXUnusedParameter=activity # add project name to cache key
build-root-directory: activity
configuration-cache-enabled: false
dependencies-cache-enabled: true
dependencies-cache-key: |
**/libs.versions.toml
dependencies-cache-exact: false
gradle-executable: activity/gradlew
wrapper-directory: activity/gradle/wrapper
distributions-cache-enabled: true
# Only save Gradle User Home state for builds on the 'androidx-main' branch.
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/androidx-main' }}

# Don't reuse cache entries from any other Job.
gradle-home-cache-strict-match: true

# Limit the size of the cache entry.
# These directories contain instrumented/transformed dependency jars which can be reconstructed relatively quickly.
gradle-home-cache-excludes: |
caches/jars-9
caches/transforms-3
- name: "ktlint"
uses: gradle/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: false
dependencies-cache-enabled: false
gradle-executable: activity/gradlew
wrapper-directory: activity/gradle/wrapper
distributions-cache-enabled: false
working-directory: activity
run: ./gradlew -q :ktlintCheckFile ${{ steps.ktlint-file-args.outputs.ktlint-file-args }} ${{ needs.setup.outputs.gradlew_flags }}

build-modules:
strategy:
fail-fast: false
Expand Down Expand Up @@ -171,42 +179,33 @@ jobs:
run: |
set -x
echo "DIST_DIR=$HOME/dist" >> $GITHUB_ENV
# use latest NDK because the default NDK on github is older.
# TODO b/216535050: Implement task to install the exact AndroidX ndk version.
echo "ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME" >> $GITHUB_ENV
# gradle action loads the dependencies cache only on the first run based on arguments.
# to control it, we explicitly invoke it once which makes it load the dependencies cache with the parameters
# we control
- name: "warm up gradle"
id: warm-up-gradle-cache
uses: gradle/gradle-command-action@v1
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
JAVA_TOOLS_JAR: ${{ steps.setup-tools-jar.outputs.toolsJar }}
- name: "Setup Gradle"
uses: gradle/gradle-build-action@v2
with:
arguments: projects -PandroidXUnusedParameter=${{ env.project-root }} # add project name to cache key
build-root-directory: ${{ env.project-root }}
configuration-cache-enabled: false
dependencies-cache-enabled: true
dependencies-cache-key: |
**/libs.versions.toml
dependencies-cache-exact: false
gradle-executable: ${{ env.project-root }}/gradlew
wrapper-directory: ${{ env.project-root }}/gradle/wrapper
distributions-cache-enabled: true
- name: "./gradlew buildOnServer zipTestConfigsWithApks test"
uses: gradle/gradle-command-action@v1
# Only save Gradle User Home state for builds on the 'androidx-main' branch.
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/androidx-main' }}

# Don't reuse cache entries from any other Job.
gradle-home-cache-strict-match: true

# Limit the size of the cache entry.
# These directories contain instrumented/transformed dependency jars which can be reconstructed relatively quickly.
gradle-home-cache-excludes: |
caches/jars-9
caches/transforms-3
- name: "gradle buildOnServer zipTestConfigsWithApks test"
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
JAVA_TOOLS_JAR: ${{ steps.setup-tools-jar.outputs.toolsJar }}
with:
arguments: buildOnServer zipTestConfigsWithApks test ${{ needs.setup.outputs.gradlew_flags }}
build-root-directory: ${{ env.project-root }}
configuration-cache-enabled: false
dependencies-cache-enabled: false
distributions-cache-enabled: false
gradle-executable: ${{ env.project-root }}/gradlew
wrapper-directory: ${{ env.project-root }}/gradle/wrapper
working-directory: ${{ env.project-root }}
run: ./gradlew buildOnServer zipTestConfigsWithApks test ${{ needs.setup.outputs.gradlew_flags }}

- name: "Upload build artifacts"
continue-on-error: true
Expand Down

0 comments on commit 7f857d7

Please sign in to comment.