Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action to produce all artifacts #27

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Windows Native Artifact Build

on:
push:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
build-win64:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install SWIG
run: cinst swig

- name: Run SWIG
run: |
mkdir java\target\swig\ome\jxrlib
swig.exe -java -c++ -package ome.jxrlib -outdir java\target\swig\ome\jxrlib -o java\target\swig\JXR_wrap.cxx java\JXR.i

- name: Add msbuild to PATH
uses: microsoft/[email protected]

- name: Build native code
run: msbuild jxrencoderdecoder\JXR_vc16.sln /p:Configuration=Release /p:Platform="x64"

- name: Build native artifacts
run: mvn -f java\native-windows_64\pom.xml package

- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-win64
path: java\native-windows_64\target\*.jar

build-linux64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install SWIG
run: sudo apt-get install -y swig

- name: Run SWIG
run: make swig

- name: Build native code
run: |
docker build -f Dockerfile2010 . -t native_builder
docker run -v $(pwd):/jxrlib --user ${UID} -t native_builder make -C /jxrlib

- name: Run tests
run: |
export LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/build
cd build
mkdir -p transcoded/C/ transcoded/C++/ transcoded/Java/
# Test base jxrlib C library
for input in ../fixtures/first-tiles/*; do
basename=${input##*/};
basename=${bn%.jxr};
./JxrDecApp -i "$input" -o "transcoded/C/$basename.tif";
./jxrdecode "$input" "transcoded/C++/$basename.tif";
./jxrdecode --in-memory "$input";
done
# Test jxrlib Java bindings (in memory and file to file)
mvn -f ../java/pom.xml test
# Testing was successful
cd ${GITHUB_WORKSPACE}
mvn -f java/native-linux_64 package;

- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-linux64
path: java/native-linux_64/target/*.jar

build-macos:
runs-on: macos-latest
env:
DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install SWIG
run: brew install swig

- name: Build native code
run: |
make clean swig all
mkdir -p ${HOME}/Library/Java/Extensions
cp build/*.dylib ${HOME}/Library/Java/Extensions

- name: Run tests
run: |
cd build
mkdir -p transcoded/C/ transcoded/C++/ transcoded/Java/
# Test base jxrlib C library
for input in ../fixtures/first-tiles/*; do
basename=${input##*/};
basename=${bn%.jxr};
./JxrDecApp -i "$input" -o "transcoded/C/$basename.tif";
./jxrdecode "$input" "transcoded/C++/$basename.tif";
./jxrdecode --in-memory "$input";
done
# Test jxrlib Java bindings (in memory and file to file)
mvn -f ../java/pom.xml test
# Testing was successful
cd ${GITHUB_WORKSPACE}
mvn -f java/native-osx_64 package;

- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-macos
path: java/native-osx_64/target/*.jar

build-all:
runs-on: ubuntu-latest
needs: [build-win64, build-linux64, build-macos]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Download native artifacts
uses: actions/download-artifact@v2

- name: Install artifacts in local Maven repository
run: |
for jar in artifacts*/*.jar; do
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=${jar}
done

- name: Build all artifact
run: mvn -f java/all/pom.xml package install

- name: Run tests
run: |
gradle -b java/cli/build.gradle install
mkdir -p build/transcoded/C/ build/transcoded/C++/ build/transcoded/Java/
export EXT="tif"
export IFS="
"

for input in fixtures/first-tiles/*; do
output=$(basename "$input")
output=$(basename "$output" .jxr)
java/cli/build/install/cli/bin/cli --in-memory "$input" "build/transcoded/Java/in-memory-$output.$EXT"
done

- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts-all
path: java/all/target/*.jar
6 changes: 6 additions & 0 deletions Dockerfile2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Dockerfile for lowest common denominator Linux native artifact build
# --------------------------------------------------------------------
# Cribbed from TileDB-Java/ci/Dockerfile2010
FROM quay.io/pypa/manylinux2010_x86_64

RUN yum install -y java-1.8.0-openjdk-devel
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ CXX_LIBRARIES=$(CXX_STATIC_LIBRARIES)
endif

LIBS=-L$(DIR_BUILD) $(shell echo $(LIBRARIES) | sed -E 's%$(DIR_BUILD)/lib([^ ]*)\.(a|$(LIBSUFFIX))%-l\1%g') -lm
CXXLIBS=-L$(DIR_BUILD) -ljxr++ -lcrypto
CXXLIBS=-L$(DIR_BUILD) -ljxr++

##--------------------------------
##
Expand Down
30 changes: 4 additions & 26 deletions cpp/jxrdecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include <string>
#include <sstream>

#include <openssl/md5.h>

#include "windowsmediaphoto.h"

#include "CodecFactory.hpp"
Expand All @@ -40,20 +38,6 @@

using namespace jxrlib;

template<typename T>
static std::string md5(std::vector<T> bytes, size_t offset) {
std::vector<unsigned char> md5_bytes(MD5_DIGEST_LENGTH);
MD5(
(const unsigned char *)bytes.data() + offset,
bytes.size() - offset,
md5_bytes.data());
std::stringstream ss;
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
ss << std::hex << (int)md5_bytes[i];
}
return ss.str();
}

void stream_data() {
Factory factory;
CodecFactory codecFactory;
Expand All @@ -64,8 +48,6 @@ void stream_data() {
bytes.push_back(val);
}

std::cerr << "Read bytes MD5: " << md5(bytes, 0) << std::endl;

ImageDecoder decoder;
codecFactory.decoderFromBytes(decoder, bytes);
std::cerr << "Opened decoder with " << bytes.size() << " bytes" << std::endl;
Expand All @@ -81,8 +63,7 @@ void stream_data() {
decoder.selectFrame(i);
decoder.getRawBytes(decodedBytes.data());

std::cerr << decodedBytes.size() << " Bytes MD5: " << md5(decodedBytes, 0)
<< std::endl;
std::cerr << decodedBytes.size() << " Bytes" << std::endl;
}
}

Expand All @@ -96,8 +77,6 @@ void stream_file_bytes(std::string inputFile, size_t offset) {
input.seekg(0, std::ios::beg);
input.read(bytes.data() + offset, length);

std::cerr << "Read bytes MD5: " << md5(bytes, offset) << std::endl;

Factory factory;
CodecFactory codecFactory;

Expand All @@ -117,8 +96,7 @@ void stream_file_bytes(std::string inputFile, size_t offset) {
decoder.selectFrame(i);
decoder.getRawBytes(decodedBytes.data());

std::cerr << decodedBytes.size() << " Bytes MD5: " << md5(decodedBytes, 0)
<< std::endl;
std::cerr << decodedBytes.size() << " Bytes" << std::endl;
}
}

Expand All @@ -141,7 +119,7 @@ void stream_file(std::string inputFile) {
decoder.selectFrame(i);
decoder.getRawBytes(bytes.data());

std::cerr << bytes.size() << " Bytes MD5: " << md5(bytes, 0) << std::endl;
std::cerr << bytes.size() << " Bytes" << std::endl;
}
}

Expand All @@ -164,7 +142,7 @@ void stream_file(std::string inputFile, long offset) {
decoder.selectFrame(i);
decoder.getRawBytes(bytes.data());

std::cerr << bytes.size() << " Bytes MD5: " << md5(bytes, 0) << std::endl;
std::cerr << bytes.size() << " Bytes" << std::endl;
}
}

Expand Down
Loading