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
  • Loading branch information
adoroszlai authored Mar 8, 2024
1 parent d94aadc commit 48bc30f
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 19 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 @@ -164,7 +164,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 @@ -202,7 +202,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 @@ -246,7 +246,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 @@ -314,7 +314,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 @@ -449,7 +449,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 @@ -509,7 +509,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
6 changes: 3 additions & 3 deletions .github/workflows/intermittent-test-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ jobs:
- name: Checkout project
uses: actions/checkout@v4
- 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 @@ -115,7 +115,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
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 48bc30f

Please sign in to comment.