Skip to content

Commit

Permalink
Generate hash of integration-tests/ for test runner image if tag not …
Browse files Browse the repository at this point in the history
…provided
  • Loading branch information
lukaszcl committed Sep 2, 2024
1 parent 275cca7 commit 9376a90
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions .github/actions/build-test-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -90,20 +89,30 @@ 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
if: steps.check-image.outputs.exists == 'false'
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: |
Expand All @@ -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
Expand Down

0 comments on commit 9376a90

Please sign in to comment.