Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 86 additions & 0 deletions .github/.agents/skills/optimize-workflow/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: optimize-workflow
description: Optimize CI runners and workflow structure for speed, simplicity, stability, and cost.
disable-model-invocation: true
---

<initialization>
Prompt user if missing:
1. Workflow to optimize.
2. Priorities (default: stability > speed > cost).
3. "Speed" definition (e.g., cache hits vs raw execution).
4. "Stability" definition (e.g., are flaky tests acceptable?).
5. Spot setting (infer via scenarios, do not ask directly). [runs-on spot reference](https://runs-on.com/docs/costs/spot-pricing/)
6. Acceptable structural changes (e.g., job splitting, caching, lint reorganization, trigger optimizations).

Setup:
1. Analyze workflow: identify jobs, runners, step dependencies, critical path, caching, and bottlenecks.
2. Identify structural optimizations:
- Parallelize sequential steps/jobs (e.g., matrix builds).
- Add/fix caching (e.g., go modules, cargo, npm, docker layers).
- Move checks/lints before compilation/tests to fail early.
- Refactor triggers/scope.
3. Permitted scope: High freedom. OK to introduce breaking edits to internal `smartcontractkit` actions/workflows to improve speed/simplicity.
4. Ask user to target: specific job, whole workflow runner config, or workflow structure.
5. Setup test workflow (bypass gates, mock inputs, add `workflow_dispatch`).
6. Init/resume trial log: `.github/.agents/skills/optimize-workflow/trials/<workflow>.md`.
7. Run baseline trial with current configuration to benchmark.
</initialization>

<constraints>
- No OOM or Out of Disk Space failures allowed.
- Prefer default `ubuntu-latest`. Use `runs-on` only for larger runner requirements.
- Note: `runs-on` with `tmpfs` enabled can cause silent OOMs (not visible in memory metrics) under high disk load. Toggle `tmpfs` off if unexplained OOMs occur, and evaluate speed/cost impact.
- Verify runner configuration via available runners API before use.
- Validate workflow YAML syntax (e.g., `actionlint` or dry-run) before committing.
- Maintain semantic correctness. OK to break internal `smartcontractkit` action/workflow interfaces for speed/simplicity.
- Use `gh` CLI for runs and PRs.
- Change only one variable per trial.
- Ensure fair comparison: cache status must be identical across trials compared for speed.
- Document runner config and structure layout in each trial to ensure reproducibility.
</constraints>

<resources>
- [runs-on docs](https://runs-on.com/docs/)
- [available runners](https://go.runs-on.com/api)
- [GitHub Action docs](https://docs.github.com/en/actions)
</resources>

<loop>
1. Define trials. Update `<workflow>.md` log.
2. User approves trials and execution method (parallel vs sequential).
3. Push to new disposable branch.
- Commit message: `cpu=X/ram=Y` or `struct/[caching|parallel|ordering|simplify]`
- PR title: `[DO NOT MERGE] Trial: <workflow-name>`
- PR body: Details of configuration. Include before-after Mermaid diagram showing structural flow.
4. Trigger workflow.
5. Monitor run:
`python3 .github/.agents/skills/optimize-workflow/scripts/workflow_monitor.py [run_id] --format json --out-file .github/.agents/skills/optimize-workflow/trials/[trial-name].json`
6. Compare trials:
`python3 .github/.agents/skills/optimize-workflow/scripts/workflow_compare.py .github/.agents/skills/optimize-workflow/trials/[trial-1].json .github/.agents/skills/optimize-workflow/trials/[trial-2].json --out-file .github/.agents/skills/optimize-workflow/trials/[trial-1]-[trial-2]-comparison.md`
7. Update trial log. Include updated before-after diagram if structural changes occurred.
8. Show condensed results. Prompt for more trials or stop.

<trial-template>
| Runner | Structure | Experiment | Expectation | Branch | Run ID | Commit | Stability | Runtime | Cost | Notes |
|---|---|---|---|---|---|---|---|---|---|---|
| `config` | `default / cached / parallel` | What's tested | Expected result | `branch` | `run-id` | `sha` | Pass/Fail/Flaky | mm:ss | $ | Findings |
</trial-template>
</loop>

<complete trigger="User stops loop or all trials done">
1. Recommend final configuration.
2. Add PR summary table and before-after Mermaid diagrams:

```md
### [Workflow/Job Name] Runner & Structure Changes

| Approach | Runner | Structure | Stability | Runtime | Runtime Delta (Abs/%) | Cost | Cost Delta (Abs/%) |
|---|---|---|---|---|---|---|---|
| [Old](https://github.com/link/to/baseline/workflow_run) | [original runner] | [original structure] | Pass/Fail/Flaky | mm:ss | +0:00 (+0%) | $ | +$ (+0%) |
| [New](https://github.com/link/to/final/workflow_run) | [new runner] | [new structure] | Pass/Fail/Flaky | mm:ss | +0:00 (+0%) | $ | +$ (+0%) |
```

3. Clean debug lines. Make final approved edits on a new branch. Ask user to commit.
4. Delete trial branches, logs, and PRs.
</complete>
74 changes: 0 additions & 74 deletions .github/.agents/skills/right-size-runners/SKILL.md

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tools/clroot/db.sqlite3-wal
.env*
.dbenv
!.github/actions/setup-postgres/.env
/.github/.agents/skills/right-size-runners/trials/
/.github/.agents/skills/**/trials/
.direnv
.idea
.vscode/
Expand Down
Loading