From 9376a908a715d3299b061051608b41658ab12da7 Mon Sep 17 00:00:00 2001 From: lukaszcl <120112546+lukaszcl@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:55:17 +0200 Subject: [PATCH] Generate hash of integration-tests/ for test runner image if tag not provided --- .github/actions/build-test-image/action.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/actions/build-test-image/action.yml b/.github/actions/build-test-image/action.yml index dcc9fefda71..bcd8b4b27bc 100644 --- a/.github/actions/build-test-image/action.yml +++ b/.github/actions/build-test-image/action.yml @@ -7,8 +7,7 @@ inputs: default: chainlink-tests required: false tag: - description: The tag to use by default and to use for checking image existance - default: ${{ github.sha }} + description: The tag to use by default and to use for checking image existance. If not provided, the hash of the integration-tests/ directory will be used required: false other_tags: description: Other tags to push if needed @@ -90,12 +89,22 @@ runs: # End Base Image Logic # Test Runner Logic + - name: Get hash of integration-tests/ for test runner image + id: test_runner_hash + if: ${{ inputs.tag == '' }} + # Do not include testconfig/ in the hash to avoid rebuilding the image when only testconfig/ changes + shell: sh + run: | + HASH_VALUE=$(echo ${{ hashFiles('integration-tests/**', '!integration-tests/testconfig/**') }}) + echo "Computed hash: $HASH_VALUE" + echo "hash_value=$HASH_VALUE" >> $GITHUB_OUTPUT + - name: Check if image exists id: check-image uses: smartcontractkit/chainlink-github-actions/docker/image-exists@75a9005952a9e905649cfb5a6971fd9429436acd # v2.3.25 with: repository: ${{ inputs.repository }} - tag: ${{ inputs.tag }} + tag: ${{ inputs.tag || steps.test_runner_hash.outputs.hash_value }} AWS_REGION: ${{ inputs.QA_AWS_REGION }} AWS_ROLE_TO_ASSUME: ${{ inputs.QA_AWS_ROLE_TO_ASSUME }} - name: Build and Publish Test Runner @@ -103,7 +112,7 @@ runs: uses: smartcontractkit/chainlink-github-actions/docker/build-push@75a9005952a9e905649cfb5a6971fd9429436acd # v2.3.25 with: tags: | - ${{ inputs.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ inputs.QA_AWS_REGION }}.amazonaws.com/${{ inputs.repository }}:${{ inputs.tag }} + ${{ inputs.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ inputs.QA_AWS_REGION }}.amazonaws.com/${{ inputs.repository }}:${{ inputs.tag || steps.test_runner_hash.outputs.hash_value }} ${{ inputs.other_tags }} file: ./integration-tests/test.Dockerfile build-args: | @@ -116,7 +125,7 @@ runs: shell: sh env: INPUTS_REPOSITORY: ${{ inputs.repository }} - INPUTS_TAG: ${{ inputs.tag }} + INPUTS_TAG: ${{ inputs.tag || steps.test_runner_hash.outputs.hash_value }} run: | echo "### ${INPUTS_REPOSITORY} image tag for this test run :ship:" >>$GITHUB_STEP_SUMMARY echo "\`${INPUTS_TAG}\`" >>$GITHUB_STEP_SUMMARY