diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7bf438..a1b56b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,11 +20,13 @@ jobs: - 3.0.5 backend: - libvips + - imagemagick steps: - name: Install Deps run: | sudo apt-get -y install \ + ffmpeg mupdf-tools \ libtiff-dev \ libpng-dev libpng16-16 \ libjpeg-dev libjpeg-turbo8-dev libjpeg-turbo-progs \ @@ -42,7 +44,7 @@ jobs: uses: actions/cache/restore@v3 with: path: /home/runner/vips - key: compiled-vips-${{ matrix.vips-version }} + key: compile-vips-${{ matrix.vips-version }} - name: Compile Libvips if: steps.vips-cache.outputs.cache-hit != 'true' @@ -62,7 +64,7 @@ jobs: uses: actions/cache/save@v3 with: path: /home/runner/vips - key: compiled-vips-${{ matrix.vips-version }} + key: compile-vips-${{ matrix.vips-version }} - name: Install Libvips run: | @@ -75,7 +77,7 @@ jobs: uses: actions/cache/restore@v3 with: path: /home/runner/im - key: compiled-im-${{ matrix.im-version }} + key: compile-im-${{ matrix.im-version }} - name: Compile Imagemagick if: steps.im-cache.outputs.cache-hit != 'true' @@ -93,7 +95,7 @@ jobs: uses: actions/cache/save@v3 with: path: /home/runner/im - key: compiled-im-${{ matrix.im-version }} + key: compile-im-${{ matrix.im-version }} - name: Install Imagemagick run: | @@ -101,13 +103,12 @@ jobs: sudo make install sudo ldconfig /usr/local/lib - - name: Install FFMpeg + - name: Version Info run: | - sudo add-apt-repository ppa:ubuntuhandbook1/ffmpeg6 - sudo apt install ffmpeg - - - name: Install MuPDF - run: sudo apt-get -y install mupdf-tools + vips --version + identify --version + ffmpeg -version + mutool -v - uses: actions/checkout@v4 @@ -119,8 +120,4 @@ jobs: - env: VIPS_WARNING: 1 run: | - vips --version - identify --version - ffmpeg -version - mutool -v bundle exec rake test:${{ matrix.backend }} \ No newline at end of file diff --git a/test/bob_ross/plugins/pdf_test.rb b/test/bob_ross/plugins/pdf_test.rb index 7dec213..4949742 100644 --- a/test/bob_ross/plugins/pdf_test.rb +++ b/test/bob_ross/plugins/pdf_test.rb @@ -37,7 +37,10 @@ class PDFPluginTest < Minitest::Test assert_geometry('612x792', image) assert_signature( - 'f2c56e4f41e4cea5137b2aaa6e949f50ca3cd17b9803b221dd49a1ec8891aa5b', + key_for_version({ + ['>= 1.19.0', '< 1.22.2'] => '169487ef32a2f4354a628160d508c2c508fdf47005ca3b91f5f1537b3efcf68c', + '>= 1.22.2' => 'f2c56e4f41e4cea5137b2aaa6e949f50ca3cd17b9803b221dd49a1ec8891aa5b', + }, mupdf_version), image ) end @@ -47,7 +50,10 @@ class PDFPluginTest < Minitest::Test assert_geometry('612x792', image) assert_signature( - 'b6c1ff99cefbe60f59f681fc7350a83b7a9734def84888472c0616b474cf9bca', + key_for_version({ + ['>= 1.19.0', '< 1.22.2'] => 'f82c26383f5213193151a4e647192c123f7c24228252228d5098120e8b2895fa', + '>= 1.22.2' => 'b6c1ff99cefbe60f59f681fc7350a83b7a9734def84888472c0616b474cf9bca', + }, mupdf_version), image ) end @@ -57,7 +63,10 @@ class PDFPluginTest < Minitest::Test assert_geometry('387x500', image) assert_signature( - '9571636ec1e7e74a3d5d2398258ab54f308aef79bca60451b3e4dabc9d7989c7', + key_for_version({ + ['>= 1.19.0', '< 1.22.2'] => '9e74391f349859ea0596e0f14380a69014f18f0c727749971bf4ddb2060df678', + '>= 1.22.2' => '9571636ec1e7e74a3d5d2398258ab54f308aef79bca60451b3e4dabc9d7989c7', + }, mupdf_version), image ) end diff --git a/test/bob_ross/plugins/video_test.rb b/test/bob_ross/plugins/video_test.rb index 14ce26a..2e28d2b 100644 --- a/test/bob_ross/plugins/video_test.rb +++ b/test/bob_ross/plugins/video_test.rb @@ -36,30 +36,30 @@ class VideoPluginTest < Minitest::Test image = BobRoss::VideoPlugin.transform(fixture('videos/world.mp4')) assert_geometry('640x360', image) - assert_signature( - 'fed332e73ca87a31749b6f27056fc271cc8efd0402315aed0fb7e938b919512a', - image - ) + assert_signature(value_for_versions({ + ['>= 4.4.2-0', '< 6.0'] => 'adb611d67ff335ab564e13b4a29daf5f19868588950afd00f2c874bdc92bc0f6', + ['>= 6.0'] => 'fed332e73ca87a31749b6f27056fc271cc8efd0402315aed0fb7e938b919512a' + }, ffmpeg_version), image) end test 'creates a thumbnail for the selected timestamp' do image = BobRoss::VideoPlugin.transform(fixture('videos/world.mp4'), {seek: 0}) assert_geometry('640x360', image) - assert_signature( - '1d3e16995c5dfadf73f67a5695c02f14b1cbae07ca168aaf79c9f0d728db44c8', - image - ) + assert_signature(value_for_versions({ + ['>= 4.4.2-0', '< 6.0'] => '5ff4311478633fb23f44ff1d6d16286baafb885531a86ddb2c7ccaf22fe4f52f', + ['>= 6.0'] => '1d3e16995c5dfadf73f67a5695c02f14b1cbae07ca168aaf79c9f0d728db44c8' + }, ffmpeg_version), image) end test 'creates a thumbnail for the selected percentage of movie' do image = BobRoss::VideoPlugin.transform(fixture('videos/world.mp4'), {seek: '100%'}) assert_geometry('640x360', image) - assert_signature( - '74c9aaaedbd064a5bbb71c65df3e42f9c56e4146ac5830147619cec39adbf8e9', - image - ) + assert_signature(value_for_versions({ + ['>= 4.4.2-0', '< 6.0'] => 'd1e07b1a1d504b30a6e6f01281bb647fab67a5b23b2ca369ca946531f85eff69', + ['>= 6.0'] => '74c9aaaedbd064a5bbb71c65df3e42f9c56e4146ac5830147619cec39adbf8e9' + }, ffmpeg_version), image) end end \ No newline at end of file diff --git a/test/bob_ross/server_test.rb b/test/bob_ross/server_test.rb index e482b5e..06b89d6 100644 --- a/test/bob_ross/server_test.rb +++ b/test/bob_ross/server_test.rb @@ -217,28 +217,51 @@ def create_server(configs={}) response = server.get("/flyer") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes key_for_version(key_for_backend(key_for_version({ - '>= 1.19.0' => { - im: { - '>= 7.1.1-21' => '7d5daa0941b10cb47277e954a77413b2' - }, - vips: { - '>= 8.15.0' => '2f4645b128d93f5d9304b79baabb9fdd' - } - } - }, mupdf_version))), Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 1.19.0', '< 1.22.2']] => 'c0e5d6b674ed162bfdd212cffad42585', + ['>= 7.1.1-21', ['>= 1.22.2']] => '7d5daa0941b10cb47277e954a77413b2' + }, vips: { + ['>= 8.15.0', ['>= 1.19.0', '< 1.22.2']] => 'c0bd56a48d4c81423ae926988d21c55f', + ['>= 8.15.0', ['>= 1.22.2']] => '2f4645b128d93f5d9304b79baabb9fdd' + }}), BobRoss.backend.version, mupdf_version + ), Digest::MD5.hexdigest(response.body) response = server.get("/S100/floorplan") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['592a7aed4be6c66f3deac77762153823', '2d0c2c8966dc484c540141f57ae73cae'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 1.19.0', '< 1.22.2']] => 'bab2943711de8adcf01a711983c52b15', + ['>= 7.1.1-21', ['>= 1.22.2']] => '592a7aed4be6c66f3deac77762153823' + }, vips: { + ['>= 8.15.0', ['>= 1.19.0', '< 1.22.2']] => 'fb65fd6089b9b01aa71a95f053cc09bb', + ['>= 8.15.0', ['>= 1.22.2']] => '2d0c2c8966dc484c540141f57ae73cae' + }}), BobRoss.backend.version, mupdf_version + ), Digest::MD5.hexdigest(response.body) response = server.get("/S50x50/floorplan") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['4bd78a3a3f7be88b2272b2697e10183b', '9863144037ac5cccca31b0d22304bf7b'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 1.19.0', '< 1.22.2']] => 'f6df84e2708d0add72f1e3d3e28098cb', + ['>= 7.1.1-21', ['>= 1.22.2']] => '4bd78a3a3f7be88b2272b2697e10183b' + }, vips: { + ['>= 8.15.0', ['>= 1.19.0', '< 1.22.2']] => 'e42bb91cf34a3cce419ffec9fbefec0e', + ['>= 8.15.0', ['>= 1.22.2']] => '9863144037ac5cccca31b0d22304bf7b' + }}), BobRoss.backend.version, mupdf_version + ), Digest::MD5.hexdigest(response.body) response = server.get("/Sx50/flyer") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['c7bb8896007fdc48fcb683a5533e5712', 'ff8552e8b6990d9b293c2c2c88bfa116'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 1.19.0', '< 1.22.2']] => 'c7bb8896007fdc48fcb683a5533e5712', + ['>= 7.1.1-21', ['>= 1.22.2']] => 'c7bb8896007fdc48fcb683a5533e5712' + }, vips: { + ['>= 8.15.0', ['>= 1.19.0', '< 1.22.2']] => '86b2fbe3f875ca59b77d9d1abaff0e2e', + ['>= 8.15.0', ['>= 1.22.2']] => 'ff8552e8b6990d9b293c2c2c88bfa116' + }}), BobRoss.backend.version, mupdf_version + ), Digest::MD5.hexdigest(response.body) end test 'a Video' do @@ -246,18 +269,50 @@ def create_server(configs={}) response = server.get("/video") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['dd0af2d65277b93f7c3de4007be21081', '76311e89661fc5d21828084271c08455'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 4.4.2-0', '< 6.0']] => 'f0b9194eafb984d4d4273c33570eb91b', + ['>= 7.1.1-21', ['>= 6.0']] => 'dd0af2d65277b93f7c3de4007be21081' + }, vips: { + ['>= 8.15.0', ['>= 4.4.2-0', '< 6.0']] => '85196b91ab4e189da1eef3fda9d7fce8', + ['>= 8.15.0', ['>= 6.0']] => '76311e89661fc5d21828084271c08455' + }}), BobRoss.backend.version, ffmpeg_version + ), Digest::MD5.hexdigest(response.body) response = server.get("/S100/video") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['549a9a3fff71f7ae5c135142a2885166', '351a240af0ec0db5758d5120abc73984'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 4.4.2-0', '< 6.0']] => '69f8bd89d373f45f6ee92cd8db8fa096', + ['>= 7.1.1-21', ['>= 6.0']] => '549a9a3fff71f7ae5c135142a2885166' + }, vips: { + ['>= 8.15.0', ['>= 4.4.2-0', '< 6.0']] => 'df8501dba59a7f5d34f26cf932b857e7', + ['>= 8.15.0', ['>= 6.0']] => '351a240af0ec0db5758d5120abc73984' + }}), BobRoss.backend.version, ffmpeg_version + ), Digest::MD5.hexdigest(response.body) response = server.get("/S50x50/video") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['f103fb67f500511bd29ec10c5205b40f', '87c98e63d160c2d15ff5aeec1ed866b7'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 4.4.2-0', '< 6.0']] => '9418f242fbbca265063ccef0b8313d71', + ['>= 7.1.1-21', ['>= 6.0']] => 'f103fb67f500511bd29ec10c5205b40f' + }, vips: { + ['>= 8.15.0', ['>= 4.4.2-0', '< 6.0']] => '8db0afaf7f747d2d6884e115e3f018a5', + ['>= 8.15.0', ['>= 6.0']] => '87c98e63d160c2d15ff5aeec1ed866b7' + }}), BobRoss.backend.version, ffmpeg_version + ), Digest::MD5.hexdigest(response.body) response = server.get("/Sx50/video") assert_equal 'image/jpeg', response.headers['Content-Type'] - assert_includes ['d462eac44ca95715b288c4e501dc1f7d', '2b00b06f58ede4e365e3f7e33e65df99'], Digest::MD5.hexdigest(response.body) + assert_equal value_for_versions(key_for_backend({ + im: { + ['>= 7.1.1-21', ['>= 4.4.2-0', '< 6.0']] => 'd462eac44ca95715b288c4e501dc1f7d', + ['>= 7.1.1-21', ['>= 6.0']] => 'd462eac44ca95715b288c4e501dc1f7d' + }, vips: { + ['>= 8.15.0', ['>= 4.4.2-0', '< 6.0']] => '448cb17829d0adf6e0326239cb3c32d5', + ['>= 8.15.0', ['>= 6.0']] => '2b00b06f58ede4e365e3f7e33e65df99' + }}), BobRoss.backend.version, ffmpeg_version + ), Digest::MD5.hexdigest(response.body) end end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index d899632..ae44799 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -53,10 +53,16 @@ def self.test(name, requires: nil, &block) end def mupdf_version - return @version if @version + return @mupdf_version if @mupdf_version version_cmd = Terrapin::CommandLine.new("mutool", '-v') version_cmd.run - @version = version_cmd.output.error_output.match(/version\s+(\S+)/)[1] + @mupdf_version = version_cmd.output.error_output.match(/version\s+([\d\.\-]+)/)[1] + end + + def ffmpeg_version + return @ffmpeg_version if @ffmpeg_version + version_cmd = Terrapin::CommandLine.new("ffmpeg", '-version') + @ffmpeg_version = version_cmd.run.match(/version\s+([\d\.\-]+)/)[1] end def wait_until @@ -94,16 +100,24 @@ def backend BobRoss.backend.key end + def value_for_versions(hash, *versions) + hash.find do |k,v| + if versions.size == 1 + Gem::Dependency.new('a', k).match?('a', versions[0].gsub('-', '.')) + else + k.zip(versions).to_h.all? do |key, version| + Gem::Dependency.new('a', key).match?('a', version.gsub('-', '.')) + end + end + end&.[](1) + end + def key_for_backend(hash, backend=nil) hash[backend || BobRoss.backend.key] end def key_for_version(hash, version=nil) - version ||= BobRoss.backend.version - - hash.find do |k,v| - Gem::Dependency.new('a', k).match?('a', version.gsub('-', '.')) - end&.[](1) + value_for_versions(hash, version || BobRoss.backend.version) end # exp is the signature or [IM sig, libvips sig]