mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-06-06 05:49:01 +08:00
update CI
This commit is contained in:
31
.github/workflows/CI.yml
vendored
31
.github/workflows/CI.yml
vendored
@@ -21,3 +21,34 @@ jobs:
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
build-exif:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check Out
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
- name: Get cache key
|
||||
id: cache_key
|
||||
run: |
|
||||
cd scripts
|
||||
python3 get_cache_key.py exiv2 || exit 1
|
||||
- name: Cache
|
||||
id: cache
|
||||
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_exiv2.sh || exit 1
|
||||
- name: Build
|
||||
run: |
|
||||
export CMAKE_PREFIX_PATH=`pwd`/clib
|
||||
cargo build --features exif --verbose || exit 1
|
||||
- name: Test
|
||||
run: |
|
||||
export CMAKE_PREFIX_PATH=`pwd`/clib
|
||||
cargo test --features exif --verbose -- --show-output || exit 1
|
||||
|
||||
3
scripts/README.md
Normal file
3
scripts/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Usage
|
||||
[build_exiv2.sh](build_exiv2.sh): Used to build thirdparty library.
|
||||
[get_cache_key.py](get_cache_key.py): Used to get cache's key which used in [action/cache](https://github.com/actions/cache).
|
||||
6
scripts/build_exiv2.sh
Normal file
6
scripts/build_exiv2.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
export PREFIX=`pwd`/clib
|
||||
mkdir -p cbuild && cd cbuild || exit 1
|
||||
git clone --depth 1 'https://github.com/Exiv2/exiv2' && cd exiv2 || exit 1
|
||||
mkdir -p build && cd build || exit 1
|
||||
cmake -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$PREFIX" ../ || exit 1
|
||||
make -j8 && make install || exit 1
|
||||
37
scripts/get_cache_key.py
Normal file
37
scripts/get_cache_key.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from argparse import ArgumentParser
|
||||
from hashlib import sha256 as _sha256
|
||||
import sys
|
||||
from time import gmtime, time, strftime
|
||||
from typing import List
|
||||
|
||||
|
||||
ALL_FEATURES = ['exiv2']
|
||||
|
||||
def sha256(data) -> str:
|
||||
if isinstance(data, str):
|
||||
data = data.encode()
|
||||
elif not isinstance(data, bytes):
|
||||
data = str(data).encode()
|
||||
s = _sha256()
|
||||
s.update(data)
|
||||
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
|
||||
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}"
|
||||
print(f"::set-output name=cache_key::{sha256(d)}")
|
||||
except Exception:
|
||||
from traceback import print_exc
|
||||
from sys import exit
|
||||
print_exc()
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user