Skip to content

Commit

Permalink
Test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tunmx committed May 5, 2024
1 parent 325bf7a commit 13a9cdd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/test_ubuntu_x86_Pikachu.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
# This GitHub Actions workflow is designed for a CMake project running on a single platform (Ubuntu-x86).
# For multi-platform testing, see the link provided.
# Refer to: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Run Ubuntu-x86 Test Pikachu

# Trigger this workflow on push or pull request to the "feature/sub" branch
on:
push:
branches: [ "feature/sub" ]
branches: ["feature/sub"]
pull_request:
branches: [ "feature/sub" ]
branches: ["feature/sub"]

# Define environment variables shared across jobs
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
# Set the CMake build type (e.g., Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

# Jobs section defines all individual tasks for the CI workflow
jobs:
build:
# 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
# Specify that this job should run on the latest Ubuntu environment provided by GitHub
runs-on: ubuntu-latest

# Define steps for this job
steps:
# Step 1: Check out the code from the repository
- uses: actions/checkout@v4

# Step 2: Update Git submodules recursively
- name: Update submodules
run: |
git submodule sync --recursive
git submodule update --init --recursive
git submodule sync --recursive # Ensure submodule paths are up-to-date
git submodule update --init --recursive # Initialize and update all submodules
# Step 3: Install necessary dependencies for building the CMake project
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get update # Update package lists
# Install build tools and required libraries for video processing
sudo apt-get install -y build-essential libgtk-3-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev
# Step 4: Run a separate script for CMake configuration and building
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
# Execute a pre-existing script to handle CMake configuration and building
# The script is assumed to be located at `ci/ci_linux_x86_usual.sh`
run: bash ci/ci_linux_x86_usual.sh

22 changes: 18 additions & 4 deletions ci/ci_linux_x86_usual.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

set -e # If the command fails to execute, exit immediately
# Exit immediately if any command exits with a non-zero status
set -e

TARGET_DIR="test_res"
DOWNLOAD_URL="https://github.com/tunmx/inspireface-store/raw/main/resource/test_res-lite.zip"
Expand All @@ -9,15 +10,18 @@ BUILD_DIRNAME="ci_ubuntu18"
TEST_DIR="./build/${BUILD_DIRNAME}/test"
TEST_EXECUTABLE="./test/Test"

# Check whether the directory exists
# Check if the target directory already exists
if [ ! -d "$TARGET_DIR" ]; then
echo "Directory '$TARGET_DIR' does not exist. Downloading..."

# Download the dataset zip file
wget -q "$DOWNLOAD_URL" -O "$ZIP_FILE"

echo "Extracting '$ZIP_FILE' to '$TARGET_DIR'..."
# Unzip the downloaded file
unzip "$ZIP_FILE"

# Remove the downloaded zip file and unnecessary folders
rm "$ZIP_FILE"
rm -rf "__MACOSX"

Expand All @@ -26,12 +30,18 @@ else
echo "Directory '$TARGET_DIR' already exists. Skipping download."
fi

# Get the absolute path of the target directory
FULL_TEST_DIR="$(realpath ${TARGET_DIR})"

# Create the build directory if it doesn't exist
mkdir -p build/${BUILD_DIRNAME}/

# Change directory to the build directory
# Disable the shellcheck warning for potential directory changes
# shellcheck disable=SC2164
cd build/${BUILD_DIRNAME}/

# Configure the CMake build system
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=ON \
Expand All @@ -41,15 +51,19 @@ cmake -DCMAKE_BUILD_TYPE=Release \
-DOpenCV_DIR=3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 \
-DISF_BUILD_SHARED_LIBS=OFF ../../

# Compile the project using 4 parallel jobs
make -j4

# Create a symbolic link to the extracted test data directory
ln -s ${FULL_TEST_DIR} .

# Check if the test executable file exists
if [ ! -f "$TEST_EXECUTABLE" ]; then
# If not, print an error message and exit with a non-zero status code
echo "Error: Test executable '$TEST_EXECUTABLE' not found. Please ensure it is built correctly."
exit 1 # Exit with a non-zero status code to indicate an error
exit 1
else
# If it exists, print a message and run the test executable
echo "Test executable found. Running tests..."
"$TEST_EXECUTABLE"
fi

0 comments on commit 13a9cdd

Please sign in to comment.