From f079122be5d4f38169f0dc8da76cd9d8fbca6d98 Mon Sep 17 00:00:00 2001 From: despiegk Date: Fri, 7 Feb 2025 05:54:33 +0300 Subject: [PATCH] ... --- .github/workflows/hero_build_linux.yml | 63 +------ install_v.sh | 164 +++++++++++------- test_basic.vsh | 6 +- .../workflows => workflows}/documentation.yml | 0 workflows/hero_build_linux.yml | 97 +++++++++++ .../hero_build_macos.yml | 3 + {.github/workflows => workflows}/release.yml | 0 7 files changed, 206 insertions(+), 127 deletions(-) rename {.github/workflows => workflows}/documentation.yml (100%) create mode 100644 workflows/hero_build_linux.yml rename {.github/workflows => workflows}/hero_build_macos.yml (90%) rename {.github/workflows => workflows}/release.yml (100%) diff --git a/.github/workflows/hero_build_linux.yml b/.github/workflows/hero_build_linux.yml index d1325cc2..eedba69f 100644 --- a/.github/workflows/hero_build_linux.yml +++ b/.github/workflows/hero_build_linux.yml @@ -33,65 +33,8 @@ jobs: - 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: Setup V & Herolib + run: ./install_v.sh --herolib - 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}} + run: ./test_basic.vsh diff --git a/install_v.sh b/install_v.sh index a10fb814..1d0742c4 100755 --- a/install_v.sh +++ b/install_v.sh @@ -1,4 +1,3 @@ - #!/bin/bash -e # Help function @@ -198,9 +197,9 @@ function os_update { echo 'builduser ALL=(ALL) NOPASSWD: ALL' | tee /etc/sudoers.d/builduser fi - if [[ -n "${DEBUG}" ]]; then - execute_with_marker "paru_install" paru_install - fi + # if [[ -n "${DEBUG}" ]]; then + # execute_with_marker "paru_install" paru_install + # fi fi echo ' - os update done' } @@ -300,6 +299,28 @@ remove_all() { # Function to check if a service is running and start it if needed check_and_start_redis() { + + # Handle Redis installation for GitHub Actions environment + if is_github_actions; then + + # 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 + + return + fi + # Normal service management for non-container environments if [[ "${OSNAME}" == "ubuntu" ]] || [[ "${OSNAME}" == "debian" ]]; then @@ -362,6 +383,74 @@ check_and_start_redis() { fi } +v-install() { + + # Only clone and install if directory doesn't exist + if [ ! -d ~/code/v ]; then + echo "Installing V..." + mkdir -p ~/_code + cd ~/_code + git clone --depth=1 https://github.com/vlang/v + cd v + make + sudo ./v symlink + fi + + # Verify v is in path + if ! command_exists v; then + echo "Error: V installation failed or not in PATH" + echo "Please ensure ~/code/v is in your PATH" + exit 1 + fi + + echo "V installation successful!" + +} + + +v-analyzer() { + + # Install v-analyzer if requested + if [ "$INSTALL_ANALYZER" = true ]; then + echo "Installing v-analyzer..." + v download -RD https://raw.githubusercontent.com/vlang/v-analyzer/main/install.vsh + + # Check if v-analyzer bin directory exists + if [ ! -d "$HOME/.config/v-analyzer/bin" ]; then + echo "Error: v-analyzer bin directory not found at $HOME/.config/v-analyzer/bin" + echo "Please ensure v-analyzer was installed correctly" + exit 1 + fi + + echo "v-analyzer installation successful!" + fi + + # Add v-analyzer to PATH if installed + if [ -d "$HOME/.config/v-analyzer/bin" ]; then + V_ANALYZER_PATH='export PATH="$PATH:$HOME/.config/v-analyzer/bin"' + + # Function to add path to rc file if not present + add_to_rc() { + local RC_FILE="$1" + if [ -f "$RC_FILE" ]; then + if ! grep -q "v-analyzer/bin" "$RC_FILE"; then + echo "" >> "$RC_FILE" + echo "$V_ANALYZER_PATH" >> "$RC_FILE" + echo "Added v-analyzer to $RC_FILE" + else + echo "v-analyzer path already exists in $RC_FILE" + fi + fi + } + + # Add to both .zshrc and .bashrc if they exist + add_to_rc ~/.zshrc + if [ "$(uname)" = "Darwin" ] && [ -f ~/.bashrc ]; then + add_to_rc ~/.bashrc + fi + fi +} + # Handle remove if requested @@ -390,72 +479,15 @@ if [ "$RESET" = true ] || ! command_exists v; then # Install secp256k1 install_secp256k1 - # Only clone and install if directory doesn't exist - if [ ! -d ~/code/v ]; then - echo "Installing V..." - mkdir -p ~/_code - cd ~/_code - git clone --depth=1 https://github.com/vlang/v - cd v - make - sudo ./v symlink + v-install + + # Only install v-analyzer if not in GitHub Actions environment + if ! is_github_actions; then + v-analyzer fi - # Verify v is in path - if ! command_exists v; then - echo "Error: V installation failed or not in PATH" - echo "Please ensure ~/code/v is in your PATH" - exit 1 - fi - echo "V installation successful!" fi -# Install v-analyzer if requested -if [ "$INSTALL_ANALYZER" = true ]; then - echo "Installing v-analyzer..." - v download -RD https://raw.githubusercontent.com/vlang/v-analyzer/main/install.vsh - - # Check if v-analyzer bin directory exists - if [ ! -d "$HOME/.config/v-analyzer/bin" ]; then - echo "Error: v-analyzer bin directory not found at $HOME/.config/v-analyzer/bin" - echo "Please ensure v-analyzer was installed correctly" - exit 1 - fi - - echo "v-analyzer installation successful!" -fi - -# Add v-analyzer to PATH if installed -if [ -d "$HOME/.config/v-analyzer/bin" ]; then - V_ANALYZER_PATH='export PATH="$PATH:$HOME/.config/v-analyzer/bin"' - - # Function to add path to rc file if not present - add_to_rc() { - local RC_FILE="$1" - if [ -f "$RC_FILE" ]; then - if ! grep -q "v-analyzer/bin" "$RC_FILE"; then - echo "" >> "$RC_FILE" - echo "$V_ANALYZER_PATH" >> "$RC_FILE" - echo "Added v-analyzer to $RC_FILE" - else - echo "v-analyzer path already exists in $RC_FILE" - fi - fi - } - - # Add to both .zshrc and .bashrc if they exist - add_to_rc ~/.zshrc - if [ "$(uname)" = "Darwin" ] && [ -f ~/.bashrc ]; then - add_to_rc ~/.bashrc - fi -fi - -# Final verification -if ! command_exists v; then - echo "Error: V is not accessible in PATH" - echo "Please add ~/code/v to your PATH and try again" - exit 1 -fi check_and_start_redis diff --git a/test_basic.vsh b/test_basic.vsh index c44d9c2f..a06591cb 100755 --- a/test_basic.vsh +++ b/test_basic.vsh @@ -173,7 +173,7 @@ lib/develop ' // the following tests have no prio and can be ignored -tests_ignore := ' +mut tests_ignore := ' notifier_test.v clients/meilisearch clients/zdb @@ -185,6 +185,10 @@ data/radixtree clients/livekit ' +if os.exists("/home/runner"){ + tests_ignore+="clients/livekit" +} + tests_error := ' tmux_window_test.v tmux_test.v diff --git a/.github/workflows/documentation.yml b/workflows/documentation.yml similarity index 100% rename from .github/workflows/documentation.yml rename to workflows/documentation.yml diff --git a/workflows/hero_build_linux.yml b/workflows/hero_build_linux.yml new file mode 100644 index 00000000..d1325cc2 --- /dev/null +++ b/workflows/hero_build_linux.yml @@ -0,0 +1,97 @@ +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/hero_build_macos.yml b/workflows/hero_build_macos.yml similarity index 90% rename from .github/workflows/hero_build_macos.yml rename to workflows/hero_build_macos.yml index 616a76ae..ad070088 100644 --- a/.github/workflows/hero_build_macos.yml +++ b/workflows/hero_build_macos.yml @@ -3,9 +3,12 @@ name: Build Hero on Macos & Run tests permissions: contents: write +# Workflow is temporarily disabled. To enable, set ENABLE_MACOS_BUILD=true in repository secrets on: push: + if: ${{ vars.ENABLE_MACOS_BUILD == 'true' }} workflow_dispatch: + if: ${{ vars.ENABLE_MACOS_BUILD == 'true' }} jobs: build: diff --git a/.github/workflows/release.yml b/workflows/release.yml similarity index 100% rename from .github/workflows/release.yml rename to workflows/release.yml