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 automatic tests #88

Merged
merged 7 commits into from
Feb 10, 2022
Merged
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
114 changes: 114 additions & 0 deletions .github/workflows/autotest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# This is a basic workflow to help you get started with Actions

name: autotest

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
autotest:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: macos-latest

steps:
- name: Get environment cache
id: cache-environment
uses: actions/cache@v2
with:
path: |
/usr/local/Cellar/ninja
/usr/local/bin/ninja
/usr/local/Cellar/node
/usr/local/bin/node
/usr/local/Cellar/emscripten
/usr/local/bin/emscripten
/usr/local/Cellar/yasm
/usr/local/bin/yasm
/usr/local/Cellar/depsync
/usr/local/bin/depsync
key: libpag-environment-20220208
- if: github.event_name == 'push'
name: Get libpag cache (push)
id: libpag-push
uses: actions/cache@v2
with:
path: libpag.tar.zst
key: libpag-code-${{ github.sha }}
restore-keys: |
libpag-code-${{ github.event.before }}
libpag-code-
- if: github.event_name == 'pull_request'
name: Get libpag cache (pull_request)
id: libpag-pull_request
uses: actions/cache@v2
with:
path: libpag.tar.zst
key: libpag-code-${{ github.event.pull_request.base.sha }}
restore-keys: libpag-code-
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "libpag.tar.zst"
- name: File exist
if: steps.check_files.outputs.files_exists == 'true'
# Only runs if all of the files exists
run: |
echo "file exist"
tar xvf libpag.tar.zst
rm -rf libpag.tar.zst
- name: File not exist
if: steps.check_files.outputs.files_exists != 'true'
run: |
echo "file not exist"
git clone -b main https://github.com/Tencent/libpag.git
- if: github.event_name == 'pull_request'
name: swith branch (pull_request)
run: |
cd libpag
git pull
git checkout ${{ github.head_ref }}
- if: github.event_name == 'push'
name: swith branch (push)
run: |
cd libpag
git pull
- name: brew link emscripten
if: steps.cache-third_party.outputs.cache-hit == 'true'
run: |
brew link emscripten

- name: Run autotest script
run: |
ls
cd libpag
chmod +x sync_deps.sh
./sync_deps.sh
chmod +x autotest.sh
./autotest.sh
shell: bash
- name: The job has failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: result
path: libpag/result
- uses: actions/upload-artifact@v2
with:
name: result
path: result
- name: Compress libpag
run: |
cd libpag
rm -rf result
git checkout main
cd ..
tar cvfa libpag.tar.zst libpag

96 changes: 96 additions & 0 deletions autotest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash

function make_dir() {
rm -rf $1
mkdir -p $1
}
echo "shell log - autotest start begin "
if [[ `uname` == 'Darwin' ]]; then
MAC_REQUIRED_TOOLS="gcovr"
for TOOL in ${MAC_REQUIRED_TOOLS[@]}; do
if [ ! $(which $TOOL) ]; then
if [ ! $(which brew) ]; then
echo "Homebrew not found. Trying to install..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ||
exit 1
fi
echo "$TOOL not found. Trying to install..."
brew install $TOOL || exit 1
fi
done
fi

echo `pwd`

COMPLIE_RESULT=true

WORKSPACE=$(pwd)

cd $WORKSPACE

make_dir result
make_dir build

cd build

cmake -DCMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage -g -O0" -DSMOKE_TEST=ON -DCMAKE_BUILD_TYPE=Debug ../
if test $? -eq 0
then
echo "~~~~~~~~~~~~~~~~~~~CMakeLists OK~~~~~~~~~~~~~~~~~~"
else
echo "~~~~~~~~~~~~~~~~~~~CMakeLists error~~~~~~~~~~~~~~~~~~"
exit
fi

cmake --build . --target PAGFullTest -- -j 12
if test $? -eq 0
then
echo "~~~~~~~~~~~~~~~~~~~PAGFullTest make successed~~~~~~~~~~~~~~~~~~"
else
echo "~~~~~~~~~~~~~~~~~~~PAGFullTest make error~~~~~~~~~~~~~~~~~~"
exit 1
fi

cmake --build . --target PAGSmokeTest -- -j 12
if test $? -eq 0
then
echo "~~~~~~~~~~~~~~~~~~~PAGSmokeTest make successed~~~~~~~~~~~~~~~~~~"
else
echo "~~~~~~~~~~~~~~~~~~~PAGSmokeTest make error~~~~~~~~~~~~~~~~~~"
exit 1
fi

./PAGFullTest --gtest_output=json:PAGFullTest.json

if test $? -eq 0
then
echo "~~~~~~~~~~~~~~~~~~~PAGFullTest successed~~~~~~~~~~~~~~~~~~"
else
echo "~~~~~~~~~~~~~~~~~~~PAGFullTest Failed~~~~~~~~~~~~~~~~~~"
COMPLIE_RESULT=false
fi

./PAGSmokeTest --gtest_output=json:PAGSmokeTest.json
if test $? -eq 0
then
echo "~~~~~~~~~~~~~~~~~~~PAGSmokeTest successed~~~~~~~~~~~~~~~~~~"
else
echo "~~~~~~~~~~~~~~~~~~~PAGSmokeTest Failed~~~~~~~~~~~~~~~~~~"
COMPLIE_RESULT=false
fi

cp -a $WORKSPACE/build/*.json $WORKSPACE/result/

cd ..

gcovr -r . -e='test/*.*' -e='vendor/*.*'--html -o ./result/coverage.html
gcovr -r . -e='test/*.*' -e='vendor/*.*' --xml-pretty -o ./result/coverage.xml

rm -rf build

if [ "$COMPLIE_RESULT" == false ]
then
cp -a $WORKSPACE/test/out/baseline/**/*.lzma2 $WORKSPACE/result/
cp -a $WORKSPACE/test/out/compare/*.webp $WORKSPACE/result/
exit 1
fi