-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature]: Add shell script for installation and workflows for testing (
#131)
- Loading branch information
Showing
3 changed files
with
245 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Test Install Script | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- test-install-script | ||
paths: | ||
- '.github/workflows/test-install-script.yml' | ||
- 'install.sh' | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/test-install-script.yml' | ||
- 'install.sh' | ||
|
||
jobs: | ||
linux: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, ubuntu-22.04, archlinux] | ||
include: | ||
- os: ubuntu-latest | ||
image: ubuntu:latest | ||
- os: ubuntu-22.04 | ||
image: ubuntu:22.04 | ||
- os: archlinux | ||
image: archlinux:latest | ||
|
||
name: ${{ matrix.os }} | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ${{ matrix.image }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Make install.sh Executable | ||
run: chmod +x install.sh | ||
|
||
- name: Run Installation Script | ||
run: ./install.sh | ||
|
||
|
||
wsl: | ||
name: WSL | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up WSL2 | ||
uses: vedantmgoyal9/setup-wsl2@main | ||
|
||
- name: Install dos2unix and Convert Line Endings | ||
run: | | ||
wsl sudo apt update -y | ||
wsl sudo apt install dos2unix -y | ||
wsl dos2unix "/mnt/d/a/Pixels_Seminar/Pixels_Seminar/install.sh" # Convert line endings | ||
- name: Make Executable and Run Script | ||
run: | | ||
wsl chmod +x "/mnt/d/a/Pixels_Seminar/Pixels_Seminar/install.sh" | ||
wsl bash "/mnt/d/a/Pixels_Seminar/Pixels_Seminar/install.sh" # Run the script | ||
macos: | ||
name: MacOS Latest | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Make install.sh Executable | ||
run: chmod +x install.sh | ||
|
||
- name: Run Installation Script | ||
run: ./install.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Function to check if a command exists | ||
command_exists() { | ||
command -v "$1" &>/dev/null | ||
} | ||
|
||
# Detect OS | ||
OS="" | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
if grep -qE "debian|ubuntu" /etc/os-release; then | ||
OS="debian" | ||
elif grep -q "arch" /etc/os-release; then | ||
OS="arch" | ||
fi | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
OS="macos" | ||
elif grep -q "WSL" /proc/version &>/dev/null; then | ||
OS="wsl" | ||
fi | ||
|
||
# Ensure sudo is installed (for CI or minimal environments) | ||
if ! command_exists sudo; then | ||
echo "sudo is not installed. Installing sudo..." | ||
case "$OS" in | ||
"debian" | "wsl") | ||
su -c "apt update && apt install sudo -y" | ||
;; | ||
"arch") | ||
su -c "pacman -Sy --noconfirm sudo" | ||
;; | ||
*) | ||
echo "Unsupported OS for automatic sudo installation. Please install manually." | ||
exit 1 | ||
;; | ||
esac | ||
fi | ||
|
||
# Ensure Git is installed | ||
if ! command_exists git; then | ||
echo "Git is not installed. Installing Git..." | ||
case "$OS" in | ||
"debian" | "wsl") | ||
sudo apt update && sudo apt install -y git | ||
;; | ||
"arch") | ||
sudo pacman -Sy --noconfirm git | ||
;; | ||
"macos") | ||
brew install git | ||
;; | ||
*) | ||
echo "Unsupported OS. Please install Git manually." | ||
exit 1 | ||
;; | ||
esac | ||
fi | ||
|
||
if [ ! -d "Pixels_Seminar" ]; then | ||
echo "Cloning the repository..." | ||
git clone https://github.com/SRA-VJTI/Pixels_Seminar.git | ||
fi | ||
|
||
cd Pixels_Seminar | ||
|
||
# Check if OpenCV is installed | ||
if pkg-config --exists opencv4 sdl2; then | ||
echo "OpenCV is already installed." | ||
exit 0 | ||
else | ||
echo "OpenCV not found. Installing dependencies..." | ||
fi | ||
|
||
# Install dependencies based on OS | ||
case "$OS" in | ||
"debian" | "wsl") | ||
echo "🔹 Detected Debian/Ubuntu or WSL" | ||
|
||
# Install sudo if not available (for containers) | ||
if ! command_exists sudo; then | ||
su -c "apt update && apt install sudo -y" | ||
fi | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime | ||
apt-get install -y tzdata | ||
dpkg-reconfigure --frontend noninteractive tzdata | ||
|
||
# Install pkg-config and OpenCV dependencies | ||
sudo apt update -y | ||
sudo apt install -y pkg-config build-essential make g++ git libopencv-dev libsdl2-2.0-0 libsdl2-image-dev libsdl2-dev | ||
;; | ||
"arch") | ||
echo "🔹 Detected Arch Linux" | ||
sudo pacman -Sy --noconfirm base-devel opencv hdf5 glew vtk fmt sdl2 pkg-config | ||
;; | ||
"macos") | ||
echo "🔹 Detected macOS" | ||
if ! command_exists brew; then | ||
echo "Homebrew not found. Installing Homebrew..." | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||
fi | ||
brew install git cmake opencv sdl2 | ||
;; | ||
*) | ||
echo "Unsupported OS" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
echo "Installation complete!" |