diff --git a/.github/workflows/hero_build_macos.yml b/.github/workflows/build_and_test.yml similarity index 63% rename from .github/workflows/hero_build_macos.yml rename to .github/workflows/build_and_test.yml index ec0d22dd..8cbdfcb7 100644 --- a/.github/workflows/hero_build_macos.yml +++ b/.github/workflows/build_and_test.yml @@ -1,4 +1,4 @@ -name: Build Hero on Macos & Run tests +name: Build Hero & Run tests permissions: contents: write @@ -12,6 +12,9 @@ jobs: strategy: matrix: include: + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + short-name: linux-i64 - target: aarch64-apple-darwin os: macos-latest short-name: macos-arm64 @@ -28,34 +31,10 @@ jobs: uses: actions/checkout@v3 - name: Setup Vlang - run: | - git clone --depth=1 https://github.com/vlang/v - cd v - make - sudo ./v symlink - cd .. + run: ./install_v.sh --github-actions - name: Setup Herolib - run: | - mkdir -p ~/.vmodules/freeflowuniverse - ln -s $GITHUB_WORKSPACE/lib ~/.vmodules/freeflowuniverse/herolib - - echo "Installing secp256k1..." - brew install secp256k1 - - echo "secp256k1 installation complete!" - - - name: Install and Start Redis - run: | - brew update - brew install redis - - # Start Redis - redis-server --daemonize yes - - # Print versions - redis-cli --version - redis-server --version + run: ./install_herolib.vsh - name: Build Hero run: | diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index b6655dfe..847eca95 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -22,14 +22,11 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - - name: Install Vlang dependencies - run: sudo apt update && sudo apt install -y libgc-dev - - name: Checkout uses: actions/checkout@v3 - name: Setup Vlang - run: ./install_v.sh + run: ./install_v.sh --github-actions - name: Generate documentation run: | diff --git a/.github/workflows/hero_build_linux.yml b/.github/workflows/hero_build_linux.yml deleted file mode 100644 index d1325cc2..00000000 --- a/.github/workflows/hero_build_linux.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Build Hero on Linux & Run tests - -permissions: - contents: write - -on: - push: - workflow_dispatch: - -jobs: - build: - strategy: - matrix: - include: - - target: x86_64-unknown-linux-musl - os: ubuntu-latest - short-name: linux-i64 - # - target: aarch64-unknown-linux-musl - # os: ubuntu-latest - # short-name: linux-arm64 - # - target: aarch64-apple-darwin - # os: macos-latest - # short-name: macos-arm64 - # - target: x86_64-apple-darwin - # os: macos-13 - # short-name: macos-i64 - runs-on: ${{ matrix.os }} - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref_name }} and your repository is ${{ github.repository }}." - - - name: Check out repository code - uses: actions/checkout@v3 - - - name: Setup Vlang - run: | - git clone --depth=1 https://github.com/vlang/v - cd v - make - sudo ./v symlink - cd .. - - - name: Setup Herolib - run: | - mkdir -p ~/.vmodules/freeflowuniverse - ln -s $GITHUB_WORKSPACE/lib ~/.vmodules/freeflowuniverse/herolib - - echo "Installing secp256k1..." - # Install build dependencies - sudo apt-get install -y build-essential wget autoconf libtool - - # Download and extract secp256k1 - cd /tmp - wget https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v0.3.2.tar.gz - tar -xvf v0.3.2.tar.gz - - # Build and install - cd secp256k1-0.3.2/ - ./autogen.sh - ./configure - make -j 5 - sudo make install - - # Cleanup - rm -rf secp256k1-0.3.2 v0.3.2.tar.gz - - echo "secp256k1 installation complete!" - - - name: Install and Start Redis - run: | - # Import Redis GPG key - curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg - # Add Redis repository - echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list - # Install Redis - sudo apt-get update - sudo apt-get install -y redis - - # Start Redis - redis-server --daemonize yes - - # Print versions - redis-cli --version - redis-server --version - - - name: Build Hero - run: | - v -cg -enable-globals -w -n cli/hero.v - - - name: Do all the basic tests - run: | - ./test_basic.vsh - env: - LIVEKIT_API_KEY: ${{secrets.LIVEKIT_API_KEY}} - LIVEKIT_API_SECRET: ${{secrets.LIVEKIT_API_SECRET}} - LIVEKIT_URL: ${{secrets.LIVEKIT_URL}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 210c8574..d50a4678 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,44 +29,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Vlang - run: | - git clone --depth=1 https://github.com/vlang/v - cd v - make - sudo ./v symlink - cd .. + run: ./install_v.sh --github-actions - name: Setup Herolib - run: | - mkdir -p ~/.vmodules/freeflowuniverse - ln -s $GITHUB_WORKSPACE/lib ~/.vmodules/freeflowuniverse/herolib - - echo "Installing secp256k1..." - if [[ ${{ matrix.os }} == 'macos-latest' || ${{ matrix.os }} == 'macos-13' ]]; then - brew install secp256k1 - - elif [[ ${{ matrix.os }} == 'ubuntu-latest' ]]; then - # Install build dependencies - sudo apt-get install -y build-essential wget autoconf libtool - - # Download and extract secp256k1 - cd /tmp - wget https://github.com/bitcoin-core/secp256k1/archive/refs/tags/v0.3.2.tar.gz - tar -xvf v0.3.2.tar.gz - - # Build and install - cd secp256k1-0.3.2/ - ./autogen.sh - ./configure - make -j 5 - sudo make install - - else - echo "Unsupported OS: ${{ matrix.os }}" - exit 1 - fi - - echo "secp256k1 installation complete!" + run: ./install_herolib.vsh - name: Build Hero run: | diff --git a/install_herolib.vsh b/install_herolib.vsh index 051d705d..49da3cf2 100755 --- a/install_herolib.vsh +++ b/install_herolib.vsh @@ -1,49 +1,48 @@ -#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run +#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -d use_openssl -enable-globals run import os import flag fn addtoscript(tofind string, toadd string) ! { - home_dir := os.home_dir() - mut rc_file := '${home_dir}/.zshrc' - if !os.exists(rc_file) { - rc_file = '${home_dir}/.bashrc' - if !os.exists(rc_file) { - return error('No .zshrc or .bashrc found in home directory') - } - } + home_dir := os.home_dir() + mut rc_file := '${home_dir}/.zshrc' + if !os.exists(rc_file) { + rc_file = '${home_dir}/.bashrc' + if !os.exists(rc_file) { + return error('No .zshrc or .bashrc found in home directory') + } + } - // Read current content - mut content := os.read_file(rc_file)! - - // Remove existing alias if present - lines := content.split('\n') - mut new_lines := []string{} - mut prev_is_emtpy := false - for line in lines { - if prev_is_emtpy { - if line.trim_space() == ""{ - continue - }else{ - prev_is_emtpy = false - } - } - if line.trim_space() == ""{ - prev_is_emtpy = true - } + // Read current content + mut content := os.read_file(rc_file)! - if !line.contains(tofind) { - new_lines << line - } - } - new_lines << toadd - new_lines << "" - // Write back to file - new_content := new_lines.join('\n') - os.write_file(rc_file, new_content)! + // Remove existing alias if present + lines := content.split('\n') + mut new_lines := []string{} + mut prev_is_emtpy := false + for line in lines { + if prev_is_emtpy { + if line.trim_space() == '' { + continue + } else { + prev_is_emtpy = false + } + } + if line.trim_space() == '' { + prev_is_emtpy = true + } + + if !line.contains(tofind) { + new_lines << line + } + } + new_lines << toadd + new_lines << '' + // Write back to file + new_content := new_lines.join('\n') + os.write_file(rc_file, new_content)! } - vroot := @VROOT abs_dir_of_script := dir(@FILE) @@ -52,24 +51,24 @@ println('Resetting all symlinks...') os.rm('${os.home_dir()}/.vmodules/freeflowuniverse/herolib') or {} // Create necessary directories -os.mkdir_all('${os.home_dir()}/.vmodules/freeflowuniverse') or { - panic('Failed to create directory ~/.vmodules/freeflowuniverse: ${err}') +os.mkdir_all('${os.home_dir()}/.vmodules/freeflowuniverse') or { + panic('Failed to create directory ~/.vmodules/freeflowuniverse: ${err}') } // Create new symlinks os.symlink('${abs_dir_of_script}/lib', '${os.home_dir()}/.vmodules/freeflowuniverse/herolib') or { - panic('Failed to create herolib symlink: ${err}') + panic('Failed to create herolib symlink: ${err}') } println('Herolib installation completed successfully!') // Add vtest alias -addtoscript('alias vtest=', 'alias vtest=\'v -stats -enable-globals -n -w -cg -gc none -no-retry-compilation -cc tcc test\' ') or { - eprintln('Failed to add vtest alias: ${err}') +addtoscript('alias vtest=', "alias vtest='v -stats -enable-globals -n -w -cg -gc none -no-retry-compilation -cc tcc test' ") or { + eprintln('Failed to add vtest alias: ${err}') } addtoscript('HOME/hero/bin', 'export PATH="\$PATH:\$HOME/hero/bin"') or { - eprintln('Failed to add path to hero, ${err}') + eprintln('Failed to add path to hero, ${err}') } // ulimit -n 32000 diff --git a/install_v.sh b/install_v.sh index a10fb814..c43737ad 100755 --- a/install_v.sh +++ b/install_v.sh @@ -8,11 +8,12 @@ print_help() { echo "Usage: $0 [options]" echo echo "Options:" - echo " -h, --help Show this help message" - echo " --reset Force reinstallation of V" - echo " --remove Remove V installation and exit" - echo " --analyzer Install/update v-analyzer" - echo " --herolib Install our herolib" + echo " -h, --help Show this help message" + echo " --reset Force reinstallation of V" + echo " --remove Remove V installation and exit" + echo " --analyzer Install/update v-analyzer" + echo " --herolib Install our herolib" + echo " --github-actions Install for github actions" echo echo "Examples:" echo " $0" @@ -21,6 +22,7 @@ print_help() { echo " $0 --analyzer " echo " $0 --herolib " echo " $0 --reset --analyzer # Fresh install of both" + echo " $0 --github-actions" echo } @@ -29,6 +31,7 @@ RESET=false REMOVE=false INSTALL_ANALYZER=false HEROLIB=false +IS_GITHUB_ACTIONS=false for arg in "$@"; do case $arg in @@ -48,6 +51,9 @@ for arg in "$@"; do --analyzer) INSTALL_ANALYZER=true ;; + --github-actions) + IS_GITHUB_ACTIONS=true + ;; *) echo "Unknown option: $arg" echo "Use -h or --help to see available options" @@ -93,22 +99,19 @@ function package_check_install { function package_install { local command_name="$1" if [[ "${OSNAME}" == "ubuntu" ]]; then - apt -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install $1 -q -y --allow-downgrades --allow-remove-essential + sudo apt -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install $1 -q -y --allow-downgrades --allow-remove-essential elif [[ "${OSNAME}" == "darwin"* ]]; then brew install $command_name elif [[ "${OSNAME}" == "alpine"* ]]; then - apk add $command_name + sudo apk add $command_name elif [[ "${OSNAME}" == "arch"* ]]; then - pacman --noconfirm -Su $command_name + sudo pacman --noconfirm -Su $command_name else echo "platform : ${OSNAME} not supported" exit 1 fi } -is_github_actions() { - [ -d "/home/runner" ] || [ -d "$HOME/runner" ] -} function myplatform { @@ -146,26 +149,26 @@ myplatform function os_update { echo ' - os update' if [[ "${OSNAME}" == "ubuntu" ]]; then - if is_github_actions; then + if [ "$IS_GITHUB_ACTIONS" = true ]; then echo "github actions" else - rm -f /var/lib/apt/lists/lock - rm -f /var/cache/apt/archives/lock - rm -f /var/lib/dpkg/lock* + sudo rm -f /var/lib/apt/lists/lock + sudo rm -f /var/cache/apt/archives/lock + sudo rm -f /var/lib/dpkg/lock* fi export TERM=xterm export DEBIAN_FRONTEND=noninteractive dpkg --configure -a - apt update -y - if is_github_actions; then + sudo apt update -y + if [ "$IS_GITHUB_ACTIONS" = true ]; then echo "** IN GITHUB ACTIONS, DON'T DO UPDATE" else set +e echo "** UPDATE" - apt-mark hold grub-efi-amd64-signed + sudo apt-mark hold grub-efi-amd64-signed set -e - apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes - apt autoremove -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes + sudo apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes + sudo apt autoremove -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes fi #apt install apt-transport-https ca-certificates curl software-properties-common -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes package_install "apt-transport-https ca-certificates curl wget software-properties-common tmux" @@ -180,16 +183,17 @@ function os_update { unset NONINTERACTIVE fi set +e + brew update brew install mc redis curl tmux screen htop wget rclone tcc set -e elif [[ "${OSNAME}" == "alpine"* ]]; then - apk update screen git htop tmux - apk add mc curl rsync htop redis bash bash-completion screen git rclone + sudo apk update screen git htop tmux + sudo apk add mc curl rsync htop redis bash bash-completion screen git rclone sed -i 's#/bin/ash#/bin/bash#g' /etc/passwd elif [[ "${OSNAME}" == "arch"* ]]; then - pacman -Syy --noconfirm - pacman -Syu --noconfirm - pacman -Su --noconfirm arch-install-scripts gcc mc git tmux curl htop redis wget screen net-tools git sudo htop ca-certificates lsb-release screen rclone + sudo pacman -Syy --noconfirm + sudo pacman -Syu --noconfirm + sudo pacman -Su --noconfirm arch-install-scripts gcc mc git tmux curl htop redis wget screen net-tools git sudo htop ca-certificates lsb-release screen rclone # Check if builduser exists, create if not if ! id -u builduser > /dev/null 2>&1; then @@ -235,7 +239,7 @@ function install_secp256k1 { brew install secp256k1 elif [[ "${OSNAME}" == "ubuntu" ]]; then # Install build dependencies - apt-get install -y build-essential wget autoconf libtool + sudo apt-get install -y build-essential wget autoconf libtool # Download and extract secp256k1 cd "${DIR_BUILD}" @@ -247,7 +251,7 @@ function install_secp256k1 { ./autogen.sh ./configure make -j 5 - make install + sudo make install # Cleanup cd .. @@ -347,7 +351,7 @@ check_and_start_redis() { echo "redis is already running." else echo "redis is not running. Starting it..." - rc-service "redis" start + sudo rc-service "redis" start fi elif [[ "${OSNAME}" == "arch"* ]]; then if systemctl is-active --quiet "redis"; then diff --git a/lib/installers/infra/livekit/livekit_factory_.v b/lib/installers/infra/livekit/livekit_factory_.v index abc47f3b..208797a5 100644 --- a/lib/installers/infra/livekit/livekit_factory_.v +++ b/lib/installers/infra/livekit/livekit_factory_.v @@ -202,19 +202,3 @@ pub fn (mut self LivekitServer) destroy() ! { pub fn switch(name string) { livekit_default = name } - -pub fn (mut self LivekitServer) install(args InstallArgs) ! { - switch(self.name) - if args.reset { - destroy_()! - } - if !(installed_()!) { - install_()! - } -} - -pub fn (mut self LivekitServer) destroy() ! { - switch(self.name) - self.stop() or {} - destroy_()! -}