diff --git a/.github/workflows/hero_build.yml b/.github/workflows/hero_build.yml index 61956e8d..f914d904 100644 --- a/.github/workflows/hero_build.yml +++ b/.github/workflows/hero_build.yml @@ -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 diff --git a/examples/virt/herorun/cleanup.vsh b/examples/virt/herorun/cleanup.vsh index 6bdc99ee..f4c23e42 100755 --- a/examples/virt/herorun/cleanup.vsh +++ b/examples/virt/herorun/cleanup.vsh @@ -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') diff --git a/examples/virt/herorun/execute.vsh b/examples/virt/herorun/execute.vsh index 98fd8f7a..8c5fc234 100755 --- a/examples/virt/herorun/execute.vsh +++ b/examples/virt/herorun/execute.vsh @@ -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) diff --git a/examples/virt/herorun/setup.vsh b/examples/virt/herorun/setup.vsh index 72cd0319..dea1db51 100755 --- a/examples/virt/herorun/setup.vsh +++ b/examples/virt/herorun/setup.vsh @@ -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') diff --git a/examples/virt/herorun/setup_python_alpine.vsh b/examples/virt/herorun/setup_python_alpine.vsh index e8b5de17..7b47b55e 100755 --- a/examples/virt/herorun/setup_python_alpine.vsh +++ b/examples/virt/herorun/setup_python_alpine.vsh @@ -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') diff --git a/examples/virt/herorun/setup_with_script.vsh b/examples/virt/herorun/setup_with_script.vsh index e505df8f..daa6f178 100755 --- a/examples/virt/herorun/setup_with_script.vsh +++ b/examples/virt/herorun/setup_with_script.vsh @@ -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') diff --git a/examples/virt/herorun/test_hello_world.vsh b/examples/virt/herorun/test_hello_world.vsh index b9141283..ea70e221 100755 --- a/examples/virt/herorun/test_hello_world.vsh +++ b/examples/virt/herorun/test_hello_world.vsh @@ -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!') diff --git a/lib/virt/herorun/README.md b/lib/virt/herorun/README.md index 8aa21898..7c22a4aa 100644 --- a/lib/virt/herorun/README.md +++ b/lib/virt/herorun/README.md @@ -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 diff --git a/.github/workflows/github_actions_security.yml b/libarchive/github_actions_security.yml similarity index 100% rename from .github/workflows/github_actions_security.yml rename to libarchive/github_actions_security.yml diff --git a/libarchive/hero_build.yml b/libarchive/hero_build.yml new file mode 100644 index 00000000..375963dd --- /dev/null +++ b/libarchive/hero_build.yml @@ -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/*