From 2167a192068c37d3ff6eeff667b370856c69e351 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Fri, 5 Jan 2024 21:18:03 +0700 Subject: [PATCH] chore: use a single shared Maven cache for all workflows Part of #1656 --- .github/workflows/deploy.yml | 9 ++- .github/workflows/integration-tests-h2.yml | 8 ++- .github/workflows/integration-tests-mysql.yml | 8 ++- .../workflows/integration-tests-postgres.yml | 8 ++- .github/workflows/static-analysis.yml | 56 ++++++++++++++++--- .github/workflows/unit-tests.yml | 16 +++++- 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5ff463cf5..7fc3693a2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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/cache@v3.3.2 # 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 diff --git a/.github/workflows/integration-tests-h2.yml b/.github/workflows/integration-tests-h2.yml index 68735f234..6a5e93601 100644 --- a/.github/workflows/integration-tests-h2.yml +++ b/.github/workflows/integration-tests-h2.yml @@ -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/cache@v3.3.2 # 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 diff --git a/.github/workflows/integration-tests-mysql.yml b/.github/workflows/integration-tests-mysql.yml index 3aefb93f6..3be03bdf7 100644 --- a/.github/workflows/integration-tests-mysql.yml +++ b/.github/workflows/integration-tests-mysql.yml @@ -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/cache@v3.3.2 # 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 diff --git a/.github/workflows/integration-tests-postgres.yml b/.github/workflows/integration-tests-postgres.yml index 2a3644147..f7b79280a 100644 --- a/.github/workflows/integration-tests-postgres.yml +++ b/.github/workflows/integration-tests-postgres.yml @@ -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/cache@v3.3.2 # 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 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1882af452..b7f4391da 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -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/cache@v3.3.2 # 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 @@ -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/cache@v3.3.2 # 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 @@ -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/cache@v3.3.2 # 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 @@ -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/cache@v3.3.2 # 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 @@ -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/cache@v3.3.2 # 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 @@ -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/cache@v3.3.2 # 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 \ @@ -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/cache@v3.3.2 # 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 \ diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index b8a8167b1..839c7b4e2 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -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/cache@v3.3.2 # 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 @@ -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/cache@v3.3.2 # 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