Skip to content

Commit

Permalink
Setup wix CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-ne committed Feb 9, 2021
1 parent 4ac9f06 commit f0f6fe3
Show file tree
Hide file tree
Showing 110 changed files with 137 additions and 39 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM docker-repo.wixpress.com/com.wixpress.vips-base-image-from-source as builder

COPY . /govips
WORKDIR /govips

ENV GOOS linux
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH
ENV GOPATH /deps

RUN mkdir -p ~/.ssh/
RUN git config --global url."git@github.com:".insteadOf https://github.com/
RUN ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN mv deps /deps
RUN go test -race -v ./...
3 changes: 1 addition & 2 deletions examples/logging/example_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package package_test

import (
"fmt"
"github.com/wix-playground/govips/vips"
"io/ioutil"
"log"
"os"

"github.com/davidbyttow/govips/v2/vips"
)

/* govips example: how to modify logging by using your own log handler
Expand Down
3 changes: 1 addition & 2 deletions examples/tiff/example_tiff_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ package package_test

import (
"fmt"
"github.com/wix-playground/govips/vips"
"io/ioutil"
"os"

"github.com/davidbyttow/govips/v2/vips"
)

func checkError(err error) {
Expand Down
8 changes: 8 additions & 0 deletions get-dep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -x

git config --global url."git@github.com:".insteadOf https://github.com/
ssh-keyscan github.com >> ~/.ssh/known_hosts

GOPATH=`pwd`/deps go mod download

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/davidbyttow/govips/v2
module github.com/wix-playground/govips

go 1.15

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidbyttow/govips v0.0.0-20201026223743-b1b72c7305d9 h1:nXNjG6pGALu++DSxtrdO79AZhtU+jZnyMlq3FTkFH74=
github.com/davidbyttow/govips/v2 v2.4.0 h1:oAr8OI6JTJEZfFfznoOgMqlChEL8TPHSuB4hvyUqQ1w=
github.com/davidbyttow/govips/v2 v2.4.0/go.mod h1:goq38QD8XEMz2aWEeucEZqRxAWsemIN40vbUqfPfTAw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down
91 changes: 91 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.wixpress.prospero</groupId>
<artifactId>govips</artifactId>
<packaging>pom</packaging>
<name>govips</name>
<version>1.0.0-SNAPSHOT</version>
<description>wix-specific govips</description>
<url>http://www.wix.com</url>


<organization>
<name>Media Cloud</name>
</organization>

<developers>
<developer>
<name>Idan Yael</name>
<email>idany@wix.com</email>
<roles>
<role>owner</role>
</roles>
</developer>
<developer>
<name>Elad laufer</name>
<email>elad@wix.com</email>
<roles>
<role>owner</role>
</roles>
</developer>
<developer>
<name>Alon Neubach</name>
<email>alonne@wix.com</email>
<roles>
<role>owner</role>
</roles>
</developer>
</developers>

<scm>
<developerConnection>scm:git:ssh://git@github.com:wix-playground/govips.git
</developerConnection>
<url>scm:git:ssh://git@github.com:wix-playground/govips.git</url>
</scm>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>get-dep</id>
<phase>test</phase>
<configuration>
<executable>get-dep.sh</executable>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</build>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>com.wixpress.prospero</groupId>-->
<!-- <artifactId>mcloud-go-framework</artifactId>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>com.wixpress.vips-base-image</groupId>-->
<!-- <artifactId>vips-base-image</artifactId>-->
<!-- </dependency>-->
</dependencies>
</project>
Binary file modified resources/bmp.Decode_BMP-macos-10.golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/bmp.Decode_BMP-macos-11.golden.png
Binary file not shown.
Binary file modified resources/heic-24bit-exif.RemoveMetadata-macos-10.golden.heic
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/jpg-24bit-icc-iec.AutoRotate_1-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/jpg-24bit-icc-iec.ExtractArea-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/jpg-24bit-icc-iec.Modulate-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/jpg-24bit-icc-iec.ModulateHSV-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/jpg-24bit-icc-iec.Rotate-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified resources/jpg-24bit.Add-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/jpg-24bit.Add-macos-11.golden.jpeg
Binary file not shown.
Binary file modified resources/jpg-24bit.BandJoinConst-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed resources/jpg-24bit.Black-macos-11.golden.jpeg
Binary file not shown.
Binary file modified resources/jpg-24bit.Decode_JPG-macos-10.golden.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/jpg-24bit.Decode_JPG-macos-11.golden.jpeg
Binary file not shown.
Binary file modified resources/jpg-24bit.DrawRect-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.DrawRect-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.DrawRectRGBA-macos-10.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Embed-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.Embed-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Flip-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.Flip-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.GaussianBlur-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.GaussianBlur-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Invert-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.Invert-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Multiply-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.Multiply-macos-11.golden.jpeg
Diff not rendered.
Diff not rendered.
Binary file modified resources/jpg-24bit.ResizeWithVScale-macos-10.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Resize_Downscale-macos-10.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Resize_Upscale-macos-10.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.SimilarityRGB-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.SimilarityRGB-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.SimilarityRGBA-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.SimilarityRGBA-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.SmartCrop-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.SmartCrop-macos-11.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.TestImageRef_Divide-macos-10.golden.jpeg
Diff not rendered.
Binary file modified resources/jpg-24bit.Zoom-macos-10.golden.jpeg
Binary file removed resources/jpg-24bit.Zoom-macos-11.golden.jpeg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified resources/jpg-orientation-5.AutoRotate_5-macos-10.golden.jpeg
Diff not rendered.
Diff not rendered.
Binary file modified resources/jpg-orientation-6.AutoRotate_6-macos-10.golden.jpeg
Diff not rendered.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified resources/png-24bit+alpha.ModulateHSV_Alpha-macos-10.golden.png
Diff not rendered.
Binary file modified resources/png-24bit+alpha.Modulate_Alpha-macos-10.golden.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified resources/png-8bit+alpha.Resize_Downscale_Alpha-macos-10.golden.png
Diff not rendered.
Binary file modified resources/png-8bit+alpha.Resize_Upscale_Alpha-macos-10.golden.png
Diff not rendered.
Binary file modified resources/png-8bit+alpha.Sharpen_8bit_Alpha-macos-10.golden.png
Diff not rendered.
Binary file modified resources/png-8bit.Decode_PNG-macos-10.golden.png
Binary file removed resources/png-8bit.Decode_PNG-macos-11.golden.png
Diff not rendered.
Binary file modified resources/tif.Tiff-macos-10.golden.tiff
Binary file not shown.
Binary file removed resources/tif.Tiff-macos-11.golden.tiff
Binary file not shown.
Binary file removed resources/with_alpha.ExtractBand-macos-11.golden.png
Diff not rendered.
Binary file removed resources/with_alpha.Flatten-macos-11.golden.png
Diff not rendered.
53 changes: 19 additions & 34 deletions vips/image_golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package vips

import (
"bytes"
"fmt"
"image"
jpeg2 "image/jpeg"
"image/png"
"io/ioutil"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
Expand Down Expand Up @@ -214,7 +212,7 @@ func TestImage_AutoRotate_6__heic_to_jpg(t *testing.T) {
}, NewDefaultJPEGExportParams())
}

func TestImage_Sharpen_Luminescence_24bit_Alpha(t *testing.T) {
func TestImage_Sharpen_24bit_Alpha(t *testing.T) {
goldenTest(t, resources+"png-24bit+alpha.png", func(img *ImageRef) error {
//usm_0.66_1.00_0.01
sigma := 1 + (0.66 / 2)
Expand All @@ -225,7 +223,7 @@ func TestImage_Sharpen_Luminescence_24bit_Alpha(t *testing.T) {
}, nil, nil)
}

func TestImage_Sharpen_RGB_24bit_Alpha(t *testing.T) {
func TestImage_Sharpen_8bit_Alpha(t *testing.T) {
goldenTest(t, resources+"png-8bit+alpha.png", func(img *ImageRef) error {
//usm_0.66_1.00_0.01
sigma := 1 + (0.66 / 2)
Expand Down Expand Up @@ -592,46 +590,33 @@ func getEnvironment() string {
// default to linux assets otherwise
return "linux"
}
func assertGoldenMatch(t *testing.T, imagePath string, imageData []byte, format ImageType) {
imagePath, err := filepath.Abs(imagePath)
panicOnError(err)

dotIndex := strings.LastIndex(imagePath, ".")
if dotIndex < 0 {
func assertGoldenMatch(t *testing.T, file string, buf []byte, format ImageType) {
i := strings.LastIndex(file, ".")
if i < 0 {
panic("bad filename")
}

testName := strings.Replace(t.Name(), "/", "_", -1)
testName = strings.Replace(testName, "TestImage_", "", -1)
prefix := imagePath[:dotIndex] + "." + testName
name := strings.Replace(t.Name(), "/", "_", -1)
name = strings.Replace(name, "TestImage_", "", -1)
prefix := file[:i] + "." + name
ext := format.FileExt()
goldenPath, err := filepath.Abs(prefix + ".golden" + ext)
panicOnError(err)

expectedData, _ := ioutil.ReadFile(goldenPath)
if expectedData != nil {
if !bytes.Equal(expectedData, imageData) {
failedPath := prefix + ".failed" + ext
assert.Fail(t, "Output not equal to golden result",
"expected\t%v (%v bytes)\n"+
"but got\t\t%v (%v bytes)",
goldenPath, len(expectedData), failedPath, len(imageData))
fmt.Printf("To diff and prompt to replace golden file: ./diff-replace-golden.sh %v %v\n", goldenPath, failedPath)
err := ioutil.WriteFile(failedPath, imageData, 0666)
goldenFile := prefix + "-" + getEnvironment() + ".golden" + ext

golden, _ := ioutil.ReadFile(goldenFile)
if golden != nil {
sameAsGolden := assert.True(t, bytes.Equal(buf, golden), "Actual image (size=%d) didn't match expected golden file=%s (size=%d)", len(buf), goldenFile, len(golden))
if !sameAsGolden {
failed := prefix + "-" + getEnvironment() + ".failed" + ext
err := ioutil.WriteFile(failed, buf, 0666)
if err != nil {
panic(err)
}
}
return
}

t.Log("writing golden file: " + goldenPath)
err = ioutil.WriteFile(goldenPath, imageData, 0644)
panicOnError(err)
}

func panicOnError(err error) {
if err != nil {
panic(err)
}
t.Log("writing golden file: " + goldenFile)
err := ioutil.WriteFile(goldenFile, buf, 0644)
assert.NoError(t, err)
}

0 comments on commit f0f6fe3

Please sign in to comment.