File tree Expand file tree Collapse file tree 6 files changed +104
-0
lines changed
Expand file tree Collapse file tree 6 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Test test-image-size action
2+
3+ on :
4+ workflow_call :
5+
6+ jobs :
7+ test :
8+ runs-on : ubuntu-latest
9+ steps :
10+ - name : Checkout repository
11+ uses : actions/checkout@v6
12+
13+ - name : Test scripts
14+ run : ./test-image-size/test_scripts.sh
15+
16+ - name : Run test-image-size
17+ uses : ./test-image-size
18+ with :
19+ image : hazelcast/hazelcast:5.0.1-slim
Original file line number Diff line number Diff line change 4141 uses : ./.github/workflows/test-slack-notification.yml
4242 secrets : inherit
4343
44+ test-test-image-size :
45+ uses : ./.github/workflows/test-test-image-size.yml
46+ secrets : inherit
47+
4448 assert-all-jobs-succeeded :
4549 runs-on : ubuntu-latest
4650 needs :
5458 - test-get-supported-platforms
5559 - test-resolve-editions
5660 - test-slack-notification
61+ - test-test-image-size
5762 if : always()
5863 steps :
5964 - name : Check all jobs succeeded
Original file line number Diff line number Diff line change 1+ name : Test image size
2+ description : Test image isn't excessively large / wasting space
3+
4+ inputs :
5+ image :
6+ description : Image name to test
7+ required : true
8+ minimum_efficiency :
9+ description : Minimum efficiency percentage required - 0-1 scale
10+ required : false
11+ default : 0.95
12+
13+ runs :
14+ using : " composite"
15+ steps :
16+ - shell : bash
17+ run : |
18+ . ${GITHUB_ACTION_PATH}/test-image-size.functions.sh
19+
20+ test_image_size "${IMAGE}" "${MINIMUM_EFFICIENCY}"
21+ env :
22+ IMAGE : ${{ inputs.image }}
23+ MINIMUM_EFFICIENCY : ${{ inputs.minimum_efficiency }}
Original file line number Diff line number Diff line change 1+ function test_image_size() {
2+ local image=$1
3+ local minimum_efficiency=$2
4+
5+ local config_file
6+ config_file=$( mktemp)
7+
8+ # https://github.com/wagoodman/dive/blob/main/README.md#ci-integration
9+ yq eval -n "
10+ .rules.lowestEfficiency = ${minimum_efficiency} |
11+ .rules.highestWastedBytes = \" disabled\" |
12+ .rules.highestUserWastedPercent = \" disabled\"
13+ " > " ${config_file} "
14+
15+ docker run --rm \
16+ --env CI=true \
17+ --volume /var/run/docker.sock:/var/run/docker.sock \
18+ --volume " ${config_file} :/.dive-ci" \
19+ docker.io/wagoodman/dive:latest \
20+ " ${image} "
21+
22+ return $?
23+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -eu ${RUNNER_DEBUG: +-x}
4+
5+ SCRIPT_DIR=" $( dirname " $( readlink -f " $0 " ) " ) "
6+
7+ # Source the latest version of assert.sh unit testing library and include in current shell
8+ source /dev/stdin <<< " $(curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh)"
9+
10+ . " $SCRIPT_DIR " /test-image-size.functions.sh
11+
12+ TESTS_RESULT=0
13+
14+ function assert_test_image_size {
15+ local image=$1
16+ local minimum_efficiency=$2
17+ local expected_exit_code=$3
18+ test_image_size " ${image} " " ${minimum_efficiency} " && true
19+ local actual_exit_code=$?
20+ local msg=" Expected exit code for \" ${image} \" / \" ${minimum_efficiency} \" "
21+ assert_eq " ${expected_exit_code} " " ${actual_exit_code} " " ${msg} " && log_success " ${msg} " || TESTS_RESULT=$?
22+ }
23+
24+ log_header " Tests for test_image_size"
25+ # expected efficiency: 99.8541 %
26+ assert_test_image_size hazelcast/hazelcast:5.0.1-slim 0.95 0
27+ assert_test_image_size hazelcast/hazelcast:5.0.1-slim 0.99999999999 1
28+
29+ assert_eq 0 " $TESTS_RESULT " " All tests should pass"
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ SCRIPT_DIR=" $( dirname " $( readlink -f " $0 " ) " ) "
4+
5+ find " $SCRIPT_DIR " -name " *_tests.sh" -print0 | xargs -0 -n1 bash
You can’t perform that action at this time.
0 commit comments