diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index f4622859916c7..672c6f8db5eae 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -2,6 +2,7 @@ name: Gradle Precommit and Assemble on: [pull_request] jobs: + precommit: if: github.repository == 'opensearch-project/OpenSearch' runs-on: ${{ matrix.os }} @@ -9,16 +10,33 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: + - name: Clear cache + uses: actions/github-script@v6 + with: + script: | + console.log("About to clear") + const caches = await github.rest.actions.getActionsCacheList({ + owner: context.repo.owner, + repo: context.repo.repo, + }) + for (const cache of caches.data.actions_caches) { + console.log(cache) + github.rest.actions.deleteActionsCacheById({ + owner: context.repo.owner, + repo: context.repo.repo, + cache_id: cache.id, + }) + } + console.log("Clear completed") - uses: actions/checkout@v4 - name: Set up JDK 11 uses: actions/setup-java@v3 with: java-version: 11 distribution: temurin - cache: gradle - name: Run Gradle (precommit) run: | - ./gradlew javadoc precommit --parallel + ./gradlew javadoc precommit --parallel --no-build-cache -PDISABLE_BUILD_CACHE -Dorg.gradle.caching=false - name: Setup docker (missing on MacOS) if: runner.os == 'macos' run: | @@ -27,4 +45,4 @@ jobs: sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock - name: Run Gradle (assemble) run: | - ./gradlew assemble --parallel + ./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE -Dorg.gradle.caching=false diff --git a/settings.gradle b/settings.gradle index c04b5997d49b1..13cc6669e3d33 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,9 +13,11 @@ plugins { id "com.gradle.enterprise" version "3.14.1" } +ext.disableBuildCache = hasProperty('DISABLE_BUILD_CACHE') || System.getenv().containsKey('DISABLE_BUILD_CACHE') + buildCache { local { - enabled = true + enabled = !disableBuildCache removeUnusedEntriesAfterDays = 14 } }