### SCCache Environment Variable Setup (Bash) Source: https://github.com/runs-on/action/blob/main/README.md This bash script illustrates the underlying commands executed by the Runs On action to configure sccache. It sets environment variables related to GitHub Actions integration, S3 bucket, AWS region, S3 key prefix, and Rust compiler wrapper. ```bash echo "SCCACHE_GHA_ENABLED=false" >> $GITHUB_ENV echo "SCCACHE_BUCKET=${{ env.RUNS_ON_S3_BUCKET_CACHE}}" >> $GITHUB_ENV echo "SCCACHE_REGION=${{ env.RUNS_ON_AWS_REGION}}" >> $GITHUB_ENV echo "SCCACHE_S3_KEY_PREFIX=cache/sccache" >> $GITHUB_ENV echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV ``` -------------------------------- ### Basic RunsOn Action Setup with S3 Cache Source: https://context7.com/runs-on/action/llms.txt Demonstrates the fundamental configuration of the RunsOn Action in a GitHub Actions workflow, enabling S3 caching for build processes. It requires the 'runs-on' runner to be specified with caching extras. ```yaml name: Build with RunsOn on: [push] jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 - uses: actions/checkout@v4 - name: Build project run: make build - name: Run tests run: make test ``` -------------------------------- ### GitHub Actions: Advanced Build Pipeline with Runs-On Source: https://context7.com/runs-on/action/llms.txt This YAML defines a comprehensive GitHub Actions workflow. It utilizes the 'runs-on' property to specify a custom runner environment with specific hardware and extras like S3 cache. The workflow includes steps for checking out code, setting up sccache, installing dependencies, building a C++ project with sccache, running tests, and displaying sccache statistics. ```yaml name: Advanced Build Pipeline on: push: branches: [main] pull_request: jobs: build-and-test: runs-on: runs-on=${{ github.run_id }}/runner=8cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: show_costs: summary metrics: cpu,network,memory,disk,io sccache: s3 - uses: actions/checkout@v4 - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y build-essential cmake - name: Build C++ project run: | mkdir build && cd build cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=sccache make -j$(nproc) - name: Run tests run: | cd build ctest --output-on-failure - name: Show sccache stats run: sccache --show-stats ``` -------------------------------- ### Build Release Binaries and JS Files (Make) Source: https://github.com/runs-on/action/blob/main/README.md This make command is used during development to create release binaries and JavaScript files. It assumes a 'Makefile' exists in the project. ```makefile make release ``` -------------------------------- ### Go: Costs Package for Execution Cost Calculation Source: https://context7.com/runs-on/action/llms.txt This Go program calculates and displays execution costs, integrating with the AWS pricing API. It first loads configuration using the 'config.NewConfigFromInputs' function. Then, it calls 'costs.ComputeAndDisplayCosts' to perform the calculation and display cost details, including instance type, region, duration, total cost, GitHub equivalent cost, and savings. Error handling for configuration and cost computation is included. ```go package main import ( "context" "github.com/runs-on/action/internal/config" "github.com/runs-on/action/internal/costs" "github.com/sethvargo/go-githubactions" ) func main() { action := githubactions.New() ctx := context.Background() // Load configuration cfg, err := config.NewConfigFromInputs(action) if err != nil { action.Errorf("Config error: %v", err) return } // Compute and display costs (post-execution phase) err = costs.ComputeAndDisplayCosts(action, cfg) if err != nil { action.Warningf("Cost calculation failed: %v", err) return } // Cost data includes: // - Instance type and lifecycle (spot/on-demand) // - Region and availability zone // - Duration and total cost // - GitHub equivalent cost comparison // - Savings amount and percentage } ``` -------------------------------- ### Action Entry Point - Main and Post Execution Phases - Go Source: https://context7.com/runs-on/action/llms.txt The primary entry point for the GitHub action, handling both main execution and post-execution phases. It parses flags to determine the phase and orchestrates various internal packages for configuration, caching, monitoring, and environment display. ```go package main import ( "context" "flag" "github.com/runs-on/action/internal/cache" "github.com/runs-on/action/internal/config" "github.com/runs-on/action/internal/costs" "github.com/runs-on/action/internal/env" "github.com/runs-on/action/internal/monitoring" "github.com/runs-on/action/internal/sccache" "github.com/sethvargo/go-githubactions" ) func main() { ctx := context.Background() postFlag := flag.Bool("post", false, "Run post-execution phase") flag.Parse() action := githubactions.New() if *postFlag { // POST-EXECUTION PHASE cfg, _ := config.NewConfigFromInputs(action) // Display costs with savings calculation costs.ComputeAndDisplayCosts(action, cfg) // Generate metrics summary with charts if cfg.HasMetrics() { monitoring.GenerateMetricsSummary( action, cfg.Metrics, "chart", cfg.NetworkInterface, cfg.DiskDevice, ) } action.Infof("Post-execution phase finished.") } else { // MAIN EXECUTION PHASE cfg, _ := config.NewConfigFromInputs(action) // Show environment if requested if cfg.HasShowEnv() { env.DisplayEnvVars() } // Configure cache proxy cache.UpdateZctionsConfig(action, cfg.ActionsResultsURL, cfg.ZctionsResultsURL) // Configure sccache if cfg.HasSccache() { sccache.ConfigureSccache(action, cfg.Sccache) } // Configure CloudWatch metrics if cfg.HasMetrics() { monitoring.GenerateCloudWatchConfig( action, cfg.Metrics, cfg.NetworkInterface, cfg.DiskDevice, ) } action.Infof("Action finished.") } } ``` -------------------------------- ### Go: Config Package for Action Input Parsing and Validation Source: https://context7.com/runs-on/action/llms.txt This Go program demonstrates how to parse and validate action inputs using the 'githubactions' and a custom 'config' package. It detects the execution environment, checks for feature availability (metrics, sccache, show costs), and verifies if the action is running on the RunsOn infrastructure. Error handling is included for configuration loading. ```go package main import ( "github.com/runs-on/action/internal/config" "github.com/sethvargo/go-githubactions" ) func main() { action := githubactions.New() // Load configuration from action inputs and environment cfg, err := config.NewConfigFromInputs(action) if err != nil { action.Fatalf("Failed to load configuration: %v", err) } // Check feature availability if cfg.HasMetrics() { action.Infof("Metrics enabled: %v", cfg.Metrics) action.Infof("Network interface: %s", cfg.NetworkInterface) action.Infof("Disk device: %s", cfg.DiskDevice) } if cfg.HasSccache() { action.Infof("Sccache backend: %s", cfg.Sccache) } if cfg.HasShowCosts() { action.Infof("Cost display mode: %s", cfg.ShowCosts) } // Verify RunsOn environment if !cfg.IsUsingRunsOn() { action.Warningf("Not running on RunsOn infrastructure") } } ``` -------------------------------- ### Configure Metrics Collection in RunsOn Action Source: https://github.com/runs-on/action/blob/main/README.md This YAML snippet demonstrates how to enable and configure the collection of various system metrics (CPU, network, memory, disk, I/O) using the 'metrics' input parameter within a GitHub Actions workflow step that utilizes the 'runs-on/action'. It specifies a comma-separated list of desired metrics. ```yaml jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: metrics: cpu,network,memory,disk,io ``` -------------------------------- ### Sccache S3 Backend Configuration for Builds Source: https://context7.com/runs-on/action/llms.txt Sets up Mozilla's sccache with an S3 backend for accelerated C/C++/Rust compilation caching within a GitHub Actions workflow using RunsOn runners. This requires the `sccache` input to be set to `s3` and typically involves using the `mozilla-actions/sccache-action`. ```yaml jobs: rust-build: runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: sccache: s3 - uses: mozilla-actions/sccache-action@v0.0.9 - uses: actions/checkout@v4 - name: Build Rust project run: | cargo build --release sccache --show-stats ``` -------------------------------- ### Go: Cache Package for S3 Cache Proxy Configuration Source: https://context7.com/runs-on/action/llms.txt This Go program updates the cache proxy configuration for artifact caching using an S3 backend. It retrieves necessary URLs from environment variables ('ACTIONS_RESULTS_URL', 'ZCTIONS_RESULTS_URL') and utilizes the 'cache.UpdateZctionsConfig' function to send a PUT request for configuring the RunsOn cache proxy. It includes a check to skip configuration if 'ZCTIONS_RESULTS_URL' is not set. ```go package main import ( "github.com/runs-on/action/internal/cache" "github.com/sethvargo/go-githubactions" "os" ) func main() { action := githubactions.New() // Get required URLs from environment actionsResultsURL := os.Getenv("ACTIONS_RESULTS_URL") zctionsResultsURL := os.Getenv("ZCTIONS_RESULTS_URL") if zctionsResultsURL == "" { action.Infof("ZCTIONS_RESULTS_URL not set, skipping cache config update") return } // Update cache proxy configuration // Sends PUT request to configure RunsOn cache proxy cache.UpdateZctionsConfig(action, actionsResultsURL, zctionsResultsURL) action.Infof("Cache proxy configured successfully") } ``` -------------------------------- ### CloudWatch Metrics Collection with RunsOn Action Source: https://context7.com/runs-on/action/llms.txt Configures the RunsOn Action to collect and visualize CPU, memory, disk, network, and I/O metrics. Specify the desired metrics via the `metrics` input and optionally configure network interface and disk device. ```yaml jobs: performance-test: runs-on: runs-on=${{ github.run_id }}/runner=8cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: metrics: cpu,network,memory,disk,io network_interface: enp39s0 disk_device: nvme0n1p1 - uses: actions/checkout@v4 - name: Run performance tests run: | docker build -t myapp . docker run --rm myapp npm run benchmark ``` -------------------------------- ### Enable Environment Variable Debugging with runs-on/action (YAML) Source: https://github.com/runs-on/action/blob/main/README.md This YAML configuration shows how to enable the `show_env` option for the runs-on/action. This is useful for debugging by displaying all environment variables available within the action's environment. ```yaml jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: show_env: true ``` -------------------------------- ### Display Environment Variables for Debugging - Go Source: https://context7.com/runs-on/action/llms.txt Displays all environment variables available in the current process, sorted alphabetically. This is useful for debugging workflow environments. The output is formatted for readability. ```go package main import ( "github.com/runs-on/action/internal/env" ) func main() { // Display all environment variables sorted alphabetically env.DisplayEnvVars() // Output format: // --- Environment Variables --- // AWS_REGION=us-east-1 // GITHUB_ACTIONS=true // GITHUB_REPOSITORY=owner/repo // RUNS_ON_RUNNER_NAME=runner-xyz // RUNS_ON_S3_BUCKET_CACHE=cache-bucket // --------------------------- } ``` -------------------------------- ### Configure SCCache with S3 Backend Source: https://github.com/runs-on/action/blob/main/README.md This snippet demonstrates how to configure the 'runs-on/action' to utilize sccache with an S3 backend for compilation caching. It requires the 'mozilla-actions/sccache-action' and sets environment variables for sccache configuration. ```yaml jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: sccache: s3 - uses: mozilla-actions/sccache-action@v0.0.9 - run: # your slow rust compilation ``` -------------------------------- ### Go: Sccache Package for S3 Cache Configuration Source: https://context7.com/runs-on/action/llms.txt This Go program configures sccache to use an S3 backend for compilation caching. It calls the 'sccache.ConfigureSccache' function with 's3' as the backend, which requires specific environment variables like 'RUNS_ON_S3_BUCKET_CACHE' and 'RUNS_ON_AWS_REGION'. The program logs success or failure and mentions the automatically set environment variables and supported languages. ```go package main import ( "github.com/runs-on/action/internal/sccache" "github.com/sethvargo/go-githubactions" ) func main() { action := githubactions.New() // Configure sccache with S3 backend // Requires RUNS_ON_S3_BUCKET_CACHE and RUNS_ON_AWS_REGION env vars if err := sccache.ConfigureSccache(action, "s3"); err != nil { action.Errorf("Failed to configure sccache: %v", err) return } // Environment variables automatically set: // - SCCACHE_GHA_ENABLED=false // - SCCACHE_BUCKET= // - SCCACHE_REGION= // - SCCACHE_S3_KEY_PREFIX=cache/sccache // - RUSTC_WRAPPER=sccache action.Infof("Sccache configured for Rust, C, C++, and CUDA") } ``` -------------------------------- ### Cost Tracking Summary with RunsOn Action Source: https://context7.com/runs-on/action/llms.txt Enables cost calculation and display for GitHub Actions jobs running on RunsOn infrastructure, comparing the costs against standard GitHub-hosted runners. Set the `show_costs` input to `summary` to enable this feature. ```yaml jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: show_costs: summary - run: | npm install npm run build npm test ``` -------------------------------- ### Configure runs-on/action for Magic Caching (YAML) Source: https://github.com/runs-on/action/blob/main/README.md This snippet demonstrates how to configure the runs-on/action in a GitHub Actions workflow YAML file to utilize the magic caching feature. It specifies the runner configuration and includes the action. ```yaml jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 - other steps ``` -------------------------------- ### Display Workflow Job Costs with runs-on/action (YAML) Source: https://github.com/runs-on/action/blob/main/README.md This YAML snippet illustrates how to use the `show_costs` option with the runs-on/action. It can display the cost of running a workflow job in the action log output and optionally in the GitHub job summary. ```yaml jobs: build: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64/extras=s3-cache steps: - uses: runs-on/action@v2 with: show_costs: inline ``` -------------------------------- ### Configure CloudWatch Metrics Collection - Go Source: https://context7.com/runs-on/action/llms.txt Generates and applies CloudWatch agent configuration to collect specified performance metrics like CPU, memory, and disk I/O. It supports auto-detection for network interfaces and disk devices. This function is intended for the main execution phase of the action. ```go package main import ( "github.com/runs-on/action/internal/monitoring" "github.com/sethvargo/go-githubactions" ) func main() { action := githubactions.New() // Configure metrics collection metrics := []string{"cpu", "network", "memory", "disk", "io"} networkInterface := "enp39s0" // or "auto" for auto-detection diskDevice := "nvme0n1p1" // or "auto" for auto-detection // Generate and apply CloudWatch configuration err := monitoring.GenerateCloudWatchConfig( action, metrics, networkInterface, diskDevice, ) if err != nil { action.Errorf("Metrics config failed: %v", err) return } action.Infof("CloudWatch agent configured with metrics: %v", metrics) // In post-execution phase, generate summary with charts monitoring.GenerateMetricsSummary( action, metrics, "chart", // or "sparkline" networkInterface, diskDevice, ) } ``` -------------------------------- ### Display Environment Variables with RunsOn Action Source: https://context7.com/runs-on/action/llms.txt Configures the RunsOn Action to display all available environment variables within a GitHub Actions job. This is useful for debugging and understanding the runner's environment. The `show_env` input must be set to `true`. ```yaml jobs: debug: runs-on: runs-on=${{ github.run_id }}/runner=2cpu-linux-x64 steps: - uses: runs-on/action@v2 with: show_env: true - run: echo "Environment variables displayed above" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.