From 17dd5ef85e003838c57008b042b9b67198f42712 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Tue, 27 Aug 2024 08:22:09 -0400 Subject: [PATCH] CI: cache java dependencies and ccm images (#326) --- .github/workflows/tests@v1.yml | 96 ++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests@v1.yml b/.github/workflows/tests@v1.yml index a2f4b3b4af..88bbec688a 100644 --- a/.github/workflows/tests@v1.yml +++ b/.github/workflows/tests@v1.yml @@ -28,9 +28,35 @@ jobs: java-version: ${{ matrix.java-version }} distribution: 'adopt' + - name: Get POM hash + id: get-pom-hash + run: echo "value=${{ hashFiles('**/pom.xml') }}" >> "$GITHUB_OUTPUT" + + - name: Restore maven repository cache + uses: actions/cache/restore@v4 + id: java-cache + with: + path: ~/.m2/repository + key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ steps.get-pom-hash.outputs.value }} + - name: Compile source and tests run: mvn -B compile test-compile -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true + - name: Download test dependencies + if: steps.java-cache.outputs.cache-hit != 'true' + run: mvn -B test -Dtest=TestThatDoesNotExists -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true || true + + - name: Download verify dependencies + if: steps.java-cache.outputs.cache-hit != 'true' + run: mvn -B verify -DskipTests || true + + - name: Save maven repository cache + uses: actions/cache/save@v4 + if: steps.java-cache.outputs.cache-hit != 'true' + with: + path: ~/.m2/repository + key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ steps.get-pom-hash.outputs.value }} + verify: name: Full verify runs-on: ubuntu-latest @@ -51,6 +77,12 @@ jobs: java-version: ${{ matrix.java-version }} distribution: 'adopt' + - name: Restore maven repository cache + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Full verify run: mvn -B verify -DskipTests @@ -60,6 +92,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 + strategy: + matrix: + java-version: [8] + fail-fast: false + steps: - name: Checkout source uses: actions/checkout@v2 @@ -67,9 +104,15 @@ jobs: - name: Set up JDK 8 uses: actions/setup-java@v2 with: - java-version: '8' + java-version: ${{ matrix.java-version }} distribution: 'adopt' + - name: Restore maven repository cache + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Run unit tests run: mvn -B test -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true @@ -79,6 +122,7 @@ jobs: shopt -s globstar mkdir unit cp --parents ./**/target/*-reports/*.xml unit/ + - name: Upload test results uses: actions/upload-artifact@v2 if: success() || failure() @@ -119,6 +163,7 @@ jobs: strategy: matrix: cassandra-version: ${{ fromJson(needs.setup-integration-tests.outputs.cassandra-integration-tests-versions) }} + java-version: [8] fail-fast: false steps: @@ -128,9 +173,15 @@ jobs: - name: Set up JDK 8 uses: actions/setup-java@v2 with: - java-version: '8' + java-version: ${{ matrix.java-version }} distribution: 'adopt' + - name: Restore maven repository cache + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Setup Python 3 uses: actions/setup-python@v2 with: @@ -139,15 +190,31 @@ jobs: - name: Setup environment run: | pip3 install https://github.com/scylladb/scylla-ccm/archive/a93125bc6ad7dd5c9694331e89dc1fb212431ffe.zip + + - name: Restore CCM image cache + uses: actions/cache/restore@v4 + id: ccm-cache + with: + path: ~/.ccm/repository + key: ccm-cassandra-${{ runner.os }}-${{ matrix.cassandra-version }} + - name: Run integration tests on Cassandra (${{ matrix.cassandra-version }}) run: mvn -B -e verify -Dccm.version=${{ matrix.cassandra-version }} -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true + - name: Save CCM image cache + uses: actions/cache/save@v4 + if: steps.ccm-cache.outputs.cache-hit != 'true' + with: + path: ~/.ccm/repository + key: ccm-cassandra-${{ runner.os }}-${{ matrix.cassandra-version }} + - name: Copy test results if: success() || failure() run: | shopt -s globstar mkdir cassandra-${{ matrix.cassandra-version }} cp --parents ./**/target/*-reports/*.xml cassandra-${{ matrix.cassandra-version }}/ + - name: Upload test results uses: actions/upload-artifact@v2 if: success() || failure() @@ -171,6 +238,7 @@ jobs: strategy: matrix: scylla-version: ${{ fromJson(needs.setup-integration-tests.outputs.scylla-integration-tests-versions) }} + java-version: [8] fail-fast: false steps: @@ -180,9 +248,15 @@ jobs: - name: Set up JDK 8 uses: actions/setup-java@v2 with: - java-version: '8' + java-version: ${{ matrix.java-version }} distribution: 'adopt' + - name: Restore maven repository cache + uses: actions/cache/restore@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-${{ matrix.java-version }}-maven-${{ hashFiles('**/pom.xml') }} + - name: Setup Python 3 uses: actions/setup-python@v2 with: @@ -192,15 +266,31 @@ jobs: run: | pip3 install https://github.com/scylladb/scylla-ccm/archive/a93125bc6ad7dd5c9694331e89dc1fb212431ffe.zip sudo sh -c "echo 2097152 > /proc/sys/fs/aio-max-nr" + + - name: Restore CCM image cache + uses: actions/cache/restore@v4 + id: ccm-cache + with: + path: ~/.ccm/scylla-repository + key: ccm-scylla-${{ runner.os }}-${{ matrix.scylla-version }} + - name: Run integration tests on Scylla (${{ matrix.scylla-version }}) run: mvn -B verify -Dccm.version=${{ matrix.scylla-version }} -Dccm.scylla=true -Dfmt.skip=true -Dclirr.skip=true -Danimal.sniffer.skip=true + - name: Save CCM image cache + uses: actions/cache/save@v4 + if: steps.ccm-cache.outputs.cache-hit != 'true' + with: + path: ~/.ccm/repository + key: ccm-scylla-${{ runner.os }}-${{ matrix.scylla-version }} + - name: Copy test results if: success() || failure() run: | shopt -s globstar mkdir scylla-${{ matrix.scylla-version }} cp --parents ./**/target/*-reports/*.xml scylla-${{ matrix.scylla-version }}/ + - name: Upload test results uses: actions/upload-artifact@v2 if: success() || failure()