This commit is contained in:
2025-09-07 07:21:40 +04:00
parent 746d9d16c7
commit bbac841427
10 changed files with 276 additions and 205 deletions

View File

@@ -9,24 +9,13 @@ on:
jobs:
build:
timeout-minutes: 60
if: startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
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:
@@ -34,6 +23,10 @@ jobs:
- 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 }}."
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Check out repository code
uses: actions/checkout@v4

View File

@@ -1,21 +1,19 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.virt.herorun
fn main() {
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor using proper modules
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'ai_agent_container'
keyname: 'id_ed25519'
)!
// Create executor using proper modules
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'ai_agent_container'
keyname: 'id_ed25519'
)!
// Cleanup using tmux and osal modules
executor.cleanup()!
// Cleanup using tmux and osal modules
executor.cleanup()!
println('Cleanup complete')
}
println('Cleanup complete')

View File

@@ -1,32 +1,30 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.virt.herorun
import os
fn main() {
// Get command from command line args
if os.args.len < 2 {
println('Usage: ./execute.vsh "command" [context_id]')
exit(1)
}
cmd := os.args[1]
// context_id := if os.args.len > 2 { os.args[2] } else { 'default' }
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor using proper modules
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'ai_agent_container'
keyname: 'id_ed25519'
)!
// Execute command using osal module for clean output
output := executor.execute(cmd)!
// Output only the command result
print(output)
// Get command from command line args
if os.args.len < 2 {
println('Usage: ./execute.vsh "command" [context_id]')
exit(1)
}
cmd := os.args[1]
// context_id := if os.args.len > 2 { os.args[2] } else { 'default' }
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor using proper modules
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'ai_agent_container'
keyname: 'id_ed25519'
)!
// Execute command using osal module for clean output
output := executor.execute(cmd)!
// Output only the command result
print(output)

View File

@@ -1,21 +1,19 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.virt.herorun
fn main() {
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor using proper module integration
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'ai_agent_container'
keyname: 'id_ed25519'
)!
// Create executor using proper module integration
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'ai_agent_container'
keyname: 'id_ed25519'
)!
// Setup using sshagent, tmux, hetznermanager, and osal modules
executor.setup()!
// Setup using sshagent, tmux, hetznermanager, and osal modules
executor.setup()!
println('Setup complete')
}
println('Setup complete')

View File

@@ -1,57 +1,55 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.virt.herorun
fn main() {
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor with Alpine Python base image
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'python_alpine_container'
keyname: 'id_ed25519'
image_script: 'examples/virt/herorun/images/python_server.sh'
base_image: .alpine_python // Use Alpine with Python pre-installed
)!
// Create executor with Alpine Python base image
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'python_alpine_container'
keyname: 'id_ed25519'
image_script: 'examples/virt/herorun/images/python_server.sh'
base_image: .alpine_python // Use Alpine with Python pre-installed
)!
// Setup container
executor.setup()!
// Setup container
executor.setup()!
// Create container with Python Alpine base and Python server script
mut container := executor.get_or_create_container(
name: 'python_alpine_container'
image_script: 'examples/virt/herorun/images/python_server.sh'
base_image: .alpine_python
)!
// Create container with Python Alpine base and Python server script
mut container := executor.get_or_create_container(
name: 'python_alpine_container'
image_script: 'examples/virt/herorun/images/python_server.sh'
base_image: .alpine_python
)!
println(' Setup complete with Python Alpine container')
println('Container: python_alpine_container')
println('Base image: Alpine Linux with Python 3 pre-installed')
println('Entry point: python_server.sh')
println(' Setup complete with Python Alpine container')
println('Container: python_alpine_container')
println('Base image: Alpine Linux with Python 3 pre-installed')
println('Entry point: python_server.sh')
// Test the container to show Python is available
println('\n🐍 Testing Python availability...')
python_test := executor.execute('runc exec python_alpine_container python3 --version') or {
println(' Python test failed: ${err}')
return
}
println(' Python version: ${python_test}')
println('\n🚀 Running Python HTTP server...')
println('Note: This will start the server and exit (use runc run for persistent server)')
// Run the container to start the Python server
result := executor.execute('runc run python_alpine_container') or {
println(' Container execution failed: ${err}')
return
}
println('📋 Server output:')
println(result)
println('\n🎉 Python Alpine container executed successfully!')
println('💡 The Python HTTP server would run on port 8000 if started persistently')
// Test the container to show Python is available
println('\n🐍 Testing Python availability...')
python_test := executor.execute('runc exec python_alpine_container python3 --version') or {
println(' Python test failed: ${err}')
return
}
println(' Python version: ${python_test}')
println('\n🚀 Running Python HTTP server...')
println('Note: This will start the server and exit (use runc run for persistent server)')
// Run the container to start the Python server
result := executor.execute('runc run python_alpine_container') or {
println(' Container execution failed: ${err}')
return
}
println('📋 Server output:')
println(result)
println('\n🎉 Python Alpine container executed successfully!')
println('💡 The Python HTTP server would run on port 8000 if started persistently')

View File

@@ -1,31 +1,29 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.virt.herorun
fn main() {
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor with image script for Python server
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'python_server_container'
keyname: 'id_ed25519'
image_script: 'examples/virt/herorun/images/python_server.sh' // Path to entry point script
)!
// Create executor with image script for Python server
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'python_server_container'
keyname: 'id_ed25519'
image_script: 'examples/virt/herorun/images/python_server.sh' // Path to entry point script
)!
// Setup using sshagent, tmux, hetznermanager, and osal modules
executor.setup()!
// Setup using sshagent, tmux, hetznermanager, and osal modules
executor.setup()!
// Create container with the Python server script
mut container := executor.get_or_create_container(
name: 'python_server_container'
image_script: 'examples/virt/herorun/images/python_server.sh'
)!
// Create container with the Python server script
mut container := executor.get_or_create_container(
name: 'python_server_container'
image_script: 'examples/virt/herorun/images/python_server.sh'
)!
println('Setup complete with Python server container')
println('Container: python_server_container')
println('Entry point: examples/virt/herorun/images/python_server.sh (Python HTTP server)')
println('To start the server: runc run python_server_container')
}
println('Setup complete with Python server container')
println('Container: python_server_container')
println('Entry point: examples/virt/herorun/images/python_server.sh (Python HTTP server)')
println('To start the server: runc run python_server_container')

View File

@@ -1,42 +1,40 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.virt.herorun
fn main() {
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor with hello world script
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'hello_world_container'
keyname: 'id_ed25519'
image_script: 'examples/virt/herorun/images/hello_world.sh'
)!
// Setup container
executor.setup()!
// Create container with hello world script
mut container := executor.get_or_create_container(
name: 'hello_world_container'
image_script: 'examples/virt/herorun/images/hello_world.sh'
)!
println(' Setup complete with Hello World container')
println('Container: hello_world_container')
println('Entry point: hello_world.sh')
// Run the container to demonstrate it works
println('\n🚀 Running container...')
result := executor.execute('runc run hello_world_container') or {
println(' Container execution failed: ${err}')
return
}
println('📋 Container output:')
println(result)
println('\n🎉 Container executed successfully!')
// Create user with SSH key using sshagent module
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create executor with hello world script
mut executor := herorun.new_executor(
node_ip: '65.21.132.119'
user: 'root'
container_id: 'hello_world_container'
keyname: 'id_ed25519'
image_script: 'examples/virt/herorun/images/hello_world.sh'
)!
// Setup container
executor.setup()!
// Create container with hello world script
mut container := executor.get_or_create_container(
name: 'hello_world_container'
image_script: 'examples/virt/herorun/images/hello_world.sh'
)!
println(' Setup complete with Hello World container')
println('Container: hello_world_container')
println('Entry point: hello_world.sh')
// Run the container to demonstrate it works
println('\n🚀 Running container...')
result := executor.execute('runc run hello_world_container') or {
println(' Container execution failed: ${err}')
return
}
println('📋 Container output:')
println(result)
println('\n🎉 Container executed successfully!')

View File

@@ -30,36 +30,35 @@ lib/virt/herorun/
```v
import freeflowuniverse.herolib.virt.herorun
fn main() {
// Create user with SSH key
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Create Hetzner backend
mut backend := herorun.new_hetzner_backend(
node_ip: '65.21.132.119'
user: 'root'
)!
// Create user with SSH key
mut user := herorun.new_user(keyname: 'id_ed25519')!
// Connect to node (installs required packages automatically)
backend.connect(keyname: user.keyname)!
// Send a test command to the node
backend.send_command(cmd: 'ls')!
// Create Hetzner backend
mut backend := herorun.new_hetzner_backend(
node_ip: '65.21.132.119'
user: 'root'
)!
// Get or create container (uses tmux behind the scenes)
mut container := backend.get_or_create_container(name: 'test_container')!
// Attach to container tmux session
container.attach()!
// Connect to node (installs required packages automatically)
backend.connect(keyname: user.keyname)!
// Send a test command to the node
backend.send_command(cmd: 'ls')!
// Get or create container (uses tmux behind the scenes)
mut container := backend.get_or_create_container(name: 'test_container')!
// Attach to container tmux session
container.attach()!
// Send command to container
container.send_command(cmd: 'ls')!
// Get container logs
logs := container.get_logs()!
println('Container logs:')
println(logs)
// Send command to container
container.send_command(cmd: 'ls')!
// Get container logs
logs := container.get_logs()!
println('Container logs:')
println(logs)
}
```
### Running the Example

91
libarchive/hero_build.yml Normal file
View File

@@ -0,0 +1,91 @@
name: Release Hero
permissions:
contents: write
on:
push:
workflow_dispatch:
jobs:
build:
timeout-minutes: 60
if: startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
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 }}."
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup V & Herolib
id: setup
run: ./install_v.sh --herolib
timeout-minutes: 10
# - name: Do all the basic tests
# timeout-minutes: 25
# run: ./test_basic.vsh
- name: Build Hero
timeout-minutes: 15
run: |
set -e
v -w -d use_openssl -enable-globals cli/hero.v -o cli/hero-${{ matrix.target }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: hero-${{ matrix.target }}
path: cli/hero-${{ matrix.target }}
release_hero:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: cli/bins
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
fail_on_unmatched_files: true
generate_release_notes: true
files: cli/bins/*