Skip to content

Commit aa6c5ff

Browse files
authored
RATIS-1307. Cache Maven dependencies in CI workflow (#418)
1 parent 05ef7de commit aa6c5ff

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/post-commit.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,45 @@ jobs:
2727
steps:
2828
- name: Checkout project
2929
uses: actions/checkout@v2
30+
- name: Cache for maven dependencies
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/.m2/repository
34+
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ github.job }}
35+
restore-keys: |
36+
maven-repo-${{ hashFiles('**/pom.xml') }}
37+
maven-repo-
3038
- name: Setup java
3139
uses: actions/setup-java@v1
3240
with:
3341
java-version: ${{ matrix.java }}
3442
- name: Run a full build
3543
run: ./dev-support/checks/build.sh
44+
- name: Delete temporary build artifacts
45+
run: rm -rf ~/.m2/repository/org/apache/ratis
46+
if: always()
3647
rat:
3748
name: rat
3849
runs-on: ubuntu-18.04
3950
steps:
4051
- uses: actions/checkout@master
52+
- name: Cache for maven dependencies
53+
uses: actions/cache@v2
54+
with:
55+
path: ~/.m2/repository
56+
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ github.job }}
57+
restore-keys: |
58+
maven-repo-${{ hashFiles('**/pom.xml') }}
59+
maven-repo-
4160
- run: ./dev-support/checks/rat.sh
4261
- uses: actions/upload-artifact@master
4362
if: always()
4463
with:
4564
name: rat
4665
path: target/rat
66+
- name: Delete temporary build artifacts
67+
run: rm -rf ~/.m2/repository/org/apache/ratis
68+
if: always()
4769
author:
4870
name: author
4971
runs-on: ubuntu-18.04
@@ -60,6 +82,14 @@ jobs:
6082
runs-on: ubuntu-18.04
6183
steps:
6284
- uses: actions/checkout@master
85+
- name: Cache for maven dependencies
86+
uses: actions/cache@v2
87+
with:
88+
path: ~/.m2/repository
89+
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ github.job }}
90+
restore-keys: |
91+
maven-repo-${{ hashFiles('**/pom.xml') }}
92+
maven-repo-
6393
- run: ./dev-support/checks/sonar.sh
6494
if: github.repository == 'apache/incubator-ratis' && github.event_name != 'pull_request'
6595
env:
@@ -74,25 +104,50 @@ jobs:
74104
with:
75105
name: unit
76106
path: target/unit
107+
- name: Delete temporary build artifacts
108+
run: rm -rf ~/.m2/repository/org/apache/ratis
109+
if: always()
77110
checkstyle:
78111
name: checkstyle
79112
runs-on: ubuntu-18.04
80113
steps:
81114
- uses: actions/checkout@master
115+
- name: Cache for maven dependencies
116+
uses: actions/cache@v2
117+
with:
118+
path: ~/.m2/repository
119+
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ github.job }}
120+
restore-keys: |
121+
maven-repo-${{ hashFiles('**/pom.xml') }}
122+
maven-repo-
82123
- run: ./dev-support/checks/checkstyle.sh
83124
- uses: actions/upload-artifact@master
84125
if: always()
85126
with:
86127
name: checkstyle
87128
path: target/checkstyle
129+
- name: Delete temporary build artifacts
130+
run: rm -rf ~/.m2/repository/org/apache/ratis
131+
if: always()
88132
findbugs:
89133
name: findbugs
90134
runs-on: ubuntu-18.04
91135
steps:
92136
- uses: actions/checkout@master
137+
- name: Cache for maven dependencies
138+
uses: actions/cache@v2
139+
with:
140+
path: ~/.m2/repository
141+
key: maven-repo-${{ hashFiles('**/pom.xml') }}-${{ github.job }}
142+
restore-keys: |
143+
maven-repo-${{ hashFiles('**/pom.xml') }}
144+
maven-repo-
93145
- run: ./dev-support/checks/findbugs.sh
94146
- uses: actions/upload-artifact@master
95147
if: always()
96148
with:
97149
name: findbugs
98150
path: target/findbugs
151+
- name: Delete temporary build artifacts
152+
run: rm -rf ~/.m2/repository/org/apache/ratis
153+
if: always()

0 commit comments

Comments
 (0)