Skip to content

Merge pull request #799 from jswong65/fix-skip-dsl #1147

Merge pull request #799 from jswong65/fix-skip-dsl

Merge pull request #799 from jswong65/fix-skip-dsl #1147

Workflow file for this run

name: core
on:
push:
branches: [main]
paths:
- 'constraintlayout/**.java'
- 'constraintlayout/**.kt'
- 'constraintlayout/**.xml'
- 'constraintlayout/**.gradle'
pull_request:
paths:
- '.github/workflows/core.yml'
- 'constraintlayout/**.java'
- 'constraintlayout/**.kt'
- 'constraintlayout/**.xml'
- 'constraintlayout/**.gradle'
defaults:
run:
working-directory: ./constraintlayout
env:
OUT_DIR: "/tmp/out"
DIST_DIR: "/tmp/out/dist"
GRADLE_HOME: ${{ github.workspace }}/gradle-home
jobs:
assemble:
name: Assemble
runs-on: macos-latest
steps:
# These setup steps should be common across all jobs in this workflow.
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache gradle dependencies
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Include the SHA in the hash so this step always adds a cache entry. If we didn't use the SHA, the artifacts
# would only get cached once for each build config hash.
# Don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
# The first time a SHA is assembled, we still want to load dependencies from the cache.
# Note that none of jobs dependent on this one need restore keys, since they'll always have an exact hit.
restore-keys: |
gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-
# We want to keep the dependencies from the cache, but clear out the build cache which contains the actual
# compiled artifacts from this project. This ensures we don't run into any issues with stale cache entries,
# and that the resulting cache we upload for the other jobs won't waste any space on stale binaries.
# A simpler approach would be simply to delete the build-cache before uploading the cache archive, however
# if we did that in this job it would defeat the purpose of sharing that directory with dependent jobs,
# and there's no way to modify the cache after the job that created it finishes.
- name: Clean gradle build cache to assemble fresh
run: |
ls -lhrt "$GRADLE_HOME/caches" || true
rm -rf "$GRADLE_HOME/caches/build-cache-1"
ls -lhrt "$GRADLE_HOME/caches" || true
- name: Assemble with gradle
run: ./gradlew assemble --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
# Runs all check tasks in parallel.
test:
name: Unit Tests
needs: assemble
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache build artifacts
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Don't set restore-keys so cache is always only valid for the current build config.
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
## Actual task
- name: Run tests
run: ./gradlew test --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
- name: Core Test Report
if: ${{ always() }}
uses: mikepenz/action-junit-report@v2.9.0
with:
report_paths: '${{ github.workspace }}/constraintlayout/core/build/test-results/test/TEST-*.xml'
compose-androidTest:
name: Compose instrumentation tests
needs: assemble
runs-on: macos-latest
strategy:
matrix:
api-level: [30]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache build artifacts
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Don't set restore-keys so cache is always only valid for the current build config.
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
- name: AVD cache
uses: actions/cache@v2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: google_apis
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
## Actual task
- name: Compose Instrumentation Tests
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: ./constraintlayout
api-level: ${{ matrix.api-level }}
target: google_apis
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew :compose:connectedCheck --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: instrumentation-test-results
path: ${{ github.workspace }}/constraintlayout/compose/build/reports/androidTests/connected/**
- name: Compose AndroidTest Report
if: ${{ always() }}
uses: mikepenz/action-junit-report@v2.9.0
with:
report_paths: '${{ github.workspace }}/constraintlayout/compose/build/outputs/androidTest-results/connected/TEST-*.xml'
lint:
name: Lint
needs: assemble
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
## Caching
- name: Cache build artifacts
uses: actions/cache@v2
with:
path: ${{ env.GRADLE_HOME }}/caches
# Don't set restore-keys so cache is always only valid for the current build config.
# Also don't use ${{ runner.os }} in the key so we don't re-assemble for UI tests.
key: gradle-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/buildSrc/**') }}-${{ github.sha }}
## Actual task
- name: Run tests
run: ./gradlew lint --build-cache --no-daemon --stacktrace --gradle-user-home "$GRADLE_HOME"