refactor: Simplify V and Herolib setup (#45)

* refactor: Simplify V and Herolib setup

- Use install_v.sh script to install V and Herolib in CI.

Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>

* WIP: handle github actions in vlang installer

- Add `--github-actions` flag to `install_v.sh` script.
- Add appropriate privilege when running install_v.sh script.

Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>

* refactor: consolidate build workflows

- Consolidate macOS and Linux build workflows into a single `build_and_test.yml` workflow.
- Remove the now-redundant `hero_build_linux.yml` workflow.
- Update the workflow to support both Linux and macOS targets.
- Update `install_v.sh` script to handle brew installations without sudo.

Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>

---------

Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>
This commit is contained in:
2025-02-03 17:04:40 +02:00
committed by GitHub
parent c886f85d21
commit ee205c4b07
7 changed files with 83 additions and 251 deletions

View File

@@ -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: |

View File

@@ -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: |

View File

@@ -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}}

View File

@@ -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: |