Skip to content

Commit

Permalink
feat: initial setup for the ethereum hive github action (#1)
Browse files Browse the repository at this point in the history
Creating a reusable github action to run ethereum hive.
  • Loading branch information
skylenet authored Jan 14, 2025
1 parent ac743d7 commit 13e36f8
Show file tree
Hide file tree
Showing 9 changed files with 649 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/actions/install-deps/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Install dependencies

runs:
using: 'composite'
steps:
- name: Add gh-cli to apt
shell: bash
run: |
(type -p wget >/dev/null || (apt update && apt-get install wget -y)) \
&& mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
- name: Install apt packages
shell: bash
run: |
apt update && apt install -y unzip gh yq
28 changes: 28 additions & 0 deletions .github/workflows/pr-title-checker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: pr-title-checker

on:
pull_request_target:
types:
- opened
- edited
- synchronize
- reopened
merge_group:

concurrency:
group: "title-checker-${{ github.head_ref || github.ref }}"
cancel-in-progress: true

permissions:
pull-requests: read

jobs:
pr_title_checker:
name: validate
# Skip merge-queue PRs
if: contains(github.ref_name, 'gh-readonly-queue/main/') != true
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: release-please

on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@d1a8f221d7723166f48a584aebba00ef3f6febec
with:
token: ${{ secrets.PAT }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
26 changes: 26 additions & 0 deletions .github/workflows/test-custom-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test - Custom Config
on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
client: go-ethereum
simulator: ethereum/rpc-compat
workflow_artifact_upload: true
client_config: |
- client: go-ethereum
nametag: go-ethereum-main
dockerfile: git
build_args:
github: ethereum/go-ethereum
tag: master
19 changes: 19 additions & 0 deletions .github/workflows/test-simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test - Simple
on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
client: go-ethereum
simulator: ethereum/sync
workflow_artifact_upload: true
143 changes: 141 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,141 @@
# hive-github-action
GitHub action to run [Ethereum Hive](https://github.com/ethereum/hive)
# Ethereum Hive 🐝 Github Action

This action is a wrapper around [Ethereum Hive](https://github.com/ethereum/hive). It allows you to run tests with different clients and simulators. It also supports uploading test results to S3 and/or as a workflow artifact.

> ⚠️ **Note:** This action is still under development and may introduce breaking changes. If you want to use it in your workflows, make sure to reference to a specific commit hash.
## Inputs

### Test Configuration

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `simulator` | Simulator to run (e.g. ethereum/sync) | Yes | `ethereum/sync` |
| `client` | Client to test | Yes | `go-ethereum` |
| `client_config` | Client configuration in YAML format | No | - |
| `extra_flags` | Additional flags to pass to hive | No | - |

### Hive Configuration

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `hive_repository` | Hive repository to use | No | `ethereum/hive` |
| `hive_version` | Hive version/branch to use | No | `master` |
| `go_version` | Go version used to build hive | No | `1.21` |

### S3 Upload Configuration

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `s3_upload` | Upload test results to S3 | No | `false` |
| `s3_bucket` | S3 bucket name | No* | - |
| `s3_path` | Path prefix in S3 bucket | No | `hive-results` |
| `rclone_version` | Rclone version to use | No | `latest` |
| `rclone_config` | Base64 encoded rclone config file | No | - |

*Required if `s3_upload` is `true`

### GitHub Workflow Artifact Configuration

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `workflow_artifact_upload` | Upload test results as a workflow artifact | No | `false` |
| `workflow_artifact_prefix` | Name of the workflow prefix. If not provided, the prefix will be the simulator and client name. | No | - |

## Examples

### Simple example doing sync tests with the latest go-ethereum

```yaml
- uses: ./.github/actions/hive
with:
client: go-ethereum
simulator: ethereum/sync
```
### With custom client config
You can customize the [client configuration](https://github.com/ethereum/hive/blob/master/docs/commandline.md#client-build-parameters). This allows using different docker files that are available for each client and their respective build arguments.
```yaml
env:
CLIENT_CONFIG: |
- client: go-ethereum
nametag: prague-devnet-5
dockerfile: git
build_args:
github: ethpandaops/go-ethereum
tag: my-custom-branch
```
Then you can use the `CLIENT_CONFIG` environment variable in your workflow.

```yaml
- uses: ./.github/actions/hive
with:
client: go-ethereum
simulator: ethereum/sync
client_config: ${{ env.CLIENT_CONFIG }}
```

### Uploading the results directory to S3

You'll need to create an rclone config and base64 encode it. Then store it as a github actions secret on your repository.

An example rclone config could look like this:

```toml
# Content of rclone.conf
[s3]
type = s3
provider = Cloudflare
region = auto
endpoint = https://your-r2-account-id.r2.cloudflarestorage.com
access_key_id = your-access-key-id
secret_access_key = your-secret-access-key
no_check_bucket = true
```

Then you can run `base64 -w 0 rclone.conf` and store the output as a github actions secret.

Afterwards you just need to reference the secret for the `rclone_config` input.

```yaml
- uses: ./.github/actions/hive
with:
client: go-ethereum
simulator: ethereum/sync
client_config: ${{ env.CLIENT_CONFIG }}
s3_upload: true
s3_bucket: my-bucket
s3_path: my-path
rclone_config: ${{ secrets.RCLONE_CONFIG }}
```

### Uploading the results directory as an GitHub workflow artifact

This will upload the test results as a workflow artifact. By default the artifact prefix will be the simulator and client name. You can override this by providing a `workflow_artifact_prefix` input.
```yaml
- uses: ./.github/actions/hive
with:
client: go-ethereum
simulator: ethereum/sync
workflow_artifact_upload: true
# workflow_artifact_prefix: my-custom-prefix
```
## Local testing and development

To test the action locally, you can run [act](https://github.com/nektos/act) with the following command:

```bash
act -s GITHUB_TOKEN="$(gh auth token)" -W '.github/workflows/test.yaml'
```

Or if you configured a custom runner, you can run `act` with the following command:

```bash
act -s GITHUB_TOKEN="$(gh auth token)" -W '.github/workflows/your-workflow.yaml' -P your-self-hosted-runner=catthehacker/ubuntu:act-latest
```

## License

Refer to the repository's license file for information on the licensing of this GitHub Action and the associated software.
Loading

0 comments on commit 13e36f8

Please sign in to comment.