Skip to content

Fix race condition in benchmark and tokei-metrics workflows #43

@RAprogramm

Description

@RAprogramm

Fix race condition when benchmark and tokei-metrics workflows run in parallel.

Problem

When code changes are pushed to main, both workflows trigger simultaneously:

  • benchmark.yml (triggers on src/, benches/, Cargo.toml)
  • tokei-metrics.yml (triggers on src/, tests/, benches/**, etc.)

Both workflows:

  1. Checkout main
  2. Update README.md
  3. Commit and push

If they run in parallel, one will fail with:

! [rejected]        main -> main (fetch first)
error: failed to push some refs

Example

Workflow run failed: https://github.com/RAprogramm/cstring-array/actions/runs/18625288263

Solution

Add git pull --rebase origin main before git push in both workflows:

benchmark.yml:179

git commit -m "chore: update benchmark results [skip ci]"
git pull --rebase origin main  # ← ADD
git push

tokei-metrics.yml:159

git commit -m "chore: update tokei metrics [skip ci]"
git pull --rebase origin main  # ← ADD
git push

This ensures both workflows can merge their changes even when running in parallel.

Benefits

  • No more failed workflow runs
  • Both metrics update successfully
  • Race-safe parallel execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions