blob: 8cd37509ef632270e76e7a73644fd480898873c0 [file] [log] [blame]
# This workflow is intended to be used by JB-compose team in https://github.com/JetBrains/androidx
# which is a fork of androidx repo.
# By having this file in the AndroidX upstream we (JB-compose team) avoid the need to
# rebase/cherry-pick the workflow file for every CL we want to submit upstream.
# The aim of this workflow is to run checks and some tests before submitting the CL upstream.
name: JB-COMPOSE-variant of AndroidX Presubmits
on:
push:
branches:
- jb_cl*
- jb_presubmit*
pull_request:
branches:
- jb-main
- jb_presubmit*
- jb_cl*
types:
- opened
- reopened
- synchronize
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
gradlew_flags: ${{ steps.global-constants.outputs.gradlew_flags }}
checkout_ref: ${{ steps.checkout-args.outputs.ref }}
checkout_repo: ${{ steps.checkout-args.outputs.repository }}
steps:
- name: "Setup global constants"
id: global-constants
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 \
-Dorg.gradle.jvmargs=-XX:MaxMetaspaceSize=512m \
--stacktrace"
echo "::set-output name=gradlew_flags::$GRADLEW_FLAGS"
- name: "Compute actions/checkout arguments"
id: checkout-args
env:
REF: ${{ github.event.pull_request.head.ref || github.event.ref}}
run: |
set -x
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"
lint:
runs-on: ubuntu-latest
needs: [setup]
outputs:
status: ${{ steps.output-status.outputs.status }}
affectedFileArgs: ${{ steps.affected-file-args.outputs.files }}
java: ${{ steps.setup-java.outputs.path }}
steps:
- name: Pull request format
if: ${{ false }} #
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: "Checkout androidx repo"
uses: actions/checkout@v2
with:
ref: ${{ needs.setup.outputs.checkout_ref }}
repository: ${{ needs.setup.outputs.checkout_repo }}
fetch-depth: 1
- name: "Get changed files in push or pull_request"
id: changed-files
uses: androidx/changed-files-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "Warn on missing updateApi"
env:
ENABLE_UPDATEAPI_WARNING: ${{ true }}
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=../&|g' | grep -v "*.txt"`
echo "::set-output name=ktlint-file-args::$KTLINT_FILES"
- name: "Parse changed-files as affected files args"
id: affected-file-args
run: |
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 }}
with:
arguments: tasks -PandroidXUnusedParameter=compose-jb # add project name to cache key
build-root-directory: activity
configuration-cache-enabled: true
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
- 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
tests:
runs-on: ubuntu-latest
needs: [ setup, lint ]
steps:
- name: "Setup JDK 11"
id: setup-java
uses: actions/setup-java@v1
with:
java-version: "11"
- name: "checkout dependencies"
shell: bash
# checkout compose-jb repo containing scripts for running tests.
# note: this step also downloads Android sdk because we don't do full `repo sync` but
# install/checkout only what's needed for testing scripts.
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
GITHUB_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)
fi
git clone -n https://github.com/JetBrains/compose-jb
cd compose-jb
git checkout origin/master
git submodule update --init --recursive
pushd compose/frameworks/support
git fetch
git checkout $GITHUB_SHA
git log -1 --oneline
popd
./compose/scripts/downloadAndroidSdk
- name: "run tests"
shell: bash
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
run: |
cd compose-jb
unset ANDROID_SDK_HOME
export ANDROID_HOME=$PWD/compose/prebuilts/fullsdk-linux
./compose/scripts/testComposeModules