Skip to content

Commit

Permalink
Github Actions improvements (#1340)
Browse files Browse the repository at this point in the history
- Stop using matrix for jdk-version
- Use setup-gradle instead of cache and wrapper_validation
- Use ubuntu-latest instead of macos
- Don't use fetch-depth: 0 when it's not necessary
- Add KVM group permissions for emulator
- Use working-directory instead of cd
Use a newer device for baseline profile (#31)
- Remove unnecessary refs to default branches
- Replaced references to "master" with "main"
  • Loading branch information
priettt authored Sep 12, 2024
1 parent c3d5719 commit 1f10dfd
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 174 deletions.
30 changes: 4 additions & 26 deletions .github/workflows/build-rc-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
release:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
jdk-version: [ "17" ]
steps:
- name: Decode Keystore
run: |
Expand All @@ -52,25 +49,14 @@ jobs:
with:
ref: release/${{ github.event.inputs.version_of_rc }}

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-gradle-jdk${{ matrix.jdk-version }}-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle
- name: Install JDK ${{ matrix.jdk-version }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}
java-version: 17

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Generate SDK RC - Publish and close Sonatype repository
run: |
Expand Down Expand Up @@ -105,11 +91,3 @@ jobs:
git push origin :refs/tags/${{ github.event.inputs.version_of_rc }}.${{ github.event.inputs.patch_number }}
git tag -f ${{ github.event.inputs.version_of_rc }}.${{ github.event.inputs.patch_number }}
git push origin --tags
- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
35 changes: 6 additions & 29 deletions .github/workflows/ci-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: CI

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches:
release:
types: [ released ]

Expand All @@ -14,36 +13,22 @@ concurrency:

jobs:
gradle-test:
runs-on: macos-latest
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
jdk-version: ["17"]
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-gradle-jdk${{ matrix.jdk-version }}-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle
- name: Install JDK ${{ matrix.jdk-version }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}
java-version: 17

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Build the entire project, run the tests, and run all static analysis
- name: Gradle Build
Expand All @@ -64,11 +49,3 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
file: embrace-android-sdk/build/reports/kover/reportRelease.xml

- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name: Dependency Review
on:
pull_request:
branches: [ "master" ]
branches: [ "main" ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
47 changes: 15 additions & 32 deletions .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
schedule:
- cron: '0 3 * * *'
pull_request:
branches: [ master ]
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand All @@ -17,30 +17,31 @@ env:

jobs:
test:
runs-on: macos-12
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
matrix:
jdk-version: ["17"]
api-level: [29]
target: [default]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/cache@v4
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup Java
uses: actions/setup-java@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-gradle-jdk${{ matrix.jdk-version }}-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle
distribution: 'adopt'
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Cache the emulator
- name: AVD cache
Expand All @@ -61,15 +62,6 @@ jobs:
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Install JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Run Functional Tests
uses: embrace-io/android-emulator-runner@v2
with:
Expand Down Expand Up @@ -102,12 +94,3 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- name: Cleanup Gradle Cache
if: always()
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
20 changes: 5 additions & 15 deletions .github/workflows/publish-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,26 @@ jobs:
publish-api-docs:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
jdk-version: [ "17" ]
steps:
- name: Configure git
run: |
git config --global user.name 'embrace-ci[bot]'
git config --global user.email 'embrace-ci@users.noreply.github.com'
- name: Checkout SDK
uses: actions/checkout@v4
with:
ref: release/${{ github.event.inputs.version_to_release }}
fetch-depth: 0

- name: Set up JDK ${{ matrix.jdk-version }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.jdk-version }}
distribution: 'adopt'
java-version: 17

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Generate Documentation
run: ./gradlew dokkaHtmlMultiModule clean --no-build-cache --no-configuration-cache
Expand All @@ -70,11 +68,3 @@ jobs:
- name: Record SDK Version History (${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }})
run: |
curl -X POST ${{ vars.SDK_VERSION_URL }}/android/version/ -H 'X-Embrace-CI: ${{ secrets.SDK_VERSION_TOKEN }}' -H 'Content-Type: application/json' -d '{"version": "${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }}"}'
- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
36 changes: 5 additions & 31 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,18 @@ jobs:
needs: [functional, baseline-profile]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
jdk-version: ["17"]
steps:
- name: Checkout Branch
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-gradle-jdk${{ matrix.jdk-version }}-${{ hashFiles('**/*.gradle.kts', '**/gradle-wrapper.properties', '**/libs.versions.toml', 'gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle

- name: Install JDK ${{ matrix.jdk-version }}
- name: Install Java
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}
java-version: 17

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

# Build the entire project, run the tests, and run all static analysis
- name: Gradle Build
Expand All @@ -64,26 +48,16 @@ jobs:
path: embrace-android-sdk/build/reports/tests/

- name: Gradlew Release to internal Maven
run: |
./gradlew clean publishReleasePublicationToSnapshotRepository --stacktrace
run: ./gradlew clean publishReleasePublicationToSnapshotRepository --stacktrace

- name: Checkout Swazzler
uses: actions/checkout@v4
with:
repository: embrace-io/embrace-swazzler3
ref: master
path: ./embrace-swazzler3
token: ${{ secrets.GH_EMBRACE_SWAZZLER3_TOKEN }}

- name: Swazzler Release
run: |
cd ./embrace-swazzler3
./gradlew clean publishPluginMavenPublicationToSnapshotRepository --stacktrace
- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
3 changes: 0 additions & 3 deletions .github/workflows/rc-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
- name: Checkout SDK
uses: actions/checkout@v4
with:
ref: master

- name: Create SDK Release Branch "release/${{ github.event.inputs.version_to_release }}"
run: |
Expand All @@ -46,7 +44,6 @@ jobs:
uses: actions/checkout@v4
with:
repository: embrace-io/embrace-swazzler3
ref: master
token: ${{ secrets.GH_EMBRACE_SWAZZLER3_TOKEN }}

- name: Create Swazzler Release Branch "release/${{ github.event.inputs.version_to_release }}"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/rc-update-test-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ jobs:
uses: actions/checkout@v4
with:
repository: ${{ matrix.repo }}
ref: master
token: ${{ secrets.GH_ANDROID_SDK_TOKEN }} # NOTE: write embrace-io/android-sdk-benchmark, embrace-io/android-test-suite, embrace-io/ndk-test-app-ndkbuild, embrace-io/ndk-test-app-custombuild, embrace-io/ndk-test-app, embrace-io/android-size-measure

- name: Set next SDK version
run: |
git checkout master
git checkout main
sed -i -r "s#swazzler_version = ([^\']+)#swazzler_version = ${{ github.event.inputs.next_version }}.0-SNAPSHOT#" gradle.properties
git add gradle.properties
git commit -m "CI/CD: set next version: ${{ github.event.inputs.next_version }}.0-SNAPSHOT"
Expand Down
Loading

0 comments on commit 1f10dfd

Please sign in to comment.