-
Notifications
You must be signed in to change notification settings - Fork 808
ci: composable avalanchego action #4341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Elvis339
wants to merge
43
commits into
master
Choose a base branch
from
composable-ci-action
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
966eb57
ci(avalanchego-build)
Elvis339 ec8fe0e
ci: temp. run custom action on github runners
Elvis339 36f8420
ci: temp. run custom action on github runners with ubuntu-latest tag
Elvis339 8a517e5
ci(gh_runners): temp. checkout
Elvis339 04a9aa8
ci: remove checkout
Elvis339 1477677
ci: add checkout back
Elvis339 58784da
ci: remove defaults from coreth and libevm
Elvis339 bec87c7
debug
Elvis339 ebeafdc
ci: use $GITHUB_ACTION_PATH
Elvis339 17af2a7
ci: github runners
Elvis339 76b7009
ci: github runners use nix and use realpath
Elvis339 7aafbae
ci: github runners run help from bin
Elvis339 35e7eb6
ci: self-hosted runners
Elvis339 2ea5241
ci: self-hosted runners install build-essential
Elvis339 0e863be
ci: self-hosted runners run & build reexecution bench
Elvis339 b63ffe4
ci: self-hosted runners run & build reexecution bench
Elvis339 18e728c
ci(reexec): temp. disable go setup
Elvis339 3dfbc38
re-run re-exec
Elvis339 dfa8c81
ci: set permissions
Elvis339 06708b0
ci(avalanchego-build-action): use composable Firewood action
Elvis339 fb8a6cf
ci: reexecution bench with firewood custom action
Elvis339 da4c389
ci: add back ci jobs & remove tmp. jobs
Elvis339 6a09874
Merge branch 'master' into composable-ci-action
Elvis339 2c84ad9
ci: uncomment c-chain-reexecution-benchmark-* pull_request directive
Elvis339 f1a55c7
chore: address copilot PR review
Elvis339 4702f81
ci(c-chain-reexecution-benchmark)
Elvis339 7ac895c
ci(avalanchego-build-action): use `go get` instead of checking libevm…
Elvis339 26443d9
feat(build): extend build with Firewood
Elvis339 833f844
ci(avalanche-go-setup):
Elvis339 4257069
ci: test composition
Elvis339 24805ed
ci: test composition - switch AWS role
Elvis339 7503a0c
ci: test composition - switch AWS role
Elvis339 9f82ca8
ci: test composition - set permissions
Elvis339 db1bbc5
ci: test composition - set permissions
Elvis339 4df4b98
ci: test composition, set `config: firewood` to reexec bench
Elvis339 1674dfa
ci: set current state dir src to firewood 100
Elvis339 6de7ef2
ci: revert to default
Elvis339 6b212a9
Merge branch 'master' into composable-ci-action
Elvis339 07ada03
ci(avalanchego-setup-action): add `firewood-path` checkout path allow…
Elvis339 79f3d9b
Merge remote-tracking branch 'origin/composable-ci-action' into compo…
Elvis339 106ee40
ci(avalanchego-setup-action): handle checkout-path
Elvis339 57329f2
ci(avalanchego-setup-action): handle checkout-path
Elvis339 daff6b5
ci(avalanchego-setup-action): correct Firewood setup path
Elvis339 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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 }} | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- 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 | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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 | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
fi | ||
|
||
go mod tidy | ||
go mod download | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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" | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
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 | ||
Elvis339 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.