Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Use date in dependencies cache and refresh daily (#327)
Browse files Browse the repository at this point in the history
* Use date in dependencies cache and refresh daily

* fail if cache already warm
  • Loading branch information
Travis Tomsu authored Feb 19, 2021
1 parent eda7234 commit 368b04f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/unitTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ jobs:
matrix:
java: [8, 11, 15]
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d' --utc)"

- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
key: ${{ runner.os }}-maven-${{ steps.date.outputs.date }}

- name: Mvn install # Need this when the directory/pom structure changes
id: install1
continue-on-error: true
Expand All @@ -39,6 +44,7 @@ jobs:
--define maven.test.skip=true \
--define maven.javadoc.skip=true \
install
- name: Retry install on failure
id: install2
if: steps.install1.outcome == 'failure'
Expand All @@ -50,6 +56,7 @@ jobs:
--define maven.test.skip=true \
--define maven.javadoc.skip=true \
install
- name: Unit Tests
id: unitTest1
continue-on-error: true
Expand All @@ -59,12 +66,14 @@ jobs:
--fail-at-end \
--threads 1.5C \
test
- name: Aggregate Report
run: |
./mvnw \
--batch-mode \
--define aggregate=true \
surefire-report:report-only
- name: Archive logs
if: always()
continue-on-error: true
Expand All @@ -81,16 +90,21 @@ jobs:
strategy:
fail-fast: false
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d' --utc)"

- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: 11

- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
key: ${{ runner.os }}-maven-${{ steps.date.outputs.date }}

- name: releaseCheck
run: |
./mvnw \
Expand All @@ -101,6 +115,7 @@ jobs:
-Dcheckstyle.skip \
clean \
package
- name: docsCheck
run: |
./mvnw \
Expand All @@ -112,6 +127,7 @@ jobs:
--projects docs \
clean \
package
- name: Archive Artifacts
if: always()
continue-on-error: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
name: Purge Caches
name: Warm Caches
on:
workflow_dispatch:
schedule:
- cron: '6 4 1,15 * *' # 04:06 UTC every 1st and 15th of the month
- cron: '1 0 * * *' # 00:01 UTC every day

jobs:
purgeCache:
warmCache:
if: github.repository == 'GoogleCloudPlatform/spring-cloud-gcp' # Only run on upstream branch
name: Purge Cache
name: Warm Cache
runs-on: ubuntu-20.04
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d' --utc)"

- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- uses: actions/cache@v2
id: loadCache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
key: ${{ runner.os }}-maven-${{ steps.date.outputs.date }}

- name: Purge caches
run: |
rm -rf ~/.m2 && \
rm -rf ~/.sonar/cache
- name: Fail if cache already warm
if: steps.loadCache.outputs.cache-hit == 'true'
run: /bin/false # Do nothing, unsuccessfully.

- uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar-${{ steps.date.outputs.date }}

- name: Mvn install
id: install1
Expand Down

0 comments on commit 368b04f

Please sign in to comment.