-
Notifications
You must be signed in to change notification settings - Fork 840
[ci] Migrate reexec tasks to a script to simplify maintenance #4761
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
base: master
Are you sure you want to change the base?
Conversation
| description: 'The password for the Prometheus instance.' | ||
| required: true | ||
| default: '' | ||
| workspace: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this was unused.
| role-to-assume: ${{ inputs.aws-role }} | ||
| aws-region: ${{ inputs.aws-region }} | ||
| role-duration-seconds: ${{ inputs.aws-role-duration-seconds }} | ||
| - name: Validate inputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation moved to the script so its defined once for use locally and in CI and it can be subject to shellcheck linting.
| run: echo "BENCHMARK_OUTPUT_FILE=${GITHUB_WORKSPACE}/benchmark-output.json" >> "$GITHUB_ENV" | ||
| - name: Run C-Chain Re-execution Benchmark | ||
| shell: nix develop --impure --command bash -x {0} | ||
| run: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this configuration to the script
| - name: Set task env | ||
| - name: Set benchmark output file | ||
| shell: bash | ||
| run: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXECUTION_DATA_DIR is now set in the script
| summary-always: true | ||
| github-token: ${{ inputs.github-token }} | ||
| auto-push: ${{ inputs.push-github-action-benchmark }} | ||
| - name: Push Post-State to S3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronbuchwald I might have been overzealous here - was your intent to only push to s3 if the benchmark comparison succeeded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR consolidates C-Chain re-execution logic from multiple Taskfile tasks into a single unified shell script to simplify maintenance and usage.
Key Changes:
- Introduces
reexecute_cchain.shscript with preset test configurations and custom test support - Removes complex Taskfile orchestration in favor of direct script execution
- Simplifies GitHub Actions workflows by replacing task-based invocation with direct script calls
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/reexecute_cchain.sh | New unified script that handles test presets, S3 data import, execution, and optional post-state pushing |
| Taskfile.yml | Removes reexecution-related tasks and adds simplified test-c-chain-reexecution entry point; simplifies export-cchain-block-range task |
| .github/workflows/c-chain-reexecution-benchmark-gh-native.yml | Updates workflow to use test parameter instead of task parameter |
| .github/workflows/c-chain-reexecution-benchmark-gh-native.json | Updates matrix configuration to use test instead of task |
| .github/workflows/c-chain-reexecution-benchmark-container.yml | Updates workflow to use test parameter instead of task parameter |
| .github/workflows/c-chain-reexecution-benchmark-container.json | Updates matrix configuration to use test instead of task |
| .github/actions/c-chain-reexecution-benchmark/action.yml | Simplifies action inputs and logic to call script directly with environment variable overrides |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
scripts/reexecute_cchain.sh
Outdated
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| S3_BOOTSTRAP_BUCKET="${S3_BOOTSTRAP_BUCKET:-s3://avalanchego-bootstrap-testing}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken, we switched to turning each of these sets of parameters into tasks to comply with the notion that tasks should be fully encompassed within the task instead of passing in a bunch of parameters.
I'd argue that a wide range of different sets of options like this is not as common to place within a bash script.
Would you still push to keep each of these baked into one configuration options within this script if we are going to move it out of the taskfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intended for tasks to be both discoverable and to serve as entrypoints into CI so that reproducing CI was as simple as possible. The goal was not to implement anything non-trivial directly in the tasks, though, and I think that the reexec task logic is better maintained outside of the taskfile as I've proposed in this PR.
I think creating a task per reexec test configuration makes about as much sense as creating a task per e2e test. It's still possible to target the execution of an e2e test but it's the e2e test suite that's responsible for enabling that rather than something we need to do in the taskfile. I think it similarly makes sense for there to be an entrypoint in the taskfile for executing reexec tests, and that the entrypoint be responsible for defining both common test configurations and enabling ad-hoc configuration.
|
Could you please validate the change by stepping through the README and updating it as needed? |
scripts/reexecute_cchain.sh
Outdated
| set -euo pipefail | ||
|
|
||
| # C-Chain Re-execution Script | ||
| # Usage: ./scripts/reexecute_cchain.sh <test-name> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running START_BLOCK=1 END_BLOCK=200_000 task test-c-chain-reexecution -- custom locally fails with the following error message:
task: [test-c-chain-reexecution] ./scripts/reexecute_cchain.sh custom
Error: Missing required env vars: S3_BLOCK_DIR S3_STATE_DIR
Ideally, I shouldn't have to set the S3 variables if I'm using my own current state/block directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're using your own state/block directory, you can call the benchmark_cchain_range.sh script directly. But to your point, maybe there should be a single more flexible script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yes. To my understanding, reexecute_cchain_range.sh is an extension of benchmark_cchain_range.sh and so I think it would make sense to have one script rather than have two scripts which can be confusing (e.g. I ran reexecute_cchain_range.sh rather than benchmark_cchain_range.sh)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I'll tackle that first thing tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the existing script and added a new script/task for the import. PTAL
Done |
91851f9 to
0df3f05
Compare
|
Not ideal that we have a README with complex instructions that have to be manually verified when things change. Mental note: prefer an executable script in future with inline comments instead of a static README. |
scripts/benchmark_cchain_range.sh
Outdated
| missing=() | ||
| [[ -z "${BLOCK_DIR_SRC:-}" ]] && missing+=("BLOCK_DIR_SRC") | ||
| [[ -z "${CURRENT_STATE_DIR_SRC:-}" ]] && missing+=("CURRENT_STATE_DIR_SRC") | ||
| [[ -z "${START_BLOCK:-}" ]] && missing+=("START_BLOCK") | ||
| [[ -z "${END_BLOCK:-}" ]] && missing+=("END_BLOCK") | ||
|
|
||
| if [[ ${#missing[@]} -gt 0 ]]; then | ||
| error "Missing required env vars: ${missing[*]}" | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running task test-cchain-reexecution with just BLOCK_DIR and CURRENT_STATE_DIR set, I get the following error message:
Without test-name, expects env vars: BLOCK_DIR, CURRENT_STATE_DIR, START_BLOCK, END_BLOCK
Ideally, it should tell me that just START_BLOCK and END_BLOCK are missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to indicate the status of required env vars.
scripts/benchmark_cchain_range.sh
Outdated
| # METRICS_COLLECTOR_ENABLED: If set, enables the metrics collector. | ||
| # PUSH_POST_STATE: S3 destination to push current-state after execution. | ||
| # | ||
| # For 'custom' test or S3 import with other tests: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit / feel-free-to-ignore): could we say something along the lines of "For all other tests which fetch from S3" to make it clear that any predefined/custom test uses S3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Though 'runs a predefined test that automatically imports data from S3' on L12 already tried to convey this.
Edit: Rewrite this section as part of removing custom
tests/reexecute/c/README.md
Outdated
| ### Using Custom Parameters | ||
|
|
||
| [Taskfile](https://taskfile.dev/) supports reading arguments via both environment variables and named arguments on the command line, so we'll set `EXECUTION_DATA_DIR` and use the defaults for the remainder of the parameters: | ||
| For custom benchmark runs, use the `custom` test with environment variables: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this seems like ./scripts/benchmark_cchain_range.sh and ./scripts/benchmark_cchain_range.sh custom do the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, removed custom
Doing anything non-trivial in tasks is not recommended. This change moves the reexec logic to a new script for ease of maintenance and to simplify usage.
0df3f05 to
809baac
Compare
Why this should be merged
Doing anything non-trivial in tasks is not recommended. This change moves the reexec logic to a new script for ease of maintenance and to simplify usage.
How this was tested
Need to be documented in RELEASES.md?
N/A