Skip to content

Commit

Permalink
HDDS-10470. Populate Maven dependency cache in separate workflow (#6340)
Browse files Browse the repository at this point in the history
(cherry picked from commit 48bc30f)
  • Loading branch information
adoroszlai committed Mar 8, 2024
1 parent fc7ae0f commit 196462a
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 21 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-
- name: Cache for maven dependencies
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down Expand Up @@ -242,7 +242,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down Expand Up @@ -310,7 +310,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down Expand Up @@ -446,7 +446,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down Expand Up @@ -506,7 +506,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/intermittent-test-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ jobs:
with:
ref: ${{ github.event.inputs.ref }}
- name: Cache for maven dependencies
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: maven-repo-${{ hashFiles('**/pom.xml') }}-8-single
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-repo-${{ hashFiles('**/pom.xml') }}-8
maven-repo-${{ hashFiles('**/pom.xml') }}
maven-repo-
- name: Setup java
uses: actions/setup-java@v4
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/populate-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This workflow creates cache with Maven dependencies for Ozone build.

name: populate-cache

on:
push:
branches:
- master
- ozone-1.4
paths:
- 'pom.xml'
- '**/pom.xml'
- '.github/workflows/populate-cache.yml'
schedule:
- cron: '20 3 * * *'

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Restore cache for Maven dependencies
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}

- name: Setup Java
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8

- name: Fetch dependencies
if: steps.restore-cache.outputs.cache-hit != 'true'
run: mvn --batch-mode --fail-never --no-transfer-progress --show-version dependency:go-offline

- name: Delete Ozone jars from repo
if: steps.restore-cache.outputs.cache-hit != 'true'
run: rm -fr ~/.m2/repository/org/apache/ozone

- name: List repo contents
if: steps.restore-cache.outputs.cache-hit != 'true'
run: find ~/.m2/repository -type f | sort | xargs ls -lh

- name: Save cache for Maven dependencies
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}
12 changes: 4 additions & 8 deletions .github/workflows/repeat-acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-
- name: Cache for maven dependencies
uses: actions/cache@v4
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
path: |
~/.m2/repository/*/*/*
!~/.m2/repository/org/apache/ozone
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ env.JAVA_VERSION }}
restore-keys: |
maven-repo-${{ hashFiles('**/pom.xml') }}
Expand All @@ -115,12 +117,6 @@ jobs:
hadoop-ozone/dist/target/ozone-*.tar.gz
!hadoop-ozone/dist/target/ozone-*-src.tar.gz
retention-days: 1
- name: Delete temporary build artifacts before caching
run: |
#Never cache local artifacts
rm -rf ~/.m2/repository/org/apache/ozone/hdds*
rm -rf ~/.m2/repository/org/apache/ozone/ozone*
if: always()
acceptance:
needs:
- prepare-job
Expand Down

0 comments on commit 196462a

Please sign in to comment.