[PR #6009] Fix #5976: Add job-index and job-total to strategy context #2659

Open
opened 2026-03-01 22:37:37 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/6009
Author: @cobyfrombrooklyn-bot
Created: 2/24/2026
Status: 🔄 Open

Base: masterHead: fix-issue-5976


📝 Commits (1)

  • b2c8ca2 fix: add job-index and job-total to strategy context

📊 Changes

4 files changed (+34 additions, -0 deletions)

View changed files

📝 pkg/runner/expression.go (+4 -0)
📝 pkg/runner/expression_test.go (+26 -0)
📝 pkg/runner/run_context.go (+2 -0)
📝 pkg/runner/runner.go (+2 -0)

📄 Description

The strategy context was missing job-index and job-total attributes, which are documented in the GitHub Actions contexts reference. Workflows using strategy.job-index or strategy.job-total would get empty values.

Changes

  • Added JobIndex and JobTotal fields to RunContext struct
  • Set them in the matrix iteration loop in runner.go (line 190: for i, matrix := range matrixes)
  • Included job-index and job-total in the strategy map in both expression evaluator paths in expression.go

Test

Added TestStrategyJobIndexAndTotal in expression_test.go that:

  • Creates a RunContext with JobIndex=3 and JobTotal=5
  • Verifies strategy.job-index evaluates to 3
  • Verifies strategy.job-total evaluates to 5
  • Also checks strategy.fail-fast and strategy.max-parallel still work

Test fails without the fix (build error: RunContext has no field JobIndex/JobTotal), passes with it.

Tested locally on macOS ARM (Apple Silicon). All expression/unit tests pass. Pre-existing Docker-dependent test failures unrelated to this change.

Fixes #5976


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/6009 **Author:** [@cobyfrombrooklyn-bot](https://github.com/cobyfrombrooklyn-bot) **Created:** 2/24/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix-issue-5976` --- ### 📝 Commits (1) - [`b2c8ca2`](https://github.com/nektos/act/commit/b2c8ca2cdb1b724975f83f63980081359a7078e0) fix: add job-index and job-total to strategy context ### 📊 Changes **4 files changed** (+34 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `pkg/runner/expression.go` (+4 -0) 📝 `pkg/runner/expression_test.go` (+26 -0) 📝 `pkg/runner/run_context.go` (+2 -0) 📝 `pkg/runner/runner.go` (+2 -0) </details> ### 📄 Description The `strategy` context was missing `job-index` and `job-total` attributes, which are [documented in the GitHub Actions contexts reference](https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#strategy-context). Workflows using `strategy.job-index` or `strategy.job-total` would get empty values. ## Changes - Added `JobIndex` and `JobTotal` fields to `RunContext` struct - Set them in the matrix iteration loop in `runner.go` (line 190: `for i, matrix := range matrixes`) - Included `job-index` and `job-total` in the strategy map in both expression evaluator paths in `expression.go` ## Test Added `TestStrategyJobIndexAndTotal` in `expression_test.go` that: - Creates a RunContext with JobIndex=3 and JobTotal=5 - Verifies `strategy.job-index` evaluates to 3 - Verifies `strategy.job-total` evaluates to 5 - Also checks `strategy.fail-fast` and `strategy.max-parallel` still work Test fails without the fix (build error: RunContext has no field JobIndex/JobTotal), passes with it. Tested locally on macOS ARM (Apple Silicon). All expression/unit tests pass. Pre-existing Docker-dependent test failures unrelated to this change. Fixes #5976 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#2659
No description provided.