diff --git a/.github/workflows/test-heif-convert.yml b/.github/workflows/test-heif-convert.yml new file mode 100644 index 0000000..299341b --- /dev/null +++ b/.github/workflows/test-heif-convert.yml @@ -0,0 +1,44 @@ +name: Test heif-convert + +on: [push, pull_request] + +jobs: + test-script: + name: Test Script + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install heif-convert + run: pip3 install . + + - name: Add executable permission to test-script + working-directory: tests + run: chmod +x test-script.sh + + - name: Run Test + working-directory: tests + run: ./test-script.sh + + test-docker-image: + name: Test Docker Image + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Docker Image + uses: docker/build-push-action@v5 + with: + context: . + push: false + tags: nevermendel/heif-convert + + - name: Add executable permission to test-docker-image + working-directory: tests + run: chmod +x test-docker-image.sh + + - name: Run Test + working-directory: tests + run: ./test-docker-image.sh diff --git a/tests/image.heic b/tests/image.heic new file mode 100644 index 0000000..381b0f0 Binary files /dev/null and b/tests/image.heic differ diff --git a/tests/image.jpg b/tests/image.jpg new file mode 100644 index 0000000..1491c3f Binary files /dev/null and b/tests/image.jpg differ diff --git a/tests/image.png b/tests/image.png new file mode 100644 index 0000000..a8ee9b2 Binary files /dev/null and b/tests/image.png differ diff --git a/tests/test-docker-image.sh b/tests/test-docker-image.sh new file mode 100755 index 0000000..22eb936 --- /dev/null +++ b/tests/test-docker-image.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +docker run -v "$(pwd)":/usr/app/out --rm nevermendel/heif-convert image.heic -f jpg -q 90 -o result +docker run -v "$(pwd)":/usr/app/out --rm nevermendel/heif-convert image.heic -f png -o result + +status_code=0 + +if ! cmp -s image.jpg result.jpg; then + echo "jpg image is different" + status_code=1 +fi + +if ! cmp -s image.png result.png; then + echo "png image is different" + status_code=1 +fi + +exit $status_code diff --git a/tests/test-script.sh b/tests/test-script.sh new file mode 100755 index 0000000..b85cd67 --- /dev/null +++ b/tests/test-script.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +heif-convert image.heic -f jpg -q 90 -o result +heif-convert image.heic -f png -o result + +status_code=0 + +if ! cmp -s image.jpg result.jpg; then + echo "jpg image is different" + status_code=1 +fi + +if ! cmp -s image.png result.png; then + echo "png image is different" + status_code=1 +fi + +exit $status_code