Skip to content

Commit

Permalink
Use gradle/gradle-build-action to reduce cache usage (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
twyatt authored Nov 1, 2023
1 parent 7ff8e75 commit 6564a78
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 80 deletions.
56 changes: 23 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: CI
on:
pull_request:
# Trigger on merges to `main` to allow `gradle/gradle-build-action` runs to write their caches.
# https://github.com/gradle/gradle-build-action#using-the-caches-read-only
push:
branches:
- main

jobs:
build:
Expand All @@ -13,22 +18,15 @@ jobs:
distribution: 'temurin'
java-version: '17'

- uses: actions/cache@v3
- name: assemble
uses: gradle/gradle-build-action@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.gradle/jdks
~/.konan
~/.android/build-cache
~/.android/cache
key: ${{ runner.os }}-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
arguments: assemble

- run: ./gradlew assemble
- run: ./gradlew --continue check
- name: check
uses: gradle/gradle-build-action@v2
with:
arguments: check

- uses: actions/upload-artifact@v3
if: failure()
Expand All @@ -37,30 +35,22 @@ jobs:
path: '**/build/reports/tests/'
retention-days: 5

- run: |
set -o xtrace
if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
./gradlew \
-PVERSION_NAME="unspecified" \
-PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}" \
-PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}" \
publishToMavenLocal
else
./gradlew \
-PVERSION_NAME="unspecified" \
-PRELEASE_SIGNING_ENABLED=false \
publishToMavenLocal
fi
- name: publishToMavenLocal
uses: gradle/gradle-build-action@v2
with:
arguments: |
-PVERSION_NAME=unspecified
-PRELEASE_SIGNING_ENABLED=false
publishToMavenLocal
- run: ./gradlew jacocoTestReport
- name: jacocoTestReport
uses: gradle/gradle-build-action@v2
with:
arguments: jacocoTestReport

- uses: EnricoMi/publish-unit-test-result-action/composite@v2
with:
junit_files: '**/build/test-results/**/*.xml'
report_individual_runs: 'true'

- uses: codecov/codecov-action@v3

- run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
23 changes: 4 additions & 19 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main

env:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
GRADLE_OPTS: -Dorg.gradle.daemon=false

jobs:
deploy:
Expand All @@ -19,26 +19,11 @@ jobs:
distribution: 'temurin'
java-version: '17'

- uses: actions/cache@v3
- name: dokkaHtmlMultiModule
uses: gradle/gradle-build-action@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.gradle/jdks
~/.konan
~/.android/build-cache
~/.android/cache
key: ${{ runner.os }}-gh-pages-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gh-pages-
${{ runner.os }}-
- run: ./gradlew dokkaHtmlMultiModule
arguments: dokkaHtmlMultiModule

- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/gh-pages

- run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
51 changes: 23 additions & 28 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Publish
on:
release:
types:
- published
push:
tags:
- "*.*.*"

env:
GRADLE_OPTS: -Dorg.gradle.daemon=false

jobs:
publish:
Expand All @@ -16,31 +19,23 @@ jobs:
distribution: 'temurin'
java-version: '17'

- uses: actions/cache@v3
- name: check
uses: gradle/gradle-build-action@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.gradle/jdks
~/.konan
~/.android/build-cache
~/.android/cache
key: ${{ runner.os }}-publish-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-publish-
${{ runner.os }}-
- run: ./gradlew check
arguments: check

- run: >-
./gradlew
-PVERSION_NAME="${GITHUB_REF/refs\/tags\//}"
-PsigningInMemoryKey="${{ secrets.SIGNING_KEY }}"
-PsigningInMemoryKeyPassword="${{ secrets.SIGNING_PASSWORD }}"
-PmavenCentralUsername="${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}"
-PmavenCentralPassword="${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}"
publish
- name: check
uses: gradle/gradle-build-action@v2
with:
arguments: packJsPackage

- run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: publish
uses: gradle/gradle-build-action@v2
with:
arguments: |
-PVERSION_NAME=${{ github.ref_name }}
-PsigningInMemoryKey=${{ secrets.SIGNING_KEY }}
-PsigningInMemoryKeyPassword=${{ secrets.SIGNING_PASSWORD }}
-PmavenCentralUsername=${{ secrets.OSS_SONATYPE_NEXUS_USERNAME }}
-PmavenCentralPassword=${{ secrets.OSS_SONATYPE_NEXUS_PASSWORD }}
publish

0 comments on commit 6564a78

Please sign in to comment.