From 477bc424d93ad5302049e2545988a06f24372983 Mon Sep 17 00:00:00 2001 From: Tejaswini Bandlamudi <96047043+tejaswini-imply@users.noreply.github.com> Date: Fri, 10 Feb 2023 22:27:45 +0530 Subject: [PATCH] Fix GHA tests cache hit miss scenario (#13772) * rebuild maven project or docker image in case of cache hit miss * rebuild maven project in case of docker cache hit miss too * fix docker-restore cache hit fail issue --- .github/workflows/reusable-revised-its.yml | 30 ++++++++++++++++++--- .github/workflows/reusable-standard-its.yml | 7 +++-- .github/workflows/reusable-unit-tests.yml | 7 +++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reusable-revised-its.yml b/.github/workflows/reusable-revised-its.yml index 963695cd9fc..26c045fb86f 100644 --- a/.github/workflows/reusable-revised-its.yml +++ b/.github/workflows/reusable-revised-its.yml @@ -61,16 +61,38 @@ jobs: with: path: ~/.m2/repository key: maven-${{ runner.os }}-${{ inputs.build_jdk }}-${{ github.sha }} - fail-on-cache-miss: true - - name: Retrieve cached docker image + - name: Restore targets + id: targets-restore uses: actions/cache/restore@v3 with: - key: druid-container-jdk${{ inputs.build_jdk }}.tar.gz + path: ./**/target + key: maven-${{ runner.os }}-${{ inputs.build_jdk }}-targets-${{ github.sha }} + + - name: Retrieve cached docker image + id: docker-restore + uses: actions/cache/restore@v3 + with: + key: druid-container-jdk${{ inputs.build_jdk }}.tar.gz-${{ github.sha }} path: | ./druid-container-jdk${{ inputs.build_jdk }}.tar.gz ./integration-tests-ex/image/target/env.sh - fail-on-cache-miss: true + + - name: Maven build + if: steps.maven-restore.outputs.cache-hit != 'true' || ( steps.docker-restore.outputs.cache-hit != 'true' && steps.targets-restore.outputs.cache-hit != 'true' ) + run: | + ./it.sh ci + + - name: Create docker image + if: steps.docker-restore.outputs.cache-hit != 'true' + env: + docker-restore: ${{ toJson(steps.docker-restore.outputs) }} + run: | + ./it.sh image + source ./integration-tests-ex/image/target/env.sh + docker tag $DRUID_IT_IMAGE_NAME $DRUID_IT_IMAGE_NAME-jdk${{ matrix.jdk }} + echo $DRUID_IT_IMAGE_NAME + docker save "$DRUID_IT_IMAGE_NAME" | gzip > druid-container-jdk${{ matrix.jdk }}.tar.gz - name: Load docker image run: | diff --git a/.github/workflows/reusable-standard-its.yml b/.github/workflows/reusable-standard-its.yml index 921b08eb1cc..cb3c7012708 100644 --- a/.github/workflows/reusable-standard-its.yml +++ b/.github/workflows/reusable-standard-its.yml @@ -74,12 +74,15 @@ jobs: with: path: ~/.m2/repository key: maven-${{ runner.os }}-${{ inputs.build_jdk }}-${{ github.sha }} - fail-on-cache-miss: true + + - name: Maven build + if: steps.maven-restore.outputs.cache-hit != 'true' + run: | + ./it.sh ci - name: Run IT env: MYSQL_DRIVER_CLASSNAME: ${{ inputs.mysql_driver }} - MVN: ${{ format('{0}{1}', env.MVN, (steps.maven-restore.outputs.cache-hit && '' || ' -U')) }} run: | # Debug echo echo "Mysql driver: ${MYSQL_DRIVER_CLASSNAME}" diff --git a/.github/workflows/reusable-unit-tests.yml b/.github/workflows/reusable-unit-tests.yml index 547d8c4db93..7e48fc633b6 100644 --- a/.github/workflows/reusable-unit-tests.yml +++ b/.github/workflows/reusable-unit-tests.yml @@ -65,7 +65,6 @@ jobs: with: path: ~/.m2/repository key: maven-${{ runner.os }}-${{ inputs.jdk }}-${{ github.sha }} - fail-on-cache-miss: true - name: setup node uses: actions/setup-node@v3 @@ -89,8 +88,12 @@ jobs: - name: setup diff-test-coverage run: npm install @connectis/diff-test-coverage@1.5.3 + - name: Maven build + if: steps.maven-restore.outputs.cache-hit != 'true' + run: | + ./it.sh ci + - name: test & coverage env: MAVEN_PROJECTS: ${{ inputs.maven_projects }} - MVN: ${{ format('{0}{1}', env.MVN, (steps.maven-restore.outputs.cache-hit && '' || ' -U')) }} run: ./.github/scripts/unit_tests_script.sh