Skip to content

Commit dbe8278

Browse files
authored
[skip ci] Added local maven repository caching to main build and OWASP build. This improves the build time of the main build and also prevents the OWASP database from having to be recreated each time the OWASP build runs. Also updated the nvd delay to the recommended 6 seconds. (#24)
1 parent e983b7e commit dbe8278

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@ jobs:
1212
fetch-depth: 0
1313
persist-credentials: false
1414

15+
- name: Cache local Maven repository
16+
uses: actions/cache@v3
17+
with:
18+
path: ~/.m2/repository
19+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
20+
restore-keys: |
21+
${{ runner.os }}-maven-
22+
1523
- name: Set up JDK 21
1624
uses: oracle-actions/setup-java@v1
1725
with:
1826
website: jdk.java.net
1927
release: 21
20-
- run: ./mvnw clean install -Pall-quality-gates -B
28+
29+
- name: Run Maven
30+
run: ./mvnw clean install -Pall-quality-gates -B
2131

2232
release:
2333
runs-on: ubuntu-latest

.github/workflows/latest-versions.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ jobs:
1414
with:
1515
website: jdk.java.net
1616
release: 21
17-
- run: ./mvnw clean versions:update-properties scm:check-local-modification -U -B
17+
18+
- name: Run Maven
19+
run: ./mvnw clean versions:update-properties scm:check-local-modification -U -B

.github/workflows/owasp.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,35 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111

12+
- name: Get Date
13+
id: get-date
14+
run: |
15+
echo "datetime=$(/bin/date -u "+%Y%m%d%H")" >> $GITHUB_OUTPUT
16+
shell: bash
17+
18+
- name: Restore cached Maven dependencies
19+
uses: actions/cache/restore@v3
20+
with:
21+
path: ~/.m2/repository
22+
# Using datetime in cache key as OWASP database may change, without the pom changing
23+
key: ${{ runner.os }}-maven-${{ steps.get-date.outputs.datetime }}-${{ hashFiles('**/pom.xml') }}
24+
restore-keys: |
25+
${{ runner.os }}-maven-${{ steps.get-date.outputs.datetime }}
26+
${{ runner.os }}-maven-
27+
1228
- name: Set up JDK 21
1329
uses: oracle-actions/setup-java@v1
1430
with:
1531
website: jdk.java.net
1632
release: 21
17-
- run: ./mvnw clean install dependency-check:check -DnvdApiKey= -B
33+
34+
- name : Run Maven
35+
run: ./mvnw clean install dependency-check:check -DnvdApiKey=${{ secrets.NVD_API_KEY }} -DnvdApiDelay=6000 -B
36+
37+
# Want the Maven dependencies to be cached even if the build fails as we want the OWASP database cached, regardless of whether vulnerabilities are found or not
38+
- name: Cache Maven dependencies
39+
uses: actions/cache/save@v3
40+
if: always()
41+
with:
42+
path: ~/.m2/repository
43+
key: ${{ runner.os }}-maven-${{ steps.get-date.outputs.datetime }}-${{ hashFiles('**/pom.xml') }}

pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@
308308
<artifactId>dependency-check-maven</artifactId>
309309
<version>${dependency-check-maven.version}</version>
310310
<configuration>
311-
<!-- NVD API Key obtained from https://nvd.nist.gov/developers/request-an-api-key -->
312-
<nvdApiKey>${nvdApiKey}</nvdApiKey>
313-
314311
<!-- Assembly analyzer disabled because we don't have any .NET code/dlls -->
315312
<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
316313
<!-- Node and retirejs analyzer disabled, because any js floating around isn't part of the main app -->

0 commit comments

Comments
 (0)