Skip to content

Commit

Permalink
chore: use a single shared Maven cache for all workflows
Browse files Browse the repository at this point in the history
Part of #1656
  • Loading branch information
php-coder committed Jan 5, 2024
1 parent 3e76317 commit 2167a19
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 13 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies

- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-

- name: Build WAR file
# NOTE: we use -Dmaven.test.skip=true instead of -DskipUnitTests=true
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/integration-tests-h2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: ${{ matrix.java-version }} # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run integration tests
run: ./src/main/scripts/execute-command.sh integration-tests
- name: Save RobotFramework reports
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/integration-tests-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
# This is a workaround for github action limitation: we can't specify command for the service (--character-set-server=utf8)
# and have to modify database manually. See also:
# https://github.com/actions/runner/discussions/1872 and https://github.com/orgs/community/discussions/26688
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/integration-tests-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run integration tests
env:
SPRING_PROFILES_ACTIVE: postgres
Expand Down
56 changes: 49 additions & 7 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run CheckStyle
run: ./src/main/scripts/execute-command.sh checkstyle

Expand All @@ -49,7 +55,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run PMD
run: ./src/main/scripts/execute-command.sh pmd

Expand All @@ -68,7 +80,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Check license header
run: ./src/main/scripts/execute-command.sh check-license

Expand All @@ -87,7 +105,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Check pom.xml
run: ./src/main/scripts/execute-command.sh check-pom

Expand Down Expand Up @@ -192,7 +216,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run maven-enforcer-plugin
run: ./src/main/scripts/execute-command.sh enforcer

Expand All @@ -211,7 +241,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Compile sources
run: >-
mvn \
Expand All @@ -237,7 +273,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Compile sources
run: >-
mvn \
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run Jest
run: ./src/main/scripts/execute-command.sh jest

Expand All @@ -49,6 +55,12 @@ jobs:
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run unit tests
run: ./src/main/scripts/execute-command.sh unit-tests

0 comments on commit 2167a19

Please sign in to comment.