Skip to content
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
966eb57
ci(avalanchego-build)
Elvis339 Sep 25, 2025
ec8fe0e
ci: temp. run custom action on github runners
Elvis339 Sep 25, 2025
36f8420
ci: temp. run custom action on github runners with ubuntu-latest tag
Elvis339 Sep 25, 2025
8a517e5
ci(gh_runners): temp. checkout
Elvis339 Sep 25, 2025
04a9aa8
ci: remove checkout
Elvis339 Sep 25, 2025
1477677
ci: add checkout back
Elvis339 Sep 25, 2025
58784da
ci: remove defaults from coreth and libevm
Elvis339 Sep 25, 2025
bec87c7
debug
Elvis339 Sep 25, 2025
ebeafdc
ci: use $GITHUB_ACTION_PATH
Elvis339 Sep 25, 2025
17af2a7
ci: github runners
Elvis339 Sep 25, 2025
76b7009
ci: github runners use nix and use realpath
Elvis339 Sep 25, 2025
7aafbae
ci: github runners run help from bin
Elvis339 Sep 25, 2025
35e7eb6
ci: self-hosted runners
Elvis339 Sep 25, 2025
2ea5241
ci: self-hosted runners install build-essential
Elvis339 Sep 25, 2025
0e863be
ci: self-hosted runners run & build reexecution bench
Elvis339 Sep 25, 2025
b63ffe4
ci: self-hosted runners run & build reexecution bench
Elvis339 Sep 25, 2025
18e728c
ci(reexec): temp. disable go setup
Elvis339 Sep 25, 2025
3dfbc38
re-run re-exec
Elvis339 Sep 25, 2025
dfa8c81
ci: set permissions
Elvis339 Sep 25, 2025
06708b0
ci(avalanchego-build-action): use composable Firewood action
Elvis339 Sep 26, 2025
fb8a6cf
ci: reexecution bench with firewood custom action
Elvis339 Sep 26, 2025
da4c389
ci: add back ci jobs & remove tmp. jobs
Elvis339 Sep 26, 2025
6a09874
Merge branch 'master' into composable-ci-action
Elvis339 Sep 26, 2025
2c84ad9
ci: uncomment c-chain-reexecution-benchmark-* pull_request directive
Elvis339 Sep 26, 2025
f1a55c7
chore: address copilot PR review
Elvis339 Sep 26, 2025
4702f81
ci(c-chain-reexecution-benchmark)
Elvis339 Sep 26, 2025
7ac895c
ci(avalanchego-build-action): use `go get` instead of checking libevm…
Elvis339 Sep 26, 2025
26443d9
feat(build): extend build with Firewood
Elvis339 Sep 29, 2025
833f844
ci(avalanche-go-setup):
Elvis339 Sep 29, 2025
4257069
ci: test composition
Elvis339 Sep 29, 2025
24805ed
ci: test composition - switch AWS role
Elvis339 Sep 29, 2025
7503a0c
ci: test composition - switch AWS role
Elvis339 Sep 29, 2025
9f82ca8
ci: test composition - set permissions
Elvis339 Sep 29, 2025
db1bbc5
ci: test composition - set permissions
Elvis339 Sep 29, 2025
4df4b98
ci: test composition, set `config: firewood` to reexec bench
Elvis339 Sep 29, 2025
1674dfa
ci: set current state dir src to firewood 100
Elvis339 Sep 29, 2025
6de7ef2
ci: revert to default
Elvis339 Sep 29, 2025
6b212a9
Merge branch 'master' into composable-ci-action
Elvis339 Sep 29, 2025
07ada03
ci(avalanchego-setup-action): add `firewood-path` checkout path allow…
Elvis339 Oct 1, 2025
79f3d9b
Merge remote-tracking branch 'origin/composable-ci-action' into compo…
Elvis339 Oct 1, 2025
106ee40
ci(avalanchego-setup-action): handle checkout-path
Elvis339 Oct 1, 2025
57329f2
ci(avalanchego-setup-action): handle checkout-path
Elvis339 Oct 1, 2025
daff6b5
ci(avalanchego-setup-action): correct Firewood setup path
Elvis339 Oct 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/actions/avalanchego-build-action/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# AvalancheGo Build Action

## Overview
This action provides composable CI capabilities for building AvalancheGo with custom dependency versions.

### Why this exists?
Solves CI composability problems by enabling repositories to build AvalancheGo with specific dependency versions without complex setup or cross-repository coordination.

## Modes

**BUILD Mode** (target specified): Produces a ready-to-use binary with custom dependencies - for teams that need the executable.

When `target` parameter is provided, the action:
1. Checks out AvalancheGo at specified version
2. Replaces dependencies with custom versions
3. Builds the specified binary
4. Makes binary available via both output parameter AND artifact upload
5. Optionally executes binary with provided args

**SETUP Mode** (no target): Prepares the build environment with custom dependencies - for teams that need custom build workflows.

When `target` parameter is empty, the action:
1. Checks out AvalancheGo at specified version
2. Replaces dependencies with custom versions
3. Sets up build environment for consumer's custom workflow

## Security Model
- Repository Restriction: Only allows dependencies from `github.com/ava-labs/*` repositories
- No Custom Forks: Prevents supply chain attacks from malicious forks
- Commit Validation: Validates dependency versions reference ava-labs repositories only

## Inputs

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `target` | Which binary to build (`avalanchego`, `reexecution`). Determines BUILD vs SETUP mode | No | `''` |
| `args` | Command-line arguments for target executable (BUILD mode only) | No | `''` |
| `checkout-path` | Directory path where AvalancheGo will be checked out | No | `'avalanchego'` |
| `avalanchego` | AvalancheGo version (commit SHA, branch, tag) | No | `'main'` |
| `firewood` | Firewood version. Consumer should run Firewood shared workflow first | No | `''` |
| `coreth` | Coreth version (commit SHA, branch, tag) | No | `'main'` |
| `libevm` | LibEVM version (commit SHA, branch, tag) | No | `'main'` |

## Outputs

| Output | Description |
|--------|-------------|
| `binary-path` | Absolute path to built binary (BUILD mode only) |

## Usage Examples

### BUILD Mode - Binary Available for Consumer

```yaml
- name: Build AvalancheGo
id: build
uses: ./.github/actions/avalanchego-build-action
with:
target: "avalanchego"
coreth: "v0.12.5"
libevm: "v1.0.0"

- name: Use binary via output parameter
run: ${{ steps.build.outputs.binary-path }} --network-id=local

- name: Or download as artifact
uses: actions/download-artifact@v4
with:
name: avalanchego-avalanchego_main-coreth_v0.12.5-libevm_v1.0.0

- name: Use downloaded artifact
run: ./avalanchego --network-id=local
```

### SETUP Mode - Custom Workflow

```yaml
- name: Setup AvalancheGo with custom dependencies
uses: ./.github/actions/avalanchego-build-action
with:
checkout-path: "build/avalanchego"
coreth: "my-feature-branch"
libevm: "experimental-branch"

- name: Run custom build commands
run: |
cd build/avalanchego
./scripts/run_task.sh reexecute-cchain-range
./scripts/run_task.sh my-custom-task
```

## Artifact Naming

Artifacts are named with the complete dependency matrix for full traceability:

**Format:** `{target}-avalanchego_{version}-coreth_{version}-libevm_{version}[-firewood_{version}]`

**Examples:**
- `avalanchego-avalanchego_main-coreth_main-libevm_main` (default versions)
- `avalanchego-avalanchego_v1.11.0-coreth_v0.12.5-libevm_v1.0.0-firewood_ffi%2Fv0.0.13` (with firewood)
- `reexecution-avalanchego_my-branch-coreth_main-libevm_experimental-firewood_abc123` (mixed versions)
120 changes: 120 additions & 0 deletions .github/actions/avalanchego-build-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: 'AvalancheGo Build Action'
description: 'Build AvalancheGo with custom dependencies. Dual mode: BUILD (with target) creates binary, SETUP (no target) prepares environment.'

inputs:
target:
description: 'Binary to build (avalanchego, reexecution). If provided: BUILD mode. If empty: SETUP mode.'
required: false
default: ''
args:
description: 'Arguments for target executable (BUILD mode only)'
required: false
default: ''
checkout-path:
description: 'Directory path where AvalancheGo will be checked out'
required: false
default: 'avalanchego'
avalanchego:
description: 'AvalancheGo version (commit SHA, branch name, or tag)'
required: false
default: ${{ github.sha }}
firewood:
description: 'Firewood version (commit SHA, branch, tag, or ffi/vX.Y.Z for pre-built)'
required: false
default: ''
coreth:
description: 'Coreth version (commit SHA, branch name, or tag)'
required: false
default: ''
libevm:
description: 'LibEVM version (commit SHA, branch name, or tag)'
required: false
default: ''

outputs:
binary-path:
description: 'Absolute path to built binary (BUILD mode only)'
value: ${{ steps.build.outputs.binary-path }}

runs:
using: 'composite'
steps:
- name: Checkout AvalancheGo
uses: actions/checkout@v4
with:
repository: 'ava-labs/avalanchego'
ref: ${{ inputs.avalanchego }}
path: ${{ inputs.checkout-path }}
- name: Setup Go for project
uses: ./.github/actions/setup-go-for-project # Note: If Nix-specific functionality is needed, consumer should install Nix as a prerequisite to this action
- name: Setup Firewood FFI
if: inputs.firewood != ''
id: firewood
uses: ava-labs/firewood/.github/actions/build-action@composable-ci-action
with:
version: ${{ inputs.firewood }}
- name: Checkout Coreth
if: inputs.coreth != '' && inputs.coreth != 'master'
uses: actions/checkout@v4
with:
repository: 'ava-labs/coreth'
ref: ${{ inputs.coreth }}
path: 'coreth'
- name: Checkout LibEVM
if: inputs.libevm != '' && inputs.libevm != 'main'
uses: actions/checkout@v4
with:
repository: 'ava-labs/libevm'
ref: ${{ inputs.libevm }}
path: 'libevm'
- name: Replace dependencies with local checkouts
if: ${{ inputs.firewood != '' || inputs.coreth != '' || inputs.libevm != '' }}
shell: bash
working-directory: ./${{ inputs.checkout-path }}
run: |
# Replace Firewood FFI if provided
if [ "${{ inputs.firewood }}" != "" ]; then
echo "Replacing Firewood FFI with: ${{ steps.firewood.outputs.ffi-path }}"
go mod edit -replace github.com/ava-labs/firewood-go-ethhash/ffi=${{ steps.firewood.outputs.ffi-path }}
fi

# Replace Coreth if provided and not default
if [ "${{ inputs.coreth }}" != "" ] && [ "${{ inputs.coreth }}" != "master" ]; then
echo "Replacing Coreth with local checkout: ../coreth"
go mod edit -replace github.com/ava-labs/coreth=../coreth
fi

# Replace LibEVM if provided and not default
if [ "${{ inputs.libevm }}" != "" ] && [ "${{ inputs.libevm }}" != "main" ]; then
echo "Replacing LibEVM with local checkout: ../libevm"
go mod edit -replace github.com/ava-labs/libevm=../libevm
fi

go mod tidy
go mod download
- name: Build and run target (BUILD mode)
if: inputs.target != ''
id: build
shell: bash
working-directory: ./${{ inputs.checkout-path }}
run: |
if [ -n "${{ inputs.args }}" ]; then
OUTPUT=$(./scripts/build_target.sh "${{ inputs.target }}" ${{ inputs.args }})
else
OUTPUT=$(./scripts/build_target.sh "${{ inputs.target }}")
fi

# Extract binary path from script output
BINARY_PATH=$(echo "$OUTPUT" | grep "BINARY_PATH=" | cut -d'=' -f2)

# Convert to absolute path to avoid relative pathing issues
ABSOLUTE_BINARY_PATH=$(realpath "$BINARY_PATH")

# Set output for consumer use
echo "binary-path=$ABSOLUTE_BINARY_PATH" >> $GITHUB_OUTPUT
- name: Upload binary artifact (BUILD mode)
if: inputs.target != ''
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.target }}-avalanchego_${{ inputs.avalanchego }}-coreth_${{ inputs.coreth }}-libevm_${{ inputs.libevm }}${{ inputs.firewood != '' && format('-firewood_{0}', inputs.firewood) || '' }}
path: ${{ steps.build.outputs.binary-path }}
52 changes: 52 additions & 0 deletions .github/actions/avalanchego-build-action/build_target.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Build AvalancheGo target binary and optionally execute with arguments
# Usage: ./scripts/build_target.sh <target> [args...]

set -euo pipefail

if [[ $# -eq 0 ]]; then
echo "Usage: $0 <target> [args...]"
echo "Valid targets: avalanchego, reexecution"
exit 1
fi

TARGET="$1"
shift # Remove target from arguments, remaining args are for execution

case "$TARGET" in
"avalanchego")
if [[ ! -f "./scripts/run_task.sh" || ! -x "./scripts/run_task.sh" ]]; then
echo "Error: ./scripts/run_task.sh not found or not executable"
exit 1
fi
./scripts/run_task.sh build
EXECUTABLE="./build/avalanchego"

if [[ ! -f "$EXECUTABLE" ]]; then
echo "Error: Binary $EXECUTABLE was not created"
exit 1
fi

echo "BINARY_PATH=$PWD/$EXECUTABLE"

if [[ $# -gt 0 ]]; then
"$EXECUTABLE" "$@"
fi
;;
"reexecution")
# Compile reexecution benchmark test into binary
go test -c github.com/ava-labs/avalanchego/tests/reexecute/c -o reexecute-benchmark
EXECUTABLE="./reexecute-benchmark"

if [[ ! -f "$EXECUTABLE" ]]; then
echo "Error: Binary $EXECUTABLE was not created"
exit 1
fi

echo "BINARY_PATH=$PWD/$EXECUTABLE"
;;
*)
echo "Error: Invalid target '$TARGET'. Valid targets: avalanchego, reexecution"
exit 1
;;
esac
Loading