Skip to content

Commit

Permalink
ci: Test the built image (#91)
Browse files Browse the repository at this point in the history
Changed `test/build.sh` to also test on already built images.
  • Loading branch information
abetomo authored Nov 13, 2024
1 parent c092c74 commit 4e85395
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ jobs:
fi
fi
tags="groonga/mroonga:${version}"
tag="groonga/mroonga:${version}"
tags="${tag}"
if [ "${version}" = "mysql-8.0-latest" ]; then
tags="${tags},groonga/mroonga:latest"
fi
echo "::set-output name=push::${push}"
echo "::set-output name=tag::${tag}"
echo "::set-output name=tags::${tags}"
- uses: actions/checkout@v4
- uses: docker/login-action@v3
Expand All @@ -58,9 +60,15 @@ jobs:
# cache-to: type=gha,mode=max
context: ${{ matrix.id }}
push: ${{ steps.parse.outputs.push }}
load: ${{ steps.parse.outputs.push != 'true' }}
tags: ${{ steps.parse.outputs.tags }}
- name: Image info
run: |
echo "ref: ${{ github.ref }}"
echo "tags: ${{ steps.parse.outputs.tags }}"
echo "digest: ${{ steps.docker_build.outputs.digest }}"
- name: Test
run: |
test/build.sh \
"${{ matrix.id }}" \
"${{ steps.parse.outputs.tag }}"
20 changes: 14 additions & 6 deletions test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,30 @@

set -eu

if [ $# != 1 ]; then
echo "Usage: $0 CONTEXT"
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage: $0 CONTEXT [IMAGE_NAME]"
echo " e.g.: $0 mysql-8.0"
exit 1
fi

cd $(dirname $0)

context=$1
image_name=${2:-}

timestamp=$(date +%s)
image_name="test_mroonga_${timestamp}"
container_name="name_${image_name}"
container_name="mroonga_build_test_${timestamp}"

eval $(grep -E -o '[a-z]+_version=[0-9.]+' ../$context/Dockerfile)
mysql_version=$(head -n1 ../$context/Dockerfile | grep -E -o '[0-9.]{2,}')

sudo docker --debug image build -t $image_name ../$context
with_build=false
if [ -z "${image_name}" ]; then
with_build=true
image_name="test_mroonga_${timestamp}"
sudo docker --debug image build -t "${image_name}" "../${context}"
fi

sudo docker container run \
-d \
-p 33061:3306 \
Expand Down Expand Up @@ -47,5 +53,7 @@ set -e
sudo docker container stop $container_name
sudo docker container logs $container_name
sudo docker container rm $container_name
sudo docker image rm $image_name
if [ "${with_build}" = "true" ]; then
sudo docker image rm "${image_name}"
fi
exit $success

0 comments on commit 4e85395

Please sign in to comment.