Skip to content

Commit

Permalink
Change test scripts to test only (#93)
Browse files Browse the repository at this point in the history
Test by specifying a built image.
  • Loading branch information
abetomo authored Nov 14, 2024
1 parent 4e85395 commit edbf494
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ jobs:
echo "digest: ${{ steps.docker_build.outputs.digest }}"
- name: Test
run: |
test/build.sh \
./test.sh \
"${{ matrix.id }}" \
"${{ steps.parse.outputs.tag }}"
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ EOL

## How to build Mroonga image

* Dockerfile for some couples of MySQL and Mroonga are under "Dockerfile" directory.
Dockerfiles are located in each build context.
For example, Dockerfile for MySQL 8.0 and Mroonga is under the `mysql-8.0` directory.

```shell
$ git clone https://github.com/mroonga/docker mroonga_docker
Expand All @@ -191,10 +192,13 @@ $ sudo docker image build -t mysql80-mroonga mysql-8.0

## How to test

You can test that the image was built as expected with `test.sh`.
The arguments are the build context and the image name.

```shell
$ git clone https://github.com/mroonga/docker mroonga_docker
$ cd mroonga_docker
$ test/build.sh mysql-8.0
$ ./test.sh mysql-8.0 mysql80-mroonga
```

## How to release
Expand Down
22 changes: 6 additions & 16 deletions test/build.sh → test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,22 @@

set -eu

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

cd $(dirname $0)

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

timestamp=$(date +%s)
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,}')

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
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 container run \
-d \
Expand Down Expand Up @@ -53,7 +46,4 @@ set -e
sudo docker container stop $container_name
sudo docker container logs $container_name
sudo docker container rm $container_name
if [ "${with_build}" = "true" ]; then
sudo docker image rm "${image_name}"
fi
exit $success

0 comments on commit edbf494

Please sign in to comment.