add CI build for ugoira feature

This commit is contained in:
2022-03-19 18:04:26 +08:00
parent 0ddcd7d533
commit 44208c3ff2
5 changed files with 70 additions and 3 deletions

View File

@@ -54,3 +54,38 @@ jobs:
export CMAKE_PREFIX_PATH=`pwd`/clib
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/clib/lib"
cargo test --features exif --verbose -- --show-output || exit 1
build-ugoira:
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Get cache key
id: cache_key
run: |
cd scripts
python3 get_cache_key.py libzip x264 ffmpeg || exit 1
- name: Cache
id: cache
uses: actions/cache@v2
with:
path: clib/
key: ${{ runner.os }}-${{ steps.cache_key.outputs.cache_key }}
- name: Build thirdparty library
if: steps.cache.outputs.cache-hit != 'true'
run: |
cp scripts/build_*.sh -v ./ || exit 1
./build_libzip.sh || exit 1
./build_x264.sh || exit 1
./build_ffmpeg.sh || exit 1
- name: Build
run: |
export CMAKE_PREFIX_PATH=`pwd`/clib
cargo build --features ugoira -vv || exit 1
- name: Test
run: |
export CMAKE_PREFIX_PATH=`pwd`/clib
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/clib/lib"
cargo test --features ugoira --verbose -- --show-output || exit 1

5
scripts/build_ffmpeg.sh Executable file
View File

@@ -0,0 +1,5 @@
export PREFIX=`pwd`/clib
mkdir -p cbuild && cd cbuild || exit 1
git clone --depth 1 'https://git.ffmpeg.org/ffmpeg.git' && cd ffmpeg || exit 1
./configure "--prefix=${PREFIX}" --enable-shared --disable-static --enable-gpl --enable-version3 --disable-doc --enable-libx264 || exit 1
make -j8 && make install || exit 1

6
scripts/build_libzip.sh Executable file
View File

@@ -0,0 +1,6 @@
export PREFIX=`pwd`/clib
mkdir -p cbuild && cd cbuild || exit 1
git clone --depth 1 'https://github.com/nih-at/libzip' && cd libzip || exit 1
mkdir -p build && cd build || exit 1
cmake -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PREFIX" -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF ../ || exit 1
make -j8 && make install || exit 1

5
scripts/build_x264.sh Executable file
View File

@@ -0,0 +1,5 @@
export PREFIX=`pwd`/clib
mkdir -p cbuild && cd cbuild || exit 1
git clone --depth 1 'https://code.videolan.org/videolan/x264.git' && cd x264 || exit 1
./configure "--prefix=${PREFIX}" --disable-cli --enable-strip --enable-pic || exit 1
make -j8 && make install || exit 1

View File

@@ -1,11 +1,12 @@
from argparse import ArgumentParser
from hashlib import sha256 as _sha256
from os.path import exists
import sys
from time import gmtime, time, strftime
from typing import List
ALL_FEATURES = ['exiv2']
ALL_FEATURES = ['exiv2', 'ffmpeg', 'libzip', 'x264']
def sha256(data) -> str:
if isinstance(data, str):
@@ -17,18 +18,33 @@ def sha256(data) -> str:
return s.hexdigest()
def hash_file(feature) -> str:
fn = f"build_{feature}.sh"
if not exists(fn):
return ''
with open(fn, 'rb') as f:
c = f.read(256)
s = _sha256()
while len(c) > 0:
s.update(c)
c = f.read(256)
return s.hexdigest()
try:
p = ArgumentParser(description='Get the cache key which used in action/cache')
p.add_argument("features", help="The feature's name", action='append', nargs='+', choices=['all'] + ALL_FEATURES)
args = p.parse_intermixed_args(sys.argv[1:])
features: List[str] = args.features
features: List[str] = args.features[0]
if 'all' in features:
features = ALL_FEATURES.copy()
d = ''
now = time()
for i in features:
dt = strftime('%Y-%m', gmtime(now))
d += f"i={dt}"
h = hash_file(i)
d += f"{i}={dt}:{h}\n"
print(d)
print(f"::set-output name=cache_key::{sha256(d)}")
except Exception:
from traceback import print_exc